没有wsdl的GoogleApps脚本soap客户端
我正在尝试从google应用程序脚本访问Numara Footprints web服务API。web服务没有wsdl,但是方法有很好的文档记录。所有使用GoogleApps脚本Soap服务的示例都假定存在wsdl文件,这使它不再是我的首选。所以我尝试使用UrlFetchApp来代替。通过使用Numara Footprints提供的示例php代码,我确定了请求的外观,并在google apps脚本中编写了以下代码:没有wsdl的GoogleApps脚本soap客户端,soap,google-apps-script,Soap,Google Apps Script,我正在尝试从google应用程序脚本访问Numara Footprints web服务API。web服务没有wsdl,但是方法有很好的文档记录。所有使用GoogleApps脚本Soap服务的示例都假定存在wsdl文件,这使它不再是我的首选。所以我尝试使用UrlFetchApp来代替。通过使用Numara Footprints提供的示例php代码,我确定了请求的外观,并在google apps脚本中编写了以下代码: function sendHttpPost() { var payload= '&
function sendHttpPost() {
var payload= '<?xml version="1.0" encoding="utf-8"?>' +
'<SOAP-ENV:Envelope'+
'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"'+
'xmlns:ns1="MRWebServices"'+
'xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"' +
'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'+
'<SOAP-ENV:Body>'+
'<ns1:MRWebServices__search>'+
'<param0 xsi:type="xsd:string">ACCOUNT NAME</param0>'+
'<param1 xsi:type="xsd:string">PASSWORD</param1>'+
'<param2 xsi:type="xsd:string"></param2>'+
'<param3 xsi:type="xsd:string">'+
"SELECT * from MASTER1 where mrid='16888'</param3>"+
'</ns1:MRWebServices__search>'+
'</SOAP-ENV:Body>'+
'</SOAP-ENV:Envelope>';
var headers =
{
"SOAPAction" :encodeURIComponent("MRWebServices#MRWebServices__search")
};
var options =
{
"contentType": "text/xml; charset=utf-8",
"method" : "post",
"headers" : headers,
"payload" : payload
};
UrlFetchApp.fetch("http://FOOTPRINTS SERVER/MRcgi/MRWebServices.pl", options);
}
此代码成功联系服务器并返回以下错误消息:
Request failed for http://FOOTPRINTS SERVER/MRcgi/MRWebServices.pl
returned code 500. Server response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Application failed during request deserialization:
not well-formed (invalid token) at line 1, column 70, byte 70 at
C:/FootPrints/bin/Perl/lib/XML/Parser.pm line 187 </faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> (line 40)
我不知道如何获得更详细的错误消息,也不知道问题出在哪里。我发送的xml是直接从PHP代码中复制的,该代码可以完美地工作
我想知道是否有人:
可以看到上面或下面的谷歌应用程序脚本代码有问题
当我没有wsdl文件或脚本时,可以告诉我如何使用Google Apps脚本soap服务吗
知道一种让web服务返回更多错误详细信息的方法。
提前谢谢。我找遍了我能想到的所有地方,但没有找到答案。上述代码中的有效负载变量需要XML元素之间的空格。更正了每行末尾的代码注释空格:
var payload= '<?xml version="1.0" encoding="utf-8"?> ' +
'<SOAP-ENV:Envelope '+
'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '+
'xmlns:ns1="MRWebServices" '+
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' +
'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> '+
'<SOAP-ENV:Body> '+
'<ns1:MRWebServices__search> '+
'<param0 xsi:type="xsd:string">ACCOUNT NAME</param0> '+
'<param1 xsi:type="xsd:string">PASSWORD</param1> '+
'<param2 xsi:type="xsd:string"></param2> '+
'<param3 xsi:type="xsd:string"> '+
"SELECT * from MASTER22 where mrid='16888'</param3> "+
'</ns1:MRWebServices__search> '+
'</SOAP-ENV:Body> '+
'</SOAP-ENV:Envelope>';
var headers =
{
"SOAPAction" :"MRWebServices#MRWebServices__search"
};