我想創建一個SOAP適配器它採用soapenv:信封請求。但是,當我調用適配器日食會產生以下錯誤 - { 「錯誤」: 「了Ecma錯誤:類型錯誤:無法讀取屬性\」 從身體\」未定義 (C%3A%5Cdevelopment%5Cmywork%5CWorklight% 5CWorklightApp lications%5Cadapters%5CSOAPAdapter/SOAPAdapter-impl.js#40)」 ], 「信息」:[ ], 「isSuccessful」:假, 「警告」:[ ] }工作燈 - SOAP adapater uanble解析<soapenv:信封>請求
這似乎是一個SAXParser問題,因此我搜索了它並從IBM開發人員論壇獲得了一個解決方案(http://www.ibm.com/developerworks/forums/thread.jspa?threadID=454988) - 中的eclipse.ini的-vmargs線後,添加此 行,然後重新啓動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>";
感謝您的幫助提前。 --Yash
更新功能 -
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>
感謝快速響應很多Aviram,但問題是不與報價。我已經使用了字符串格式的一個簡單的肥皂請求 - 肥皂:信封和它工作正常。這裏的問題與soapenv元素有關。一些如何不正確解析。 – 2013-03-05 06:10:03
您在屬性中使用雙引號而不轉義它們,我相信創建的字符串不是您所期望的。要麼嘗試我的建議,要麼逃避這些引號。另外,記錄你創建的字符串,看看它是否看起來像你想要的。 – 2013-03-05 06:20:12