无法从Ofbiz反序列化SOAP响应中的元素

时间:2015-08-28 17:34:31

标签: node.js web-services soap wsdl ofbiz

我正在尝试使用node:

调用在本地计算机上运行的ofbiz实例上部署的SOAP服务
var soap = require('soap');
var url = 'https://localhost/webtools/control/SOAPService/testSoapSimple?wsdl';
var args = {'login.username':'flexadmin', 'login.password':'ofbiz'};
soap.createClient(url, function(err, client){
    if(err) throw err;
    console.log(client.describe());
    client.testSoapSimple.testSoapSimplePort.testSoapSimple(args,function(err, result, raw, soapHeader){
        console.log(result);
        console.log(raw);
    });
});

控制台输出如下:

{ testSoapSimple: { testSoapSimplePort: { testSoapSimple: [Object] } } }
{ 'map-Map': { 'map-Entry': [ [Object], [Object] ] } }
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><testSoapSimpleResponse xmlns="http://ofbiz.apache.org/service/"><map-Map>
        <map-Entry>
            <map-Key>
                <std-String value="responseMessage"></std-String>
            </map-Key>
            <map-Value>
                <std-String value="error"></std-String>
            </map-Value>
        </map-Entry>
        <map-Entry>
            <map-Key>
                <std-String value="errorMessage"></std-String>
            </map-Key>
            <map-Value>
                <std-String value="Cannot deserialize element named login.username"></std-String>
            </map-Value>
        </map-Entry>
    </map-Map></testSoapSimpleResponse></soapenv:Body></soapenv:Envelope>

它返回值无法反序列化名为login.username 的元素 我检查了日志,然后说:

2015-08-28 22:30:28,218 (http-bio-0.0.0.0-443-exec-29) [   SOAPEventHandler.java:233:ERROR] 
---- exception report ----------------------------------------------------------
Exception: org.ofbiz.entity.serialize.SerializeException
Message: Cannot deserialize element named login.username
---- stack trace ---------------------------------------------------------------
org.ofbiz.entity.serialize.SerializeException: Cannot deserialize element named login.username
org.ofbiz.entity.serialize.XmlSerializer.deserializeCustom(XmlSerializer.java:478)
org.ofbiz.entity.serialize.XmlSerializer.deserializeSingle(XmlSerializer.java:460)
org.ofbiz.entity.serialize.XmlSerializer.deserialize(XmlSerializer.java:128)
org.ofbiz.service.engine.SoapSerializer.deserialize(SoapSerializer.java:45)
org.ofbiz.webapp.event.SOAPEventHandler.invoke(SOAPEventHandler.java:180)
org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:662)
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:406)
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224)
org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:344)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
java.lang.Thread.run(Thread.java:662)

有人可以解释我做错了什么吗?或者,如果提供的WSDL出现问题?

1 个答案:

答案 0 :(得分:0)

这是因为我尝试发送的SOAP格式不是服务提供商提供的适当格式。 “login.username”被视为此处的元素,因为它应该是属性的值。例如,在这种情况下,它可能类似于:

<map-Map>
        <map-Entry>
            <map-Key>
                <login.username>123456</login.username>
            </map-Key>
        </map-Entry>
<map-Map>  

不符合服务提供商支持的内容。它应该是这样的:

<map-Map>
<map-Entry>
            <map-Key>
                <std-String value="login.username"></std-String>
            </map-Key>
            <map-Value>
                <std-String value="123456"></std-String>
            </map-Value>
        </map-Entry>
<map-Map>