I need to reference a JSON-RPC method by the URL and wondering how to do it or if you can do it.
I want to do it this way because I want to make the call inside of a $.post using jQuery.deferred(). Look at this example to see what I am trying to accomplish. I want to replace the "/echo/html/" with my RPC method. If I had to I could rewrite my RPC as an XAgent, but I would rather first see if anyone knew how to call it via URL.
My RPC method looks like this: openATMRPC.openATMFirst(); It works fine using traditional javascript, but as you can see I want it chained inside of the jQuery deferred function so that the .always runs.
var deferred = function(trueFalse) {
// return value from response as `deferred.promise`
// within `setTimeout` , after `1000` ms (one second)
return new $.Deferred(function (dfd) {
setTimeout(function () {
$.post("/echo/html/", {
html: trueFalse
})
// `deferred.always` utilized here ,
// to catch either `success` or `fail` ,
// not certain about `error` (`fail`) callbacks ?
.always(function (data) {
dfd.resolve(data)
})
}, 1000);
// return `deferred.promise()` ,
// e.g., "true" , or "false"
return dfd.promise()
})
};
UPDATE
Sorry if this wasn't clear previously. This is the XSP code for the remote call. The pathInfo property is part of the answer, but I haven't figured out how to use it to reference the method via a URL, which is what I am seeking. If I reference the ".../rpc" I get a "Service Error" message which is progress. How do I call the method inside the RPC-JSON via the URL is my question?
<xe:jsonRpcService id="jsonRpcService2" serviceName="openATMRPC" pathInfo="rpc">
<xe:this.methods>
<xe:remoteMethod name="openATMFirst">
<xe:this.script>
<![CDATA[print("into First");
var firstTry:boolean = atmBean.openATM(atmBean.atmID, userBean.userID, userBean.userPassword);
if(firstTry == false){
return firstTry.toString();
} else if(firstTry == true){
//atmBean.infoMessage = atmBean.atmID + " has been successfully Opened.";
return firstTry.toString();
}]]></xe:this.script></xe:remoteMethod>