Introduction
The JSE_Webservice class is designed to call external web services and be able to exploit the results obtained. To be used, this class must be instantiated.
Constructor
JSE_WebService(String serverAdress, String protocol, int port)
var ws = new JSE_WebService("127.0.0.1", "http", 8000);
JSE_WebService(String serverAdress, String protocol)
var ws = new JSE_WebService("127.0.0.1", "http");
Duties
setAuthentication(string username, string password): void
This method allows you to insert authentication into the header of your web-service
ws.setAuthentication("login","mdp");
send: OBWebResponse
The send function allows you to send a REST web-service request containing parameters in the URL and return the result to you in the form of an OBWebResponse object
To use it, you have several options for calling:
- send(String pUrl, String pMethod, IDictionary<string, object> pHeaders, int pTimeout, bool stringResponse, IDictionary<string, object> queryParameters) [Requires Gateway version >= 1.1.1]
- pMethod: GET, POST, PUT, DELETE
- stringResponse: Allows you to know whether the response should be converted to a string or not. Useful in case the response is not a string but a file
- send(String pUrl, String pMethod, IDictionary
pHeaders, int pTimeout, bool stringResponse) - queryParameters: null
- send(String pUrl, String pMethod, IDictionary
pHeaders, int pTimeout) - stringResponse: true
- send(String pUrl, String pMethod, IDictionary
pHeaders) - pTimeout: -1
- send(String pUrl, String pMethod)
- pHeaders: null
- send(String pUrl)
- pMethod: GET
var ws = new JSE_WebService("127.0.0.1", "http", 8000);
ws.setAuthentication("admin","*****");
var res = ws.send("/ws/v2/version");
return JSON.parse(res.StringResponse).version;
sendJson: OBWebResponse
The sendJson function allows you to send a REST web-service request containing Json parameters and return the result to you in the form of an OBWebResponse object
To use it, you have several options for calling:
- sendJson(String pUrl, String pJson, String pMethod, IDictionary<string, object> pHeader, int pTimeout, bool stringResponse, IDictionary<string, object> queryParameters) [Requires Gateway version >=1.1.1]
- pMethod: GET, POST, PUT, DELETE
- stringResponse: Allows you to know whether the response should be converted to a string or not. Useful in case the response is not a string but a file
- sendJson(String pUrl, String pJson, String pMethod, IDictionary
pHeader, int pTimeout, bool stringResponse) - queryParameters: null
- sendJson(string pUrl, string pJson, string pMethod, IDictionary
pHeader, int pTimeout) - stringResponse: true
- sendJson(string pUrl, string pJson, string pMethod, IDictionary
pHeader) - pTimeout: -1
- sendJson(string pUrl, string pJson, string pMethod)
- pHeaders: null
- sendJson(string pUrl, string pJson)
- pMethod: GET
var ws = new JSE_WebService("ip.jsontest.com", "http");
var jsonParameter = {property : ["Sites"], report_type: ["ALL"]};
var res = ws.sendJson("",JSON.stringify(jsonParameter));
return res.StringResponse;
sendSoap: OBWebResponse
The sendJson function allows you to send a SOAP web-service request containing parameters and return the result to you in the form of an OBWebResponse object
To use it, you have several options for calling:
- sendSoap(string pUrl, string pSoapBody, string pMethod, IDictionary<string, object> pHeader, int pTimeout, bool stringResponse, IDictionary<string, object> queryParameters) [Requires Gateway version >= 1.1.1]
- stringResponse: Allows you to know whether the response should be converted to a string or not. Useful in case the response is not a string but a file
- pMethod: GET, POST, PUT, DELETE
- sendSoap(string pUrl, string pSoapBody, string pMethod, IDictionary
pHeader, int pTimeout, bool stringResponse) - queryParameters: null
- sendSoap(string pUrl, string pSoapBody, string pMethod, IDictionary
pHeader, int pTimeout) - stringResponse: true
- sendSoap(string pUrl, string pSoapBody, string pMethod, IDictionary
pHeader) - pTimeout: -1
- sendSoap(string pUrl, string pSoapBody, string pMethod)
- pHeaders: null
- sendSoap(string pUrl, string pSoapBody)
- pMethod: POST
var ws = new JSE_WebService("www.learnwebservices.com", "http");
var pSoapBody = '<CelsiusToFahrenheitRequest xmlns="http://learnwebservices.com/services/tempconverter"><TemperatureInCelsius>10.0</TemperatureInCelsius></CelsiusToFahrenheitRequest>';
return ws.sendSoap("/services/tempconverter", pSoapBody);
sendFiles: OBWebResponse
The sendFiles function allows you to send a REST web-service request containing parameters and files and return the result to you in the form of an OBWebResponse object
To use it, you have several options for calling:
- sendFiles(string pUrl, IDictionary<string, object> pFiles,IDictionary<string, object> pParameters, string pMethod, IDictionary<string, object> pHeader, int pTimeout, bool stringResponse, IDictionary<string, object> queryParameters) [Requires Gateway version >= 1.1.1]
- stringResponse: Allows you to know whether the response should be converted to a string or not. Useful in case the response is not a string but a file
- pMethod: GET, POST, PUT, DELETE
- sendFiles(string pUrl, IDictionary
pFiles,IDictionary pParameters, string pMethod, IDictionary pHeader, int pTimeout, bool stringResponse) - queryParameters: null
- sendFiles(string pUrl, IDictionary
pFiles, IDictionary pParameters, string pMethod, IDictionary pHeader, int pTimeout) - stringResponse: true
- sendFiles(string pUrl, IDictionary
pFiles, IDictionary pParameters, string pMethod, IDictionary pHeader) - pTimeout: -1
- sendFiles(string pUrl, IDictionary
pFiles, IDictionary pParameters, string pMethod) - pHeaders: null
- sendFiles(string pUrl, IDictionary
pFiles, IDictionary pParameters) - pMethod: POST
var pFiles = {};
var pParameters = {};
pFiles["file"] = "D:/Dossier/Documents/facture.pdf";
pParameters["idParentFolder"] = "1";
pParameters["path"] = "";
pParameters["name"] = "TestFile";
pParameters["type"] = "11306";
pParameters["metadatas[11360]"] = "Test Script";
pParameters["metadatas[11361]"] = "Fournisseur 2";
pParameters["metadatas[11362]"] = "116.32";
pParameters["metadatas[11363]"] = "11/23/2015";
pParameters["metadatas[11364]"] = "FC_425_TEST";
pParameters["metadatas[11365]"] = "EUR";
pParameters["metadatas[11366]"] = "Facture";
pParameters["metadatas[11367]"] = "12/06/2015";
var ws = new JSE_WebService("127.0.0.1", "http", 8000);
ws.setAuthentication("admin","****");
var res = ws.sendFiles("/ws/v2/document", pFiles, pParameters);
return res.StringResponse;
sendFormParameters: OBWebResponse
[Requires Gateway version >=1.1.1]
The sendFormParameters function allows you to send a REST web-service request containing formdata-encoded parameters and return the result to you in the form of an OBWebResponse object
To use it, you have several options for calling:
- sendFormParameter(string pUrl, string pMethod, IDictionary pHeaders, IDictionary pParameter, int pTimeout, bool stringResponse, IDictionary queryParameters)
- sendFormParameter(string pUrl, string pMethod, IDictionary pHeaders, IDictionary pParameter, int pTimeout, bool stringResponse)
- queryParameters: null
- sendFormParameter(string pUrl, string pMethod, IDictionary pHeaders, IDictionary pParameter, int pTimeout)
- stringResponse: true
- sendFormParameter(string pUrl, string pMethod, IDictionary pHeaders, IDictionary pParameter)
- pMethod: GET, POST, PUT, DELETE
- pTimeout: -1