Author: keith
Date: Mon Jan 7 08:29:17 2008
New Revision: 11971
Log:
Updating storexml stub here
Modified:
trunk/mashup/java/modules/samples/digit2image/digit2image.resources/storexml.stub.js
Modified:
trunk/mashup/java/modules/samples/digit2image/digit2image.resources/storexml.stub.js
==============================================================================
---
trunk/mashup/java/modules/samples/digit2image/digit2image.resources/storexml.stub.js
(original)
+++
trunk/mashup/java/modules/samples/digit2image/digit2image.resources/storexml.stub.js
Mon Jan 7 08:29:17 2008
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+
// Example stubs for storexml operations. This function is not intended
// to be called, but rather as a source for copy-and-paste development.
@@ -43,21 +44,21 @@
}
stubs.visible = false;
-var storexml = new WebService("SOAP12Endpoint");
+var storexml = new WebService("storexmlSOAP12Endpoint");
storexml.store =
function store(/* string */ _name, /* anyType */ _value)
{
var isAsync, request, response, resultValue;
-
+
this._options = new Array();
isAsync = (this.store.callback != null && typeof(this.store.callback)
== 'function');
- request =
+ request =
'<p:store xmlns:p="http://services.mashup.wso2.org/storexml?xsd">'
+
(_name == null ? '' : '<name>' + this._encodeXML(_name) +
'</name>') +
(_value == null ? '' : '<value>' + _value + '</value>') +
'</p:store>' ;
-
+
if (isAsync) {
try {
this._call(
@@ -71,7 +72,7 @@
if (response == null) {
resultValue = null;
} else {
- resultValue = /* xs:anyType */
response["return"].*;
+ resultValue = /* xs:anyType */
convertJSType(response.documentElement.firstChild, true);
}
callbacks[0](resultValue);
}
@@ -91,9 +92,9 @@
}
} else {
try {
- response = this._call("store", request);
- resultValue = /* xs:anyType */
response["return"].*;
- return resultValue;
+ response = this._call("store", request);
+ resultValue = /* xs:anyType */
convertJSType(response.documentElement.firstChild, true);
+ return resultValue;
} catch (e) {
if (typeof(e) == "string") throw(e);
if (e.message) throw(e.message);
@@ -108,14 +109,14 @@
function retrieve(/* string */ _name)
{
var isAsync, request, response, resultValue;
-
+
this._options = new Array();
isAsync = (this.retrieve.callback != null &&
typeof(this.retrieve.callback) == 'function');
- request =
+ request =
'<p:retrieve
xmlns:p="http://services.mashup.wso2.org/storexml?xsd">' +
(_name == null ? '' : '<name>' + this._encodeXML(_name) +
'</name>') +
'</p:retrieve>' ;
-
+
if (isAsync) {
try {
this._call(
@@ -129,7 +130,7 @@
if (response == null) {
resultValue = null;
} else {
- resultValue = /* xs:anyType */
response["return"].*;
+ resultValue = /* xs:anyType */
convertJSType(response.documentElement.firstChild, true);
}
callbacks[0](resultValue);
}
@@ -149,9 +150,9 @@
}
} else {
try {
- response = this._call("retrieve", request);
- resultValue = /* xs:anyType */
response["return"].*;
- return resultValue;
+ response = this._call("retrieve", request);
+ resultValue = /* xs:anyType */
convertJSType(response.documentElement.firstChild, true);
+ return resultValue;
} catch (e) {
if (typeof(e) == "string") throw(e);
if (e.message) throw(e.message);
@@ -166,14 +167,14 @@
function remove(/* string */ _name)
{
var isAsync, request, response, resultValue;
-
+
this._options = new Array();
isAsync = (this.remove.callback != null &&
typeof(this.remove.callback) == 'function');
- request =
+ request =
'<p:remove
xmlns:p="http://services.mashup.wso2.org/storexml?xsd">' +
(_name == null ? '' : '<name>' + this._encodeXML(_name) +
'</name>') +
'</p:remove>' ;
-
+
if (isAsync) {
try {
this._call(
@@ -187,7 +188,7 @@
if (response == null) {
resultValue = null;
} else {
- resultValue = /* xs:anyType */
response["return"].*;
+ resultValue = /* xs:anyType */
convertJSType(response.documentElement.firstChild, true);
}
callbacks[0](resultValue);
}
@@ -207,9 +208,9 @@
}
} else {
try {
- response = this._call("remove", request);
- resultValue = /* xs:anyType */
response["return"].*;
- return resultValue;
+ response = this._call("remove", request);
+ resultValue = /* xs:anyType */
convertJSType(response.documentElement.firstChild, true);
+ return resultValue;
} catch (e) {
if (typeof(e) == "string") throw(e);
if (e.message) throw(e.message);
@@ -227,13 +228,13 @@
{
this.readyState = 0;
this.onreadystatechange = null;
-
+
//public accessors for manually intervening in setting the address (e.g.
supporting tcpmon)
this.getAddress = function (endpointName)
{
return this._endpointDetails[endpointName].address;
}
-
+
this.setAddress = function (endpointName, address)
{
this._endpointDetails[endpointName].address = address;
@@ -259,12 +260,12 @@
}
return wsrequest;
}
-
- this._endpointDetails =
+
+ this._endpointDetails =
{
- "SOAP12Endpoint": {
+ "storexmlSOAP12Endpoint": {
"type" : "SOAP12",
- "address" : "http://localhost:7762/services/storexml",
+ "address" :
"http://192.168.253.128:7762/services/system/storexml",
"action" : {
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
@@ -274,11 +275,16 @@
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
"remove" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/removeRequest"
+ },
+ "httplocation" : {
+ "store" : "storexml/store",
+ "retrieve" : "storexml/retrieve",
+ "remove" : "storexml/remove"
}
},
- "SecureSOAP12Endpoint": {
+ "SecureStorexmlSOAP12Endpoint": {
"type" : "SOAP12",
- "address" : "https://localhost:7443/services/storexml",
+ "address" :
"https://192.168.253.128:7443/services/system/storexml",
"action" : {
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
@@ -288,11 +294,16 @@
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
"remove" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/removeRequest"
+ },
+ "httplocation" : {
+ "store" : "storexml/store",
+ "retrieve" : "storexml/retrieve",
+ "remove" : "storexml/remove"
}
},
- "SOAP11Endpoint": {
+ "storexmlSOAP11Endpoint": {
"type" : "SOAP11",
- "address" : "http://localhost:7762/services/storexml",
+ "address" :
"http://192.168.253.128:7762/services/system/storexml",
"action" : {
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
@@ -302,11 +313,16 @@
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
"remove" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/removeRequest"
+ },
+ "httplocation" : {
+ "store" : "storexml/store",
+ "retrieve" : "storexml/retrieve",
+ "remove" : "storexml/remove"
}
},
- "SecureSOAP11Endpoint": {
+ "SecureStorexmlSOAP11Endpoint": {
"type" : "SOAP11",
- "address" : "https://localhost:7443/services/storexml",
+ "address" :
"https://192.168.253.128:7443/services/system/storexml",
"action" : {
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
@@ -316,41 +332,47 @@
"store" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/storeRequest",
"retrieve" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/retrieveRequest",
"remove" :
"http://services.mashup.wso2.org/storexml/ServiceInterface/removeRequest"
+ },
+ "httplocation" : {
+ "store" : "storexml/store",
+ "retrieve" : "storexml/retrieve",
+ "remove" : "storexml/remove"
}
},
- "HTTPEndpoint": {
+ "storexmlHTTPEndpoint": {
"type" : "HTTP",
- "address" : "http://localhost:7762/services/storexml",
+ "address" :
"http://192.168.253.128:7762/services/system/storexml",
"httplocation" : {
"store" : "storexml/store",
"retrieve" : "storexml/retrieve",
"remove" : "storexml/remove"
},
"httpmethod" : {
- "store" : null,
+ "store" : "POST",
"retrieve" : "GET",
- "remove" : null
+ "remove" : "POST"
}
},
- "SecureHTTPEndpoint": {
+ "SecureStorexmlHTTPEndpoint": {
"type" : "HTTP",
- "address" : "https://localhost:7443/services/storexml",
+ "address" :
"https://192.168.253.128:7443/services/system/storexml",
"httplocation" : {
"store" : "storexml/store",
"retrieve" : "storexml/retrieve",
"remove" : "storexml/remove"
},
"httpmethod" : {
- "store" : null,
+ "store" : "POST",
"retrieve" : "GET",
- "remove" : null
+ "remove" : "POST"
}
}
};
this.endpoint = endpointName;
- this._encodeXML = function (str) {
+ this._encodeXML = function (value) {
var re;
+ var str = value.toString();
re = /&/g;
str = str.replace(re, "&");
re = /</g;
@@ -375,25 +397,25 @@
this._options.useWSA = false;
this._options.action = undefined;
}
-
+
if (details["httpmethod"] != null) {
this._options.HTTPMethod = details.httpmethod[opName];
} else {
this._options.HTTPMethod = null;
}
-
+
if (details["httpinputSerialization"] != null) {
this._options.HTTPInputSerialization =
details.httpinputSerialization[opName];
} else {
this._options.HTTPInputSerialization= null;
}
-
+
if (details["httplocation"] != null) {
this._options.HTTPLocation = details.httplocation[opName];
} else {
this._options.HTTPLocation = null;
}
-
+
if (details["httpignoreUncited"] != null) {
this._options.HTTPLocationIgnoreUncited =
details.httpignoreUncited[opName];
} else {
@@ -405,13 +427,13 @@
} else {
this._options.HTTPQueryParameterSeparator = null;
}
-
+
var isAsync = (typeof(callback) == 'function');
-
+
var thisRequest = this._getWSRequest();
if (isAsync) {
thisRequest._userdata = userdata;
- thisRequest.onreadystatechange =
+ thisRequest.onreadystatechange =
function() {
if (thisRequest.readyState == 4) {
callback(thisRequest, userdata);
@@ -425,7 +447,7 @@
} else {
try {
var resultContent = thisRequest.responseText;
- if (resultContent == "") {
+ if (resultContent == "") {
throw new WebServiceError("No response",
"WebService._call() did not recieve a response to a synchronous request.");
}
var resultXML = thisRequest.responseXML;
@@ -434,7 +456,185 @@
}
return resultXML;
}
- }
+ }
}
WebService.visible = false;
-
+
+// library function for dynamically converting an element with js:type
annotation to a Javascript type.
+convertJSType.visible = false;
+function convertJSType(element, isWrapped) {
+ if (element == null) return "";
+ var extractedValue = WSRequest.util._stringValue(element);
+ var resultValue, i;
+ var type = element.getAttribute("js:type");
+ if (type == null) {
+ type = "xml";
+ } else {
+ type = type.toString();
+ }
+ switch (type) {
+ case "string":
+ return extractedValue;
+ break;
+ case "number":
+ return parseFloat(extractedValue);
+ break;
+ case "boolean":
+ return extractedValue == "true" || extractedValue == "1";
+ break;
+ case "date":
+ return xs_dateTime_to_date(extractedValue);
+ break;
+ case "array":
+ resultValue = new Array();
+ for (i=0; i<element.childNodes.length; i++) {
+ resultValue =
resultValue.concat(convertJSType(element.childNodes[i]));
+ }
+ return(resultValue);
+ break;
+ case "object":
+ resultValue = new Object();
+ for (i=0; i<element.childNodes.length; i++) {
+ resultValue[element.childNodes[i].tagName] =
convertJSType(element.childNodes[i]);
+ }
+ return(resultValue);
+ break;
+ case "xmllist":
+ return element.childNodes;
+ break;
+ case "xml":
+ default:
+ if (isWrapped == true)
+ return element.firstChild;
+ else return element;
+ break;
+ }
+}
+
+// library function for parsing xs:date, xs:time, and xs:dateTime types into
Date objects.
+function xs_dateTime_to_date(dateTime)
+{
+ var buffer = dateTime;
+ var p = 0; // pointer to current parse location in buffer.
+
+ var era, year, month, day, hour, minute, second, millisecond;
+
+ // parse date, if there is one.
+ if (buffer.substr(p,1) == '-')
+ {
+ era = -1;
+ p++;
+ } else {
+ era = 1;
+ }
+
+ if (buffer.charAt(p+2) != ':')
+ {
+ year = era * buffer.substr(p,4);
+ p += 5;
+ month = buffer.substr(p,2);
+ p += 3;
+ day = buffer.substr(p,2);
+ p += 3;
+ } else {
+ year = 1970;
+ month = 1;
+ day = 1;
+ }
+
+ // parse time, if there is one
+ if (buffer.charAt(p) != '+' && buffer.charAt(p) != '-')
+ {
+ hour = buffer.substr(p,2);
+ p += 3;
+ minute = buffer.substr(p,2);
+ p += 3;
+ second = buffer.substr(p,2);
+ p += 2;
+ if (buffer.charAt(p) == '.')
+ {
+ millisecond = parseFloat(buffer.substr(p))*1000;
+ // Note that JS fractional seconds are significant to 3 places -
xs:time is significant to more -
+ // though implementations are only required to carry 3 places.
+ p++;
+ while (buffer.charCodeAt(p) >= 48 && buffer.charCodeAt(p) <= 57)
p++;
+ } else {
+ millisecond = 0;
+ }
+ } else {
+ hour = 0;
+ minute = 0;
+ second = 0;
+ millisecond = 0;
+ }
+
+ var tzhour = 0;
+ var tzminute = 0;
+ // parse time zone
+ if (buffer.charAt(p) != 'Z' && buffer.charAt(p) != '') {
+ var sign = (buffer.charAt(p) == '-' ? -1 : +1);
+ p++;
+ tzhour = sign * buffer.substr(p,2);
+ p += 3;
+ tzminute = sign * buffer.substr(p,2);
+ }
+
+ var thisDate = new Date();
+ thisDate.setUTCFullYear(year);
+ thisDate.setUTCMonth(month-1);
+ thisDate.setUTCDate(day);
+ thisDate.setUTCHours(hour);
+ thisDate.setUTCMinutes(minute);
+ thisDate.setUTCSeconds(second);
+ thisDate.setUTCMilliseconds(millisecond);
+ thisDate.setUTCHours(thisDate.getUTCHours() - tzhour);
+ thisDate.setUTCMinutes(thisDate.getUTCMinutes() - tzminute);
+ return thisDate;
+}
+xs_dateTime_to_date.visible = false;
+
+function scheme(url) {
+ var s = url.substring(0, url.indexOf(':'));
+ return s;
+}
+scheme.visible = false;
+
+function domain(url) {
+ var d = url.substring(url.indexOf('://') + 3,
url.indexOf('/',url.indexOf('://')+3));
+ return d;
+}
+domain.visible = false;
+
+function domainNoPort(url) {
+ var d = domain(url);
+ if (d.indexOf(":") >= 0)
+ d = d.substring(0, d.indexOf(':'));
+ return d;
+}
+domainNoPort.visible = false;
+
+try {
+ var secureEndpoint = "";
+ var pageUrl = document.URL;
+ var pageScheme = scheme(pageUrl);
+ // only attempt fixup if we're from an http/https domain ('file:' works
fine on IE without fixup)
+ if (pageScheme == "http" || pageScheme == "https") {
+ var pageDomain = domain(pageUrl);
+ var pageDomainNoPort = domainNoPort(pageUrl);
+ var endpoints = storexml._endpointDetails;
+ // loop through each available endpoint
+ for (var i in endpoints) {
+ var address = endpoints[i].address;
+ // if we're in a secure domain, set the endpoint to the first
secure endpoint we come across
+ if (secureEndpoint == "" && pageScheme == "https" &&
scheme(address) == "https") {
+ secureEndpoint = i;
+ storexml.endpoint=secureEndpoint;
+ }
+ // if we're in a known localhost domain, rewrite the endpoint
domain so that we won't get
+ // a bogus xss violation
+ if (pageDomainNoPort.indexOf('localhost') == 0 ||
pageDomainNoPort.indexOf('127.0.0.1') == 0 ) {
+ endpoints[i].address =
address.replace(domainNoPort(address), pageDomainNoPort);
+ }
+ }
+ }
+} catch (e) { }
\ No newline at end of file
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev