Ibm mobilefirst worklight适配器调用web服务。错误:无法读取属性体

Ibm mobilefirst worklight适配器调用web服务。错误:无法读取属性体,ibm-mobilefirst,Ibm Mobilefirst,调用以下适配器返回Ecma错误:TypeError:无法从undefined中读取属性“Body”。 我读过类似的文章,也有过类似的经历 -Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser 到eclipse.ini 但这并没有解决问题 function getStateDetails(idstate) { var request='<?xml version="1.0" encodin

调用以下适配器返回Ecma错误:TypeError:无法从undefined中读取属性“Body”。

我读过类似的文章,也有过类似的经历

-Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser

到eclipse.ini 但这并没有解决问题

function getStateDetails(idstate) { 
    var request='<?xml version="1.0" encoding="utf-8"?>'+
      '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
      +'<soap:Body>'
      + '<test_demo><in0>{idstate}</in0></test_demo>'
      +'</soap:Body>'
      +'</soap:Envelope>';

    var input = {
        method : 'post',
        returnedContentType : 'xml',
        path : '/axis2/services/ws_demo/test_demo.wsdl',
        body : {
            content: request.toString(),
            contentType: 'text/xml; charset=utf-8'
        }
    };

    var result = WL.Server.invokeHttp(input);
    return result.Envelope.Body;
}
函数getStateDetails(idstate){ var请求=“”+ '' +'' +“{idstate}” +'' +''; 变量输入={ 方法:“post”, returnedContentType:'xml', 路径:'/axis2/services/ws_demo/test_demo.wsdl', 正文:{ 内容:request.toString(), contentType:'text/xml;字符集=utf-8' } }; var result=WL.Server.invokeHttp(输入); 返回result.Envelope.Body; }
看起来您是在向WSDL发出请求,而不是服务本身。

最后,在soapui和在请求中添加头的帮助下,它可以正常工作

function getStateDetails(idstate) {
var request='<?xml version="1.0" encoding="UTF-8"?>'
        +'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">'
        +'<Body><test_demo xmlns="http://www.ibm.com/informix/i4gl-soa/2010-11/ws_commandes">'
        +'<in0>'+idstate+'</in0></test_demo>'
        +'</Body></Envelope>';

        WL.Logger.debug("SOAP Request " + request);
            var input = {
                method : 'post',
                returnedContentType : 'xml',
                headers: {SOAPAction: 'test_demo'},
                path : '/axis2/services/ws_commandes',
                body : {
                    content: request.toString(),                  
                    contentType: 'text/xml; charset=utf-8'                
                }               

            };
            var result = WL.Server.invokeHttp(input);               
            return result.Envelope.Body.test_demo_response;
}
函数getStateDetails(idstate){ var请求=“” +'' +'' +''+idstate+''的 +''; WL.Logger.debug(“SOAP请求”+请求); 变量输入={ 方法:“post”, returnedContentType:'xml', 标题:{SOAPAction:'test_demo'}, 路径:'/axis2/services/ws_commandes', 正文:{ 内容:request.toString(), contentType:'text/xml;字符集=utf-8' } }; var result=WL.Server.invokeHttp(输入); 返回result.Envelope.Body.test\u demo\u响应; }
但它不会将issuery将returnContentType更改为“普通”。您将收到纯文本格式的响应,这样您就可以看到它有什么问题了。现在我得到了
{“errors”:[“文件过早结束”,“未能从后端解析有效负载(过程:HttpRequest)”],“info”:[],“isSuccessful”:false,“responseHeaders”:{“连接”:“保持活动”,“日期”:“Fri Mar 15 16:25:11 2013 GMT”,“服务器”:“Axis2C\/1.5.0(简单Axis2 HTTP服务器)”},“状态代码”:415,“状态原因”:“不支持的媒体类型”,“警告”:[]}