Author: keith
Date: Sat Jul 19 11:50:52 2008
New Revision: 19644
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19644

Log:
Updating the docs for WSRequest Host object


Modified:
   trunk/mashup/java/xdocs/wsrequesthostobject.html

Modified: trunk/mashup/java/xdocs/wsrequesthostobject.html
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/wsrequesthostobject.html?rev=19644&r1=19643&r2=19644&view=diff
==============================================================================
--- trunk/mashup/java/xdocs/wsrequesthostobject.html    (original)
+++ trunk/mashup/java/xdocs/wsrequesthostobject.html    Sat Jul 19 11:50:52 2008
@@ -1,383 +1,254 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
 <!--
-  ~ Copyright 2005-2008 WSO2, Inc. (http://wso2.com)
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~ http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-<html>
-<head>
+~ Copyright 2005-2008 WSO2, Inc. (http://wso2.com)
+~
+~ Licensed under the Apache License, Version 2.0 (the "License");
+~ you may not use this file except in compliance with the License.
+~ You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<meta http-equiv="content-type" content=""><title>WSRequest Host Object</title>
 
-    
-  <meta http-equiv="content-type" content="">
-
-
-    
-    
-  <title>WSRequest Host Object</title>
-  <link href="css/mashup-docs.css" rel="stylesheet" type="text/css" 
media="all">
+<link href="css/mashup-docs.css" rel="stylesheet" type="text/css" media="all">
 </head>
 
-
 <body>
 <div id="main-content">
 <h1>WSRequest Host Object</h1>
-
-
 <h3>1.0 Introduction</h3>
-
-
 <p>The WSO2 Mashup Server automatically generates stubs to
-    simplify the consumption of the Web Services it hosts. But if you're
-    consuming a service from somewhere else, we don't yet provide the same 
level
-    of ease. Instead of a stub which hides some of the details of exercising an
-    operation, you must use the WSRequest object directly to formulate the
-    messages.</p>
-
-
-<p>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.</p>
-
-
+simplify the consumption of the Web Services it hosts. But if you're
+consuming a service from somewhere else, we don't yet provide the same
+level of ease. Instead of a stub which hides some of the details of
+exercising an operation, you must use the WSRequest object directly to
+formulate the messages.</p>
+<p>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.</p>
 <h3>1.1 Example</h3>
-
-
 <div class="code">
-    
-<pre>var version = new WSRequest();<br>var options = new 
Array();<br>options.useSOAP = 1.2;<br>options.useWSA = 1.0;<br>options.action = 
"urn:getVersion";<br>request = "&lt;getVersion/&gt;";<br><br>try {<br>        
version.open(options,"http://127.0.0.1:11001/services/version";, false);<br>     
version.send(request);<br>      result = version.responseE4X;<br>} catch (e) 
{<br>      print(e);<br>}</pre>
-
+<pre>function invokeGetVersion(){<br> var version = new WSRequest();<br> var 
options = new Array();<br> options.useSOAP = 1.2;<br> options.useWSA = 1.0;<br> 
options.action = 
"http://services.mashup.wso2.org/version/ServiceInterface/getVersionRequest";;<br>
 var payload = null;<br> try {<br> 
version.open(options,"http://localhost:7762/services/system/version";, 
false);<br> version.send(payload);<br> result = version.responseE4X;<br> } 
catch (e) {<br> system.log(e.toString(),"error");<br> return e.toString(); <br> 
}<br> return result;<br>}</pre>
 </div>
-
-
 <h3>2.0 WSRequest Object</h3>
-
-
-
 <h3>2.1 WSRequest Interface</h3>
-
-
-<p>interface WSRequest
-    <br clear="all">
-
-    {
-    <br clear="all">
-
-    &nbsp;&nbsp;&nbsp; property EventListener onreadystatechange;
-    <br clear="all">
-
-    &nbsp;&nbsp;&nbsp; property unsigned short readyState;
-    <br clear="all">
-
-    &nbsp;&nbsp;&nbsp; void open ( in object options | in String method, in
-    String url [, in boolean async [, in String user [, in String
-    password]]]);
-    <br clear="all">
-
-    &nbsp;&nbsp;&nbsp; void send ( [in Document payload | in XMLString payload 
| in XMLString
-    payload ]);
-    <br clear="all">
-
-    &nbsp;&nbsp;&nbsp; readonly property String responseText;
-    <br clear="all">
-
-    &nbsp;&nbsp;&nbsp; readonly property Document responseXML;<br>
-
-    &nbsp;&nbsp;&nbsp; readonly property XML responseE4X;<br>
-
-    &nbsp;&nbsp;&nbsp; readonly property WebServiceError error;<br>
-
-    }</p>
-
-
+<p>interface WSRequest <br clear="all">
+{ <br clear="all">
+&nbsp;&nbsp;&nbsp; property EventListener
+onreadystatechange; <br clear="all">
+&nbsp;&nbsp;&nbsp; property unsigned short readyState; <br clear="all">
+&nbsp;&nbsp;&nbsp; function void open (&nbsp;object
+options |&nbsp;String httpMethod,&nbsp;String url
+[,&nbsp;boolean async [,&nbsp;String username
+[,&nbsp;String password]]]); <br clear="all">
+&nbsp;&nbsp;&nbsp; function void send (&nbsp;XML
+payload | XMLString payload&nbsp;); &nbsp;// To be used when
+the open method of WSRequest is used &nbsp;<br>&nbsp;
+&nbsp; function void openWSDL ( String wsdlURL, &#65279;boolean async, [Object
+options,[QName serviceName, [String endpointName]]]);<br>&nbsp;&nbsp;&nbsp; 
function void send ( String
+operationName | QName operationName,&nbsp;XML payload | XMLString
+payload&nbsp;); &nbsp;// To be used when the openWSDL method of
+WSRequest is used<br clear="all">
+&nbsp;&nbsp;&nbsp; readonly property String responseText; <br clear="all">
+&nbsp;&nbsp;&nbsp; readonly property Document responseXML;<br>
+&nbsp;&nbsp;&nbsp; readonly property XML responseE4X;<br>
+&nbsp;&nbsp;&nbsp; readonly property WebServiceError error;<br>
+}</p>
 <h3>2.2 API Documentation</h3>
-
-
 <table style="margin-left: 0.5in; border-collapse: collapse;" 
class="MsoTableGrid" border="1" cellpadding="5" cellspacing="0">
-
-    <tbody>
-
-        <tr>
-
-            <td> Member</td>
-
-            <td> Description</td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> open(options, endpointAddress, async)</td>
-
-            <td> This method prepares the WSRequest object to invoke a Web 
service.&nbsp; It accepts
-                the following parameters: <br clear="all">
-
-                
-      <ul>
-
-                    <li><em>options (array)</em>: an array of options for
-                        formulating the message.&nbsp; These options 
correspond to the message
-                        framing required by the service as documented in the 
service's WSDL
-                        and/or documentation.&nbsp; A list of the supported 
options is at
-                        WSRequest Options. <br clear="all">
-        </li>
-
-                    <li><em>endpointAddress</em> (string): a URL representing 
where to send the
-                        message. <br clear="all">
-        </li>
-
-                    <li><em>async</em> (boolean): a boolean flag representing 
whether the operation
-                        should be invoked asynchrounously or not. <br 
clear="all">
-
-                        The open() function throws an exception if the 
WSRequest object cannot
-                        accommodate the request (e.g., the options are 
malformed.)
-                    </li>
-
-                
-      </ul>
-
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> send(payload)</td>
-
-            <td> This method invokes the Web service with the requested 
payload. <br clear="all">
-
-                
-      <ul>
-
-                    <li><em>payload</em>: an XML object or a string containing 
the XML source for
-                        the request.
-                    </li>
-
-                
-      </ul>
-
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> onreadystatechange</td>
-
-            <td> 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).
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> readyState</td>
-
-            <td> The current state of the object, which can be one of the 
following values: <br clear="all">
-
-                
-      <ul>
-
-                    <li>0: The object has not been initialized by calling the 
open() method. <br clear="all">
-        </li>
-
-                    <li>1: The object has been initialized successfully, but 
the send() method has
-                        not been called. <br clear="all">
-        </li>
-
-                    <li>2: The request is pending <br clear="all">
-        </li>
-
-                    <li>3: The request is partially complete (some data has 
been received, and may
-                        be available in the responseText property. <br 
clear="all">
-        </li>
-
-                    <li>4: The request is complete, all data has been 
received. <br clear="all">
-
-                        Of these, typically only the last (readyState == 4) is 
used.
-                    </li>
-
-                
-      </ul>
-
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> responseXML</td>
-
-            <td> 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)
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> responseE4X</td>
-
-            <td> The parsed E4X XML message representing the response from the 
service.</td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> responseText</td>
-
-            <td> The raw text representing the XML (or
-                non-XML) response.&nbsp; If the responseXML property is empty, 
you can
-                check the responseText property to see if a non-XML response 
was
-                received.
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> error</td>
-
-            <td> 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
-            </td>
-
-
-        </tr>
-
-    
-  </tbody>
-</table>
-
-
-<h3>3.0 Options</h3>
-
-
-<table class="MsoTableGrid" style="margin-left: 0.5in; border-collapse: 
collapse;" border="1" cellpadding="5" cellspacing="0">
-
-    <tbody>
-
-        <tr>
-
-            <td> Option</td>
-
-            <td> Range of values</td>
-
-            <td> Description</td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> useSOAP</td>
-
-            <td><b>"1.2"</b>, 1.2, "1.1", 1.1, true, false</td>
-
-            <td> 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, and the WSDL 2.0 
HTTP binding.
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> useWSA</td>
-
-            <td> TRUE | FALSE | 1.0 | <b>"1.0"</b> | "submission"</td>
-
-            <td> 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.
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> action</td>
-
-            <td> xs:anyURI</td>
-
-            <td> 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.
-            </td>
-
-
-        </tr>
-
-        <tr>
-
-            <td> HTTPMethod</td>
-
-            <td> xs:string | "POST"</td>
-
-            <td> The HTTP method to use to formulate the request.</td>
-
-
-        </tr>
-
-    
-  </tbody>
+<tbody>
+<tr>
+<td> Member</td>
+<td> Description</td>
+</tr>
+<tr>
+<td><span style="font-weight: bold;">function
+void open (&nbsp;object options |&nbsp;String
+httpMethod,&nbsp;String url [,&nbsp;boolean async
+[,&nbsp;String username [,&nbsp;String password]]])</span>
+</td>
+<td> This method prepares the WSRequest object to invoke a
+Web service.&nbsp; It accepts the following parameters: <br clear="all">
+<ul>
+<li><em>options (array)</em>: an array of
+options for formulating the message.&nbsp; These options correspond
+to the message framing required by the service as documented in the
+service's WSDL and/or documentation.&nbsp;&nbsp;</li></ul><div 
style="margin-left: 40px;">The following is a list of supported 
options</div><ul><ul><li>useSOAP - Specify the SOAP version to be used or 
weather not to use SOAP. Supported values are "1.1" | "1.2" | 
"false"</li><li>HTTPMethod - The HTTP method to be used. Supported values are 
"GET" | "POST" | "PUT" | "DELETE"</li><li>useWSA - Weather WS-Addressing needs 
to be used. Supported
+values are "1.0" | "submission" | "true". If the version of
+WS-Addressing is specified and useWSA is set to true the "1.0" version
+is used.</li></ul></ul><div style="margin-left: 80px;">When WS-Addressing is 
been used the following options will also be 
processed</div><ul><ul><ul><li>action - Will be used as the wsa:to value. Can 
be used to specify to address that the message will be sent to.</li><li>from 
&nbsp;-&nbsp; Will be used as the wsa:from value. Can be used to specify the 
address&nbsp;the request was sent from.</li><li>replyTo&nbsp;&nbsp;-&nbsp;
+Will be used as the wsa:replyTo value. Can be used to specify the
+address&nbsp;the response should be sent 
to.</li><li>faultTo&nbsp;&nbsp;-&nbsp; Will be used as the wsa:faultTo value. 
Can be used to specify the address a fault should be sent 
to.</li></ul><li>action - If useWSA is false will be used as the 
SOAPAction.</li><li>useWSS
+- Used to specify weather WS-Security needs to be used. Currently if
+useWSS is set to true it assumes that the service is secured using
+Username Token over HTTPS.</li><li>username - If the useWSS option is set to 
true the username will be used
+to invoke the destination service using Username Token (using
+WS-Security) otherwise it will be used to invoke the service with HTTP
+Basic Authentication enabled.&nbsp;</li><li>passowrd - If the useWSS option is 
set
+to true the password will be used to invoke the destination service
+using Username Token (using WS-Security) otherwise it will be used to
+invoke the service with HTTP Basic Authentication
+enabled.&nbsp;&nbsp;</li><li>HTTPLocation - Used to specify the URL pattern of 
the operation been invoked. Refer http://wso2.org/library/3715 for 
details.</li><li>HTTPLocationIgnoreUncited - Specifies weather parameters not 
cited in the HTTPLocation should be 
ignored.</li><li>HTTPQueryParameterSeparator - Specifies the query parameter 
seperator to be used. Defaults to &amp;.</li><li>HTTPInputSerialization
+- Specifies the message format of the request. The Mashup Server can be
+extended to support custom serialization. The following are supported
+by this distribution. application/x-www-form-urlencoded,
+multipart/form-data, application/json, application/json/badgerfish,
+application/soap+xml, text/xml, application/xml</li><li>HTTPContentEncoding - 
Used to speficy the content-encoding of the request. Supported values are 
"gzip" | "compress"</li></ul>
+<li><em>httpMethod </em>(string): the
+httpMethod to be used when the operation is invoked. </li>
+<li><em>url </em>(string): a URL
+representing where to send the message. <br clear="all">
+</li>
+<li><em>async</em> (boolean): a boolean flag
+representing whether the operation should be invoked asynchrounously or
+not. Defaults to true.</li>
+<li><em>username </em>(string): The
+username. If the useWSS option is set to true the username will be used
+to invoke the destination service using Username Token (using
+WS-Security) otherwise it will be used to invoke the service with HTTP
+Basic Authentication enabled.&nbsp;</li>
+<li><em>password </em>(string): The
+password. If the useWSS option is set
+to true the password will be used to invoke the destination service
+using Username Token (using WS-Security) otherwise it will be used to
+invoke the service with HTTP Basic Authentication
+enabled.&nbsp;&nbsp;<br clear="all">
+<br>
+The open() function throws an exception if the WSRequest object cannot
+accommodate the request (e.g., the options are malformed.)</li></ul>To be 
specific here are the various ways which the open fucntion can be
+used in<br><ul><li>
+open(httpMethod, url, async);</li><li>open(options, url, 
async);</li><li>open(httpMethod, url, username);</li><li>open(options, url, 
username);</li><li>open(httpMethod, url, username, 
password);</li><li>open(options, url, username, 
password);</li><li>open(httpMethod, url, async, 
username);</li><li>open(options, url, async, username);
+</li></ul></td>
+</tr>
+<tr>
+<td style="font-weight: bold;">function void send (&nbsp;XML
+payload | XMLString payload&nbsp;)</td>
+<td> This method invokes the Web service with the requested
+payload. To be used when the WSRequest object was configured using the open 
method.<br clear="all">
+<ul>
+<li><em>payload</em>: an XML object or a
+string containing the XML source for the request. </li>
+</ul>
+</td>
+</tr>
+<tr><td style="font-weight: bold;">function void openWSDL ( String wsdlURL, 
&#65279;boolean async, [Object options,[QName serviceName, [String 
endpointName]]])</td><td>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.
+<br><ol><li>The user does not need to know how to frame the request.
+i.e. Whcih SOAP version to use? What should be the request be sent to?
+How do I configure WS-Security? and so on</li><li>Can be used to invoke 
services that are secured using WS-Security</li></ol>This method acceps the 
following parameters<br><ul><li><span style="font-style: 
italic;">wsdlURL</span> (string) - The url at which the WSDL is available at. 
Currently supports WSDL 1.1</li><li><em>async</em> (boolean): A boolean flag
+representing whether the operation should be invoked asynchrounously or
+not.</li><li><em>options (array)</em>: An array of
+options needed to parse in information to invoke secured 
services.</li></ul><div style="margin-left: 40px;">The following is a list of 
supported options<br></div><ul><ul><li>username
+- Used to specify the username if the service needs a
+username&nbsp;token to carry out any WS-Security related
+operations.&nbsp;</li><li>passowrd -&nbsp;Used to specify the passowrd if the 
service needs a password token to carry out any WS-Security related 
operations.&nbsp;</li><li>encryptionUser
+- Used to specify the alias of the certificate to use in Encryption if
+the service needs the request to be encrypted.</li></ul><li><span 
style="font-style: italic;">serviceName (QName)</span>
+- The QName of the service to be invoked. Could be usefull if the WSDL
+has multiple services. If not specified the ffirst service in the WSDL
+is used.</li><li><span style="font-style: italic;">endpointName (String)</span>
+- The name of the endpoint to use wehn invoking the service. Could be
+usefull if the service has multiple endpoints and you prefer to use a
+particular one. If not specified the first SOAP endpoint is 
used.</li></ul></td></tr><tr><td style="font-weight: bold;">function void send 
( String
+operationName | QName operationName,&nbsp;XML payload | XMLString
+payload&nbsp;)</td><td> 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.<br clear="all">
+<ul><li><span style="font-style: italic;">operationName (String</span>) - The 
name of the operation to be invoked<em></em></li><li><em>payload</em> : an XML 
object or a
+string containing the XML source for the request. </li></ul></td></tr><tr>
+<td style="font-weight: bold;">property EventListener
+&nbsp; onreadystatechange</td>
+<td> 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). </td>
+</tr>
+<tr>
+<td style="font-weight: bold;">property unsigned short  readyState</td>
+<td> The current state of the object, which can be one of
+the following values: <br clear="all">
+<ul>
+<li>0: The object has not been initialized by calling the
+open() method. <br clear="all">
+</li>
+<li>1: The object has been initialized successfully, but
+the send() method has not been called. <br clear="all">
+</li>
+<li>2: The request is pending <br clear="all">
+</li>
+<li>3: The request is partially complete (some data has
+been received, and may be available in the responseText property. <br 
clear="all">
+</li>
+<li>4: The request is complete, all data has been
+received. <br clear="all">
+Of these, typically only the last (readyState == 4) is used. </li>
+</ul>
+</td>
+</tr>
+<tr>
+<td style="font-weight: bold;">readonly property Document  responseXML</td>
+<td> 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) </td>
+</tr>
+<tr>
+<td style="font-weight: bold;"> readonly property XML responseE4X</td>
+<td> The parsed E4X XML message representing the response
+from the service.</td>
+</tr>
+<tr>
+<td style="font-weight: bold;">readonly property String responseText</td>
+<td> The raw text representing the XML (or non-XML)
+response.&nbsp; If the responseXML property is empty, you can check
+the responseText property to see if a non-XML response was received. </td>
+</tr>
+<tr>
+<td style="font-weight: bold;">readonly property WebServiceError error</td>
+<td> 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 </td>
+</tr>
+</tbody>
 </table>
-
-<p>See <a 
href="http://www.wso2.org/wiki/display/mashup/Ideas+for+evolving+WSRequest"; 
title="Ideas for evolving WSRequest">Ideas for evolving WSRequest</a> for 
additional
-    options under development.</p>
-
-
+<h3>3.0 Example Usage<br></h3><h3>2.1 Calling Services in a asynchronous 
manner</h3>Its
+important to note that when a service is called in the manner below
+(assynchronously) the thread will return to the caller immidiatly (Even
+before the result of the web service invocation is received).
+<div class="code">
+<pre>// Demonstrates calling the getVersion operation of the version service 
in a asynchronous manner using the open method<br>function 
invokeGetVersionAsync(){<br>    var version = new WSRequest();<br>    
version.onreadystatechange = function() {<br>                                   
         handleResponse(version);<br>                                        
};<br>    var options = new Array();<br>    options.useSOAP = 1.2;<br>    
options.useWSA = 1.0;<br>    options.action = 
"http://services.mashup.wso2.org/version/ServiceInterface/getVersionRequest";;<br>
    var payload = null;<br>    try {<br>        
version.open(options,"http://localhost:7762/services/system/version";, 
true);<br>        version.send();<br>    } catch (e) {<br>        
system.log(e.toString(),"error");<br>        return e.toString();        <br>   
 }<br>    return "Invoked getVersion in a asynchronous 
manner";<br>}<br><br>handleResponse.visible=false;<br>function 
handleResponse(version){<br> if (version.readyState == 4) {<br>              
system.log(version.responseText);<br>   }<br>}</pre>
+</div>
+<h3></h3>
+<div class="code">
+<pre>// Demonstrates calling the getVersion operation of the version service 
in a asynchronous manner using the openWSDL method<br>function 
invokeGetVersionAsync(){<br>    var request = new WSRequest();<br>    
request.onreadystatechange = function() {<br>                                   
             handleResponse(request);<br>                                       
 };<br>    
request.openWSDL("http://localhost:7762/services/system/version?wsdl",true);<br>
    request.send("getVersion",null);<br>    return "Invoked getVersion in a 
asynchronous manner";<br>}<br><br>handleResponse.visible=false;<br>function 
handleResponse(version){<br>      if (version.readyState == 4) {<br>            
  system.log(version.responseText);<br>   }<br>}</pre>
+</div>
+<h3>2.1 Calling Services which are secured using WS-Security</h3>Calling
+secured services using the WSO2 Mashup Server is simple. The client
+given below can handle sevaral security scenarios provided that the
+proper certificate provisioning has taken place.
+<div class="code">
+<pre>// Demonstrates calling the getVersion operation of the version service. 
This client will work for most WS-Security scenarios (Works for all the 
scenarios the Mashup Server ships)<br>function invokeGetVersion(){<br>    var 
request = new WSRequest();<br>    var options = new Array();<br>    
options["username"] = "keith"; // Will be used if the service policy needed a 
Username Token. Assuming that access has been grated to keith<br>    
options["password"] = "keith"; // Will be used if the service policy needed a 
Username Token. Assuming that access has been grated to keith<br>   
&nbsp;options["encryptionUser"] = "versionCert"; // The alias of the 
certificate that will be used to encrypt the request. <br>                      
                    // This is the public certificate of the Keystore that the 
version service is secured with.<br>                                         // 
If the security policy of the version service needs the request signed the 
client will do so. <br>                                               // But 
the keystore of the version service needs to have keith's (The clients) public 
certificate <br>    var service = new 
QName("http://services.mashup.wso2.org/version","version";);<br>    
request.openWSDL("http://localhost:7762/services/system/version?wsdl",true, 
options,service,"SecureSOAP11Endpoint");<br>    
request.send("getVersion",null);<br>    return request.responseXML;<br>}</pre>
+</div>
+<h3></h3>See <a 
href="http://www.wso2.org/wiki/display/mashup/Ideas+for+evolving+WSRequest"; 
title="Ideas for evolving WSRequest">Ideas for evolving
+WSRequest</a> for additional options under development.
 <h3>4.0 References</h3>
-
-
 <ul>
-
-    <li><a href="http://www.wso2.org/wiki/display/mashup/WebServiceError"; 
title="WebServiceError">WebServiceError</a>
-    </li>
-
-    <li><span class="nobr"><a 
href="http://www.wso2.org/wiki/pages/createpage.action?spaceKey=mashup&amp;title=wsrequest_specification&amp;linkCreation=true&amp;fromPageId=888";
 title="Create Page: wsrequest_specification" 
class="createlink">wsrequest_specification</a></span></li>
-
-    <li><a 
href="apidocs/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.html">JavaDoc
 for
-        the WSRequest host Object</a></li>
-
-    <li><a 
href="apidocs/org/wso2/mashup/hostobjects/wsrequest/WSRequestCallBack.html">JavaDoc
 for
-        the WSRequestCallBack host Object</a></li>
-
-    <li><a 
href="apidocs/org/wso2/mashup/hostobjects/wsrequest/WebServiceErrorHostObject.html">JavaDoc
-        for the WebServiceErrorHostObject host Object</a></li>
-
+<li><a href="http://www.wso2.org/wiki/display/mashup/WebServiceError"; 
title="WebServiceError">WebServiceError</a> </li>
+<li><span class="nobr"><a 
href="http://www.wso2.org/wiki/pages/createpage.action?spaceKey=mashup&amp;title=wsrequest_specification&amp;linkCreation=true&amp;fromPageId=888";
 title="Create Page: wsrequest_specification" 
class="createlink">wsrequest_specification</a></span></li>
+<li><a 
href="apidocs/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.html">JavaDoc
+for the WSRequest host Object</a></li>
+<li><a 
href="apidocs/org/wso2/mashup/hostobjects/wsrequest/WSRequestCallBack.html">JavaDoc
+for the WSRequestCallBack host Object</a></li>
+<li><a 
href="apidocs/org/wso2/mashup/hostobjects/wsrequest/WebServiceErrorHostObject.html">JavaDoc
+for the WebServiceErrorHostObject host Object</a></li>
 </ul>
-
 </div>
-
-<p>� WSO2 Inc.</p>
-
-</body>
-</html>
+<p>� 2007-2008 WSO2 Inc.</p>
+</body></html>
\ No newline at end of file

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to