<% function invokeGetVersion() { var log = new Log(); var ws = require('ws'); var version = new ws.WSRequest(); var options = new Array(); options.useSOAP = 1.2; options.useWSA = 1.0; options.action = "urn:getVersion"; var payload = null; var result; try { version.open(options, "http://stratoslive.wso2.com/services/Version", false); version.send(payload); result = version.responseE4X; } catch (e) { log.error(e.toString()); return e.toString(); } return result; } print(invokeGetVersion()); %>
The WSRequest object is similar to the XMLHTTPRequest object. It's usage typically involves specifying the endpoint address and setting up options on how to frame the message, invoking the operation with a specific XML payload, and then checking and extracting information from the result.
Member | Type | Description |
---|---|---|
EventListener onreadystatechange | EventListener | This property can be set to a function object, which is invoked when the state of an asynchronous request changes (e.g. the request completes). |
readyState | Unsigned Short | var jsonObj = {}; jsonObj.name = "nuwan"; jsonObj.company = "wso2"; A JSON Object |
responseXML | Document | The parsed XML message representing the response from the service. (Currently this is same as responseE4X, but this will be fixed to return a DOM document in the future versions) |
responseE4X * | XML | The parsed E4X XML message representing the response from the service. |
responseText | String | The raw text representing the XML (or non-XML) response. If the responseXML property is empty, you can check the responseText property to see if a non-XML response was received. |
error | WebService Error | When an asynchronous operation failed to complete successfully (including internal errors, or protocol errors such as SOAP faults) the error property is a WebServiceError object |
Operation | Returns | Description |
---|---|---|
open ( object options | String httpMethod, String url [, Boolean async [, String username [, String password]]]) | None | This method prepares the WSRequest object to invoke a Web service. It accepts the following parameters:
The following is a list of supported options
When WS-Addressing is been used the following options will also be processed
To be specific here are the various ways which the open fucntion can be used in
|
send ( XML payload | XMLString payload ) | None | This method invokes the Web service with the requested payload. To be used when the WSRequest object was configured using the open method.
|
openWSDL ( String wsdlURL, Boolean async, [Object options,[QName serviceName, [String endpointName]]]) | None | This method can be used to invoke a external web service which advertices a WSDL. Using this method had many advantages over using the open method.
This method acceps the following parameters
The following is a list of supported options
|
send ( String operationName | QName operationName, XML payload | XMLString payload ) | None | This method invokes the specified operation of the Web service with the requested payload. To be used when the WSRequest object was configured using the openWSDL method.
|