Author: keith Date: Tue Jul 29 01:13:28 2008 New Revision: 20079 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=20079
Log: Fixing Mashup-1028 Modified: branches/mashup/java/1.5/java/xdocs/sessionhostobject.html branches/mashup/java/1.5/java/xdocs/wsrequesthostobject.html Modified: branches/mashup/java/1.5/java/xdocs/sessionhostobject.html URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/xdocs/sessionhostobject.html?rev=20079&r1=20078&r2=20079&view=diff ============================================================================== --- branches/mashup/java/1.5/java/xdocs/sessionhostobject.html (original) +++ branches/mashup/java/1.5/java/xdocs/sessionhostobject.html Tue Jul 29 01:13:28 2008 @@ -1,6 +1,5 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html><head> -<!-- +<html><head><!-- ~ Copyright 2005-2008 WSO2, Inc. (http://wso2.com) ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,11 +14,10 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -<meta http-equiv="content-type" content=""><title>Session Host Object</title> -<link href="css/mashup-docs.css" rel="stylesheet" type="text/css" media="all"> -</head> +<meta http-equiv="content-type" content=""><title>Session Host Object</title> +<link href="css/mashup-docs.css" rel="stylesheet" type="text/css" media="all"></head> <body> <div id="main-content"> <h1>Session Host Object</h1> @@ -29,7 +27,7 @@ object is global and thus does not need to be instantiated explicitly.</p> <h3>1.1 Example</h3> <div class="code"> -<pre>this.serviceName = "ApplicationScopeService";<br>this.scope="application";<br>var key = "number";<br>function putValue(param){<br> session.put(key,2);<br> return <success/>;<br>}<br><br>function getValue(param){<br> number = session.get(key);<br> return <number>{number}</number>;<br>}<br><br>function removeValue(param){<br> number = session.remove(key);<br> return <success/>;<br>}<br><br>function clearSession(param){<br> session.clear();<br> return <success/>;<br>}</pre> +<pre>this.serviceName = "ApplicationScopeService";<br>this.scope="application";<br>var key = "number";<br>function putValue(param){<br> session.put(key,2);<br> return <success/>;<br>}<br><br>function getValue(param){<br> var number = session.get(key);<br> return <number>{number}</number>;<br>}<br><br>function removeValue(param){<br> session.remove(key);<br> return <success/>;<br>}<br><br>function clearSession(param){<br> session.clear();<br> return <success/>;<br>}</pre> </div> <p></p> <h2>2.0 Session Object</h2> @@ -134,5 +132,5 @@ for the session host Object</a></li> </ul> </div> -<p>© 2007-2008 WSO2 Inc.</p> +<p>� 2007-2008 WSO2 Inc.</p> </body></html> \ No newline at end of file Modified: branches/mashup/java/1.5/java/xdocs/wsrequesthostobject.html URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/xdocs/wsrequesthostobject.html?rev=20079&r1=20078&r2=20079&view=diff ============================================================================== --- branches/mashup/java/1.5/java/xdocs/wsrequesthostobject.html (original) +++ branches/mashup/java/1.5/java/xdocs/wsrequesthostobject.html Tue Jul 29 01:13:28 2008 @@ -1,5 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html><head><!-- +<html><head> +<!-- ~ Copyright 2005-2008 WSO2, Inc. (http://wso2.com) ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +15,10 @@ ~ 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> -<link href="css/mashup-docs.css" rel="stylesheet" type="text/css" media="all"></head> +<link href="css/mashup-docs.css" rel="stylesheet" type="text/css" media="all"> +</head> <body> <div id="main-content"> <h1>WSRequest Host Object</h1> @@ -35,7 +36,7 @@ information from the result.</p> <h3>1.1 Example</h3> <div class="code"> -<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> +<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> var result;<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> <p></p> <h2>2.0 WSRequest Object</h2> @@ -51,9 +52,12 @@ [, String password]]]); <br clear="all"> function void send ( XML payload | XMLString payload ); // To be used when -the open method of WSRequest is used <br> - function void openWSDL ( String wsdlURL, boolean async, [Object -options,[QName serviceName, [String endpointName]]]);<br> function void send ( String +the open method of WSRequest is used <br> + + function void openWSDL ( String wsdlURL, boolean async, +[Object +options,[QName serviceName, [String endpointName]]]);<br> + function void send ( String operationName | QName operationName, XML payload | XMLString payload ); // To be used when the openWSDL method of WSRequest is used<br clear="all"> @@ -81,27 +85,73 @@ <li><em>options (array)</em>: 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. </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 +service's WSDL and/or documentation. </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 - Will be used as the wsa:from value. Can be used to specify the address the request was sent from.</li><li>replyTo - +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 - Will be used as the +wsa:from value. Can be used to specify the address the request +was sent from.</li> +<li>replyTo - Will be used as the wsa:replyTo value. Can be used to specify the -address the response should be sent to.</li><li>faultTo - 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 +address the response should be sent to.</li> +<li>faultTo - 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 +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. </li><li>password - If the useWSS option is set +Basic Authentication enabled. </li> +<li>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. </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 &.</li><li>HTTPInputSerialization +enabled. </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 &.</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> +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 @@ -123,57 +173,120 @@ enabled. <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> +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 ( XML +<td style="font-weight: bold;">function void send +( XML payload | XMLString payload )</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"> +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, boolean async, [Object options,[QName serviceName, [String endpointName]]])</td><td>This +<tr> +<td style="font-weight: bold;">function void +openWSDL ( String wsdlURL, 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. +<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 +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 +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 token to carry out any WS-Security related -operations. </li><li>password +operations. </li> +<li>password - Used to specify the password if the service needs a password -token to carry out any WS-Security related operations. </li><li>encryptionUser +token to carry out any WS-Security related operations. </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 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> +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 +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, XML payload | XMLString -payload )</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 +payload )</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 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 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> @@ -195,24 +308,28 @@ </td> </tr> <tr> -<td style="font-weight: bold;">readonly property Document responseXML</td> +<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 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 style="font-weight: bold;">readonly property +String responseText</td> <td> 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. </td> </tr> <tr> -<td style="font-weight: bold;">readonly property WebServiceError error</td> +<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> @@ -221,22 +338,25 @@ </table> <p></p> <h2>3.0 Example Usage</h2> -<h3>2.1 Calling Services in a asynchronous manner</h3>Its +<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(payload);<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> +<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> var result; <br> try {<br> version.open(options,"http://localhost:7762/services/system/version", true);<br> version.send(payload);<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> +<br> <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> +<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 +<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 <br>// 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";<br> // Will be used if the service policy requires a Username Token. Assuming that access has been granted to keith<br> options["password"] = "keith";<br> // Will be used if the service policy requires a Username Token. Assuming that access has been granted to keith<br> options["encryptionUser"] = "versionCert";<br> // 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> +<pre>// Demonstrates calling the getVersion operation of the version service. This client will work for most <br>// 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";<br> // Will be used if the service policy requires a Username Token. Assuming that access has been granted to keith<br> options["password"] = "keith";<br> // Will be used if the service policy requires a Username Token. Assuming that access has been granted to keith<br> options["encryptionUser"] = "versionCert";<br> // 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> 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.
_______________________________________________ Mashup-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
