ibm mobilefirst - Worklight - SOAP adapater uanble to parse <soapenv:Envelope> request -


i trying create soap adapter uses soapenv:envelope request. when invoke adapter eclipse produces following error - { "errors": [ "ecma error: typeerror: cannot read property \"body\" undefined (c%3a%5cdevelopment%5cmywork%5cworklight%5cworklightapp lications%5cadapters%5csoapadapter/soapadapter-impl.js#40)" ], "info": [ ], "issuccessful": false, "warnings": [ ] }

it seems saxparser issue therefore googled , got solution ibm developers forum (http://www.ibm.com/developerworks/forums/thread.jspa?threadid=454988) - after -vmargs line in eclipse.ini, add line , restart eclipse: -dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.saxparser

i did still getting same error. here soap 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>"; 

thanks in advance. --yash

updated function -

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; 

}

updated 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> 

instead of creating soap request string should create xml literal (e4x).

meaning, instead of var request = "<mytag>" + myjsvar + "</mytag>"; should var request = <mytag> {myjsvar} </mytag>;

see slides 5 , 6 in using http adapters soap services examples


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -