我正在尝试创建一个使用soapenv:Envelope请求的SOAP 适配器。但是当我调用适配器时,eclipse会产生以下错误-{“errors”:[“Ecma错误:TypeError:无法从未定义(C%3A%5Cdevelopment%5Cmywork%5CWorklight%5CWorklightApp lications%5Cadapters%5CSOAPAdapter /SOAPAdapter-impl.js#40)" ], "info": [ ], "isSuccessful": false, "warnings": [ ] }
这似乎是一个 SAXParser 问题,因此我用谷歌搜索它并从 IBM 开发人员论坛( http://www.ibm.com/developerworks/forums/thread.jspa?threadID=454988 )获得了解决方案- 在 eclipse 中的 -vmargs 行之后.ini,添加这一行然后重启 Eclipse: -Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser
我这样做了,但我仍然遇到同样的错误。这是我的 SOAP 请求 -
"<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"+
"xmlns:xsd="http://www.w3.org/2001/XMLSchema"+
"xmlns:soapenv="http://schemas.xmlsoap.org"+
"/soap/envelope/" xmlns:soap="http://soap.amazon.com">"+
"<soapenv:Header/>"+
"<soapenv:Body>"+
"<soap:ActorSearchRequest soapenv:encodingStyle="http://schemas.xmlsoap.org"+
"/soap/encoding/">"+
"<ActorSearchRequest xsi:type="soap:ActorRequest" xs:type="type:ActorRequest"+
"xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">"+
"<actor xsi:type="xsd:string" xs:type="type:string">abc</actor>"+
"<page xsi:type="xsd:string" xs:type="type:string">1</page>"+
"<mode xsi:type="xsd:string" xs:type="type:string">a</mode>"+
"<tag xsi:type="xsd:string" xs:type="type:string">a</tag>"+
"<type xsi:type="xsd:string" xs:type="type:string">a</type>"+
"<devtag xsi:type="xsd:string" xs:type="type:string">a</devtag>"+
"</ActorSearchRequest>"+
"</soap:ActorSearchRequest>"+
"</soapenv:Body>"+
"</soapenv:Envelope>";
更新功能 -
function temperatureConvertor(celsiusTemp) {
var request = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.amazon.com">'+
'<soapenv:Header/>'+
'<soapenv:Body>'+
'<soap:ActorSearchRequest soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'+
'<ActorSearchRequest xsi:type="soap:ActorRequest" xs:type="type:ActorRequest" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">'+
'<actor xsi:type="xsd:string" xs:type="type:string">abc</actor>'+
'<page xsi:type="xsd:string" xs:type="type:string">1</page>'+
'<mode xsi:type="xsd:string" xs:type="type:string">a</mode>'+
'<tag xsi:type="xsd:string" xs:type="type:string">a</tag>'+
'<type xsi:type="xsd:string" xs:type="type:string">a</type>'+
'<devtag xsi:type="xsd:string" xs:type="type:string">a</devtag>'+
'</ActorSearchRequest>'+
'</soap:ActorSearchRequest>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';
var input = {
method : 'post',
returnedContentType : 'plain',
path : '/schemas2/AmazonWebServices.wsdl',
body: {
content: request.toString(),
contentType: 'text/xml; charset=utf-8'
}
};
var result = WL.Server.invokeHttp(input);
return result.Envelope.Body;
}
更新了 adapter.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wl:adapter xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SOAPAdapter">
<displayName>SOAPAdapter</displayName>
<description>SOAPAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>soap.amazon.com</domain>
<port></port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2"/>
</connectivity>
<procedure name="temperatureConvertor"/>
</wl:adapter>