worklight适配器调用Web服务。错误无法读取属性Body [英] worklight adapter invoke web service. error Cannot read property Body

查看:148
本文介绍了worklight适配器调用Web服务。错误无法读取属性Body的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我读过类似的帖子并且

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

到eclipse.ini
但是没有解决问题。

to eclipse.ini but didn't solve the issue.

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


推荐答案

最后它可以正常工作soapui的帮助和在请求中添加标题。

finally it works fine with the help of soapui and adding headers in the request.

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

这篇关于worklight适配器调用Web服务。错误无法读取属性Body的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆