工作灯适配器调用Web服务。 错误无法读取性能阀体(worklight adapter invo

2019-11-01 19:32发布

调用以下适配器返回Ecma Error: TypeError: Cannot read property \"Body\" from undefined.

我看过类似的线程和有

-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;
}

Answer 1:

最后,它工作正常的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;
}


Answer 2:

看起来你正在做的WSDL的请求,而不是服务本身。



文章来源: worklight adapter invoke web service. error Cannot read property Body