Axis1 非常非常简单的服务与 Axis2 客户端引发意外的子元素异常
我正在将 webesrvice 客户端从 Axis 迁移到 Axis2-1.6.1,但服务本身不会更改。我对 WDSL2Java 生成的代码有问题,因为我收到“意外的子元素”异常。 WDSL 非常简单,因为只有一个服务,并且它只接收一个字符串并返回一个日期:
<wsdl:definitions targetNamespace="xml.generator.ws">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:message name="generateToday1Request">
<wsdl:part name="idCompany" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="generateToday1Response">
<wsdl:part name="generateToday1Return" type="xsd:dateTime"/>
</wsdl:message>
<wsdl:portType name="WSGenerator">
<wsdl:operation name="generateToday1" parameterOrder="idCompany">
<wsdl:input message="impl:generateToday1Request" name="generateToday1Request"/>
<wsdl:output message="impl:generateToday1Response" name="generateToday1Response"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ValuationsXMLGeneratorSoapBinding" type="impl:WSGenerator">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="generateToday1">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="generateToday1Request">
<wsdlsoap:body namespace="http://generacion.stmts.bpi.com" use="literal"/>
</wsdl:input>
<wsdl:output name="generateToday1Response">
<wsdlsoap:body namespace="xml.generator.ws" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WSGeneratorService">
<wsdl:port binding="impl:ValuationsXMLGeneratorSoapBinding" name="ValuationsXMLGenerator">
<wsdlsoap:address location="http://naboo:8080/Statements2/services/ValuationsXMLGenerator"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我使用以下选项生成了源代码:
<axis-wsdl2java
output="${src.java}"
testcase="false"
wsdlfilename="http://naboo:8080/Statements2/services/ValuationsXMLGenerator?wsdl"
serverside="false"
unpackclasses="true"
unwrap="true"
suppressprefixes="true"
namespacetopackages="xml.generator.ws=com.spb.eco.valuations.xml"
generateAllClasses="true"/>
我使用生成的代码来调用服务,以及以下正文已发送:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<generateToday1 xmlns="http://generacion.stmts.bpi.com">
<idCompany xmlns="">US0010001</idCompany>
</generateToday1>
</soapenv:Body>
</soapenv:Envelope>
我收到以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<generateToday1Response xmlns="http://generacion.stmts.bpi.com">
<generateToday1Return>2011-09-19T22:56:53.781Z</generateToday1Return>
</generateToday1Response>
</soapenv:Body>
</soapenv:Envelope>
这是服务器的 server-config.wsdd:
<?xml version="1.0" ?>
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="ValuationsXMLGenerator" provider="java:RPC" style="rpc" use="literal">
<!-- Nombre de la clase que implementa los metodos expuestos -->
<parameter name="className" value="com.bpi.stmts.generacion.WSGenerator"/>
<parameter name="allowedMethods" value="generateToday1"/>
<parameter name="wsdlTargetNamespace" value="xml.generator.ws"/>
</service>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
<parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/>
<parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/>
<parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
<parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
<parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/>
<parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
</deployment>
它再简单不过了,但生成的代码失败,并出现以下异常:
原因: org.apache.axis2.databinding .ADBException:意外子元素 {http://generacion.stmts.bpi.com}generateToday1Return
在这种情况下,元素的顺序或类似的问题没有问题,所以我不明白为什么客户端失败。有什么想法吗?
蒂亚
吉林
I'm migrating my webesrvice client from Axis to Axis2-1.6.1, but the service itself will not be changed. I'm having issues with the code generated by the WDSL2Java, because I'm getting a "Unexpected subelement" exception. The WDSL is pretty simple, since there is only one service, and it only receives a String and returns a Date:
<wsdl:definitions targetNamespace="xml.generator.ws">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:message name="generateToday1Request">
<wsdl:part name="idCompany" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="generateToday1Response">
<wsdl:part name="generateToday1Return" type="xsd:dateTime"/>
</wsdl:message>
<wsdl:portType name="WSGenerator">
<wsdl:operation name="generateToday1" parameterOrder="idCompany">
<wsdl:input message="impl:generateToday1Request" name="generateToday1Request"/>
<wsdl:output message="impl:generateToday1Response" name="generateToday1Response"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ValuationsXMLGeneratorSoapBinding" type="impl:WSGenerator">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="generateToday1">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="generateToday1Request">
<wsdlsoap:body namespace="http://generacion.stmts.bpi.com" use="literal"/>
</wsdl:input>
<wsdl:output name="generateToday1Response">
<wsdlsoap:body namespace="xml.generator.ws" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WSGeneratorService">
<wsdl:port binding="impl:ValuationsXMLGeneratorSoapBinding" name="ValuationsXMLGenerator">
<wsdlsoap:address location="http://naboo:8080/Statements2/services/ValuationsXMLGenerator"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I've generated the source code with the following options:
<axis-wsdl2java
output="${src.java}"
testcase="false"
wsdlfilename="http://naboo:8080/Statements2/services/ValuationsXMLGenerator?wsdl"
serverside="false"
unpackclasses="true"
unwrap="true"
suppressprefixes="true"
namespacetopackages="xml.generator.ws=com.spb.eco.valuations.xml"
generateAllClasses="true"/>
I use the generated code to invoke the service, and the following body is sent:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<generateToday1 xmlns="http://generacion.stmts.bpi.com">
<idCompany xmlns="">US0010001</idCompany>
</generateToday1>
</soapenv:Body>
</soapenv:Envelope>
And I receive the following:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<generateToday1Response xmlns="http://generacion.stmts.bpi.com">
<generateToday1Return>2011-09-19T22:56:53.781Z</generateToday1Return>
</generateToday1Response>
</soapenv:Body>
</soapenv:Envelope>
And this is the server-config.wsdd for the server:
<?xml version="1.0" ?>
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="ValuationsXMLGenerator" provider="java:RPC" style="rpc" use="literal">
<!-- Nombre de la clase que implementa los metodos expuestos -->
<parameter name="className" value="com.bpi.stmts.generacion.WSGenerator"/>
<parameter name="allowedMethods" value="generateToday1"/>
<parameter name="wsdlTargetNamespace" value="xml.generator.ws"/>
</service>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
<parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/>
<parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/>
<parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
<parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
<parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/>
<parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
</deployment>
It couldn't be more simple, but the generated code fails with the following exception:
Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement
{http://generacion.stmts.bpi.com}generateToday1Return
In this case there is no problem with the orders of the elements, or anything like that, so I don't understand why the client is failing. Any ideas?
TIA
JL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题在于 SOAP 绑定样式,在您的 WSDL 中您使用了“RPC”作为样式,Axis2 不支持 RPC。我遇到了同样的问题,我已经使用 Axis1 客户端测试了 Web 服务,它可以工作,但在 Axis2 中也发生了同样的情况。
The problem is with the SOAP Binding style, In your WSDL you have used "RPC" as a style, Axis2 is not supporting the RPC. I have faced the same issue, I have tested the Web Service with Axis1 client it worked, but the same it happened in Axis2.
根据 WS-I 基本配置文件,您不应该有generateToday1Return 元素的命名空间。但响应它有一个名称空间。因此您的响应与 wSDL 文件不匹配。
欲了解更多信息,请查看此处[1]。
[1] http://wso2.org/library/2935
According to the WS-I basic profile you should not have a namespace for generateToday1Return element. But response it has a namespace. So your response is not matched with the wSDL file.
For more information please have a look at here[1].
[1] http://wso2.org/library/2935