0

调用以下适配器返回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;
}
4

2 回答 2

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;
}
于 2013-05-16T08:41:38.473 回答
0

看起来您正在向 WSDL 发出请求,而不是向服务本身发出请求。

于 2013-03-15T10:40:59.467 回答