
PUSTEFIX-INF.script.webservice_json.js Maven / Gradle / Ivy
if(!window.pfx) pfx={};
if(!pfx.ws) pfx.ws={};
if(!pfx.ws.json) pfx.ws.json={};
pfx.ws.json.deserialize=function(response) {
if(this._debug==true) alert("Response: "+response);
eval("res="+response);
return res;
};
pfx.ws.json.serialize=function(obj) {
var json=null;
if(obj!=null) {
if(obj.constructor==String) {
json=pfx.ws.json.escapeJSONString(obj);
} else if(obj.constructor==Number) {
json=obj.toString();
} else if(obj.constructor==Boolean) {
json=obj.toString();
} else if(obj.constructor==Date) {
json='new Date('+obj.valueOf()+')';
} else if(obj.constructor==Array) {
var arr=[];
for(var i=0;i=128) {
escStr[i]=pfx.ws.json.escapeJSONChar(str.charAt(i));
} else {
escStr[i]=str.charAt(i);
}
}
return "\""+escStr.join("")+"\"";
}
};
//
// BaseStub
//
pfx.ws.json.BaseStub=function(service,context,scope,requestPath) {
this._service=service;
this._context=context;
this._scope=scope;
this._requestPath=requestPath;
this._protocol="jsonws";
this._uri=null;
};
pfx.ws.json.BaseStub.prototype.setService=function(service) {
this._service=service;
this._uri=null;
};
pfx.ws.json.BaseStub.prototype.setContext=function(context) {
this._context=context;
};
pfx.ws.json.BaseStub.prototype.setRequestPath=function(requestPath) {
this._requestPath=requestPath;
this._uri=null;
};
pfx.ws.json.BaseStub.prototype.setDebug=function(debug) {
this._debug=debug;
};
pfx.ws.json.BaseStub.prototype.getURI=function() {
if(this._uri==null) {
var session="";
var matches=window.location.href.match(/;jsessionid=[A-Z0-9]+(\.[a-zA-Z0-9]+)?/);
if(matches) session=matches[0];
var reqpath=this._requestPath+"/"+this._service;
this._uri=window.location.protocol+"//"+window.location.host+reqpath+session;
}
return this._uri;
};
pfx.ws.json.BaseStub.prototype.callMethod=function(method,args,expLen) {
var wsCall=new pfx.ws.json.Call(this.getURI(),this._context,this._scope,this._debug);
return wsCall.invoke(method,args,expLen);
};
//
// DynamicProxy
//
pfx.ws.json.DynamicProxy=function(service,context) {
pfx.ws.json.BaseStub.call(this,service,context);
this._proxySetup();
};
pfx.ws.json.DynamicProxy.prototype=new pfx.ws.json.BaseStub;
pfx.ws.json.DynamicProxy.prototype._proxySetup=function() {
var req=new pfx.net.HTTPRequest('POST',this.getURI()+'?json',this._proxySetupCB,this);
req.setRequestHeader('wstype',this._protocol);
req.start('',0);
};
pfx.ws.json.DynamicProxy.prototype._proxySetupCB=function(response) {
eval("response="+response);
var methods=response.result;
for(var i=0;i0 && typeof args[argLen-1]=='function') {
this._userCallback=args[argLen-1];
argLen=argLen-1;
} else if(argLen>1 && typeof args[argLen-2]=='function') {
this._requestId=args[argLen-1];
this._userCallback=args[argLen-2];
argLen=argLen-2;
}
}
if(this._requestId) jsonReq.id=this._requestId;
var jsonParams=[];
for(var i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy