无法反序列化来自 Ofbiz 的 SOAP 响应中的元素
Cannot deserialize element in SOAP response from Ofbiz
我正在尝试调用部署在 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>
它 returns 的值为 无法反序列化名为 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 有问题?
发生这种情况是因为我尝试发送的 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>
我正在尝试调用部署在 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>
它 returns 的值为 无法反序列化名为 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 有问题?
发生这种情况是因为我尝试发送的 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>