【发布时间】:2017-10-02 15:33:16
【问题描述】:
我正在使用以下代码获取结果,但由于某种原因,我收到此错误:第 1 行错误:prolog 中不允许内容。 (第 134 行,文件“代码”),在这种情况下是
var xmlResult = XmlService.parse(result).getRootElement();
var xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://openclinica.org/ws/studySubject/v1\" xmlns:bean=\"http://openclinica.org/ws/beans\">"
+"<soapenv:Header>"
+"<wsse:Security soapenv:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">"
+"<wsse:UsernameToken wsu:Id=\"UsernameToken-27777511\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">"
+"<wsse:Username>yyyy</wsse:Username>"
+"<wsse:Password>xxxxx</wsse:Password>"
+"</wsse:UsernameToken>"
+"</wsse:Security>"
+"</soapenv:Header>"
+"<soapenv:Body>"
+"<v1:listAllByStudyRequest>"
+"<bean:studyRef>"
+"<bean:identifier>PROSPER2</bean:identifier>"
+"</bean:studyRef>"
+"</v1:listAllByStudyRequest>"
+"</soapenv:Body>"
+"</soapenv:Envelope>";
var options =
{
"method" : "post",
"contentType" : "text/xml",
"payload" : xml
};
var result = UrlFetchApp.fetch("http://89.221.253.174:8080/OpenClinica-ws/ws/studySubject/v1/studySubjectWsdl.wsdl", options);
var xmlResult = XmlService.parse(result).getRootElement();
Logger.log(xmlResult);
知道为什么这不起作用,我正在使用谷歌应用程序脚本来执行此代码;
【问题讨论】:
-
如果我使用soapUI执行上面的xml它工作正常。
-
返回的 XML 的大小是多少? >10MB?
-
我认为它甚至不是 100kb @JackBrown
-
您能否提供一个将返回的 xml 示例,
Logger.log("result") -
Xmlparse 在您的数据上运行良好,我怀疑 UrlFetch 返回的不是 xml 响应。在 URLFetct
Logger.log(result)之后添加它会得到什么。加试试这个var xmlResult = XmlService.parse(result.getContentText()).getRootElement();
标签: xml web-services soap google-apps-script wsdl