Dashboard > WSO2 Mashup Server > ... > WSO2 Mashup Server Reference > WSRequest Host Object
  WSO2 Mashup Server Log in | Register   View a printable version of the current page.  
  WSRequest Host Object
Added by Jonathan Marsh , last edited by Thilina Gunarathne on Jul 06, 2007  (view change)
Labels: 
(None)

1.0 Introduction

The WSRequest object invokes an external Web service and returns the response as an XML payload.

1.1 Example

var version = new WSRequest();
var options = new Array();
options.useSOAP = 1.2;
options.useWSA = 1.0;
options.action = "urn:getVersion";
request = "<getVersion/>";

try {
	version.open(options,"http://127.0.0.1:11001/services/version", false);
	version.send(request);
	result = version.responseE4X;
} catch (e) {
	print(e);
}

2.0 WSRequest Object

2.1 WSRequest Interface

interface WSRequest
{
    property EventListener onreadystatechange;
    property unsigned short readyState;
    void open ( in object options | in String method, in String url [, in boolean async [, in String user [, in String password]]]);
    void send ( [in Document payload | in XMLString payload | in XMLString payload ]);
    readonly property String responseText;
    readonly property Document responseXML;
    readonly property XML responseE4X;
    readonly property WebServiceError error;
}

2.2 API Documentation

Member Description Supported in version
open(options, endpointAddress, async) This method prepares the WSRequest object to invoke a Web service.  It accepts the following parameters:
  • options (array): an array of options for formulating the message.  These options correspond to the message framing required by the service as documented in the service's WSDL and/or documentation.  A list of the supported options is at WSRequest Options.
  • endpointAddress (string): a URL representing where to send the message.
  • async (boolean): a boolean flag representing whether the operation should be invoked asynchrounously or not.
    The open() function throws an exception if the WSRequest object cannot accommodate the request (e.g., the options are malformed.)
0.1
send(payload) This method invokes the Web service with the requested payload.
  • payload: an XML object or a string containing the XML source for the request.
0.1
onreadystatechange 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). 0.1
readyState The current state of the object, which can be one of the following values:
  • 0: The object has not been initialized by calling the open() method.
  • 1: The object has been initialized successfully, but the send() method has not been called.
  • 2: The request is pending
  • 3: The request is partially complete (some data has been received, and may be available in the responseText property.
  • 4: The request is complete, all data has been received.
    Of these, typically only the last (readyState == 4) is used.
0.1
responseXML 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) 0.1
responseE4X The parsed E4X XML message representing the response from the service. 0.1
responseText 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. 0.1
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 0.1

3.0 Options

Option Range of values Description Supported in version
useSOAP "1.2", 1.2, "1.1", 1.1, true, false Indicates which version of SOAP to use. If the value is "1.2", 1.2, or True, the message will be framed as a SOAP 1.2 message. If "1.1" or 1.1, SOAP 1.1 will be used. If False, the payload will be sent directly as the HTTP body. These options correspond to the WSDL 2.0 SOAP 1.2 binding [ref], the WSDL 2.0 SOAP 1.1 binding [ref], and the WSDL 2.0 HTTP binding [ref]. 0.1
useWSA TRUE | FALSE | 1.0 | "1.0" | "submission" Indicates whether to use WS-Addressing. If TRUE, 1.0 or "1.0", WS-Addressing 1.0 is used. When "submission" is specified, the submitted version is used. Except when FALSE, the "action" must option must also be set. 0.1
action xs:anyURI The WS-A action to use when constructing the WS-A headers. Also used as the SOAP Action when specified, regardless of whether WS-A is engaged or not. 0.1
HTTPMethod xs:string | "POST" The HTTP method to use to formulate the request. 0.1

See Ideas for evolving WSRequest for additional options under development.

4.0 References

Powered by a free Atlassian Confluence Open Source Project License granted to WSO2 Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators