How to use mimic xmlrpc to make a call to other apps and get response ?
Hi .
after a few days of hacking , although still no solutions , but i think i found a way
to trace my problem , that is to use chrome F12 , and this is what i found out
code
XmlRpcRequest.prototype.send = function() {
var xml_params = ""
for(var i = 0; i < this.params.length; i++)
xml_params += XmlRpc.PARAM.replace("${DATA}", this.marshal(this.params));
var xml_call = XmlRpc.REQUEST.replace("${METHOD}", this.methodName);
xml_call = XmlRpc.PROLOG + xml_call.replace("${DATA}", xml_params);
alert(xml_call);
var xhr = Builder.buildXHR();
alert(xhr);
alert(this.serviceUrl);
xhr.open("POST", this.serviceUrl, true );
//how to simulate the google app script , UrlFetch
//var optAdvancedArgs = {
// contentType : "text/xml",
// method : "post",
// payload : xml_call
//};
//if (this.authentication != null) {
// var authHeader = {
// Authorization : "Basic "
// + new Base64_(this.authentication["user"] + ":"
// + this.authentication["password"]).encode()
// };
// optAdvancedArgs["headers"] = authHeader;
//}
// TODO handle exceptions while processing UrlFetchApp.fetch
// http://www.google.com/support/forum/p/apps-script/thread?tid=0d067c1db98aa7f8&hl=en
//var response = UrlFetchApp.fetch(this.serviceUrl, optAdvancedArgs);
//return new XmlRpcResponse(Xml.parse(response.getContentText()));
// Set header so the called script knows that it's an XMLHttpRequest
xhr.setRequestHeader("Content-type", "text/xml");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
//xhr.setRequestHeader("payload",xml_cal);
xhr.send(Builder.buildDOM(xml_call));
return new XmlRpcResponse(xhr.responseXML);
};
/code
as i compare my google app scripts and the javascript that i used here at appery.io
i found that at google , it uses UrlFetchApp.fetch which there is not such
function in appery.io , so i think i need to do something in order for me to make
a call to another domain/url ... and i think is somewhere along the line where i
need to put set my browser header ... after what i did about , i tested my
appery.io app and in the chrome F12 debug , network tab ... i found this
code
Request URL:http://myserver.com:8089/xmlrpc/common
Request Headersview parsed
OPTIONS http://myserver.com:8089/xmlrpc/common HTTP/1.1
Access-Control-Request-Method: POST
Origin: http://appery.io
Referer: http://appery.io/app/view/c7a8beba-12a2-443a-a9f4-071d4bdb9927/fmMainInstantMobPOS.html
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
Access-Control-Request-Headers: origin, x-requested-with, content-type
/code
is there anything i missed ? Any comments or advices ?