Page 2 of 2

How to use mimic xmlrpc to make a call to other apps and get response ?

Posted: Wed May 29, 2013 2:54 am
by kalmen chia

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 = "&quot
for(var i = 0; i < this&#46;params&#46;length; i++)
xml_params += XmlRpc&#46;PARAM&#46;replace("${DATA}", this&#46;marshal(this&#46;params));
var xml_call = XmlRpc&#46;REQUEST&#46;replace("${METHOD}", this&#46;methodName);
xml_call = XmlRpc&#46;PROLOG + xml_call&#46;replace("${DATA}", xml_params);
alert(xml_call);
var xhr = Builder&#46;buildXHR();
alert(xhr);
alert(this&#46;serviceUrl);
xhr&#46;open("POST", this&#46;serviceUrl, true );

&#47;&#47;how to simulate the google app script , UrlFetch
&#47;&#47;var optAdvancedArgs = {
&#47;&#47; contentType : "text&#47;xml",
&#47;&#47; method : "post",
&#47;&#47; payload : xml_call
&#47;&#47;};
&#47;&#47;if (this&#46;authentication != null) {
&#47;&#47; var authHeader = {
&#47;&#47; Authorization : "Basic "
&#47;&#47; + new Base64_(this&#46;authentication["user"] + ":"
&#47;&#47; + this&#46;authentication["password"])&#46;encode()
&#47;&#47; };
&#47;&#47; optAdvancedArgs["headers"] = authHeader;
&#47;&#47;}
&#47;&#47; TODO handle exceptions while processing UrlFetchApp&#46;fetch
&#47;&#47; http:&#47;&#47;www&#46;google&#46;com&#47;support&#47;forum&#47;p&#47;apps-script&#47;thread?tid=0d067c1db98aa7f8&hl=en
&#47;&#47;var response = UrlFetchApp&#46;fetch(this&#46;serviceUrl, optAdvancedArgs);
&#47;&#47;return new XmlRpcResponse(Xml&#46;parse(response&#46;getContentText()));

&#47;&#47; Set header so the called script knows that it's an XMLHttpRequest
xhr&#46;setRequestHeader("Content-type", "text&#47;xml");
xhr&#46;setRequestHeader("X-Requested-With", "XMLHttpRequest");
&#47;&#47;xhr&#46;setRequestHeader("payload",xml_cal);

xhr&#46;send(Builder&#46;buildDOM(xml_call));
return new XmlRpcResponse(xhr&#46;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:&#47;&#47;myserver&#46;com:8089&#47;xmlrpc&#47;common
Request Headersview parsed
OPTIONS http:&#47;&#47;myserver&#46;com:8089&#47;xmlrpc&#47;common HTTP&#47;1&#46;1
Access-Control-Request-Method: POST
Origin: http:&#47;&#47;appery&#46;io
Referer: http:&#47;&#47;appery&#46;io&#47;app&#47;view&#47;c7a8beba-12a2-443a-a9f4-071d4bdb9927&#47;fmMainInstantMobPOS&#46;html
User-Agent: Mozilla&#47;5&#46;0 (Windows NT 6&#46;1; WOW64) AppleWebKit&#47;537&#46;36 (KHTML, like Gecko) Chrome&#47;27&#46;0&#46;1453&#46;94 Safari&#47;537&#46;36
Access-Control-Request-Headers: origin, x-requested-with, content-type
/code

is there anything i missed ? Any comments or advices ?


How to use mimic xmlrpc to make a call to other apps and get response ?

Posted: Wed May 29, 2013 6:33 am
by Kateryna Grynko

Hi Kalmen,

Do you use Appery.io proxy?

Here you can find details about cross-domain requests:
https://developer.mozilla.org/en-US/d...

Your server must have a special way to respond to the given OPTIONS request:
codeOPTIONS http:&#47;&#47;myserver&#46;com:8089&#47;xmlrpc&#47;common HTTP&#47;1&#46;1/code
Otherwise, the browser doesn't allow the main query, because not getting the right answer, it considers the request to be ineligible for the host server.

It's outside the scope of our support. I would advise you to consult a programmer.


How to use mimic xmlrpc to make a call to other apps and get response ?

Posted: Wed May 29, 2013 7:04 am
by kalmen chia

Hi

I do not think i used Appery.io proxy , do you know how to
activate it on ?


How to use mimic xmlrpc to make a call to other apps and get response ?

Posted: Wed May 29, 2013 7:08 am
by Kateryna Grynko

This is pretty simple. Tick "Use Appery.io Proxy" in Rest service settings.