0
我试图从谷歌应用程序脚本访问Numara Footprints Web服务API。 Web服务没有wsdl,但是这些方法都有很好的文档记录。所有使用Google Apps脚本Soap服务的示例都假定存在wsdl文件,这使得它对我而言不起作用。所以我想改用UrlFetchApp。通过使用示例PHP代码ヌ足迹提供,我建立请求应该是什么样子,并写在谷歌下面的代码Google Apps脚本:谷歌应用程序脚本肥皂客户端没有wsdl
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代码中复制。
我想知道,如果有人或者:
- 可以看到一个问题与谷歌Apps脚本代码的上方或
- 能告诉我如何使用谷歌Apps脚本SOAP服务的时候我不知道有一个wsdl文件或
- 知道一种获取Web服务的方式来返回更多的错误细节。
在此先感谢。我到处都能看到我能想到的东西,但没有找到答案。