我使用Axis2版本1.5.4,Java 1.6开发了服务器和客户端应用程序,并且服务器部署在tomcat 6上。 服务是使用注释声明的,因此没有.aar文件或任何类型的文件。 WSDL是由Axis2自动创建的。 客户端是使用WSDL2Java使用以下命令生成的存根和参数创建的:
%axis2_home%\bin\WSDL2Java -p com.audaxys.leaseclient.servicestub.generic -d adb -Eosv -s -g -u -uw -or -sp -S src/main/java -R src/main/resources --noBuildXML -uri %baseurl%/AppleFinderService.Rpc?wsdl
当客户端应用调用方法public Apple loadApple(String appType)
时,服务器响应返回一个Apple类实例,但客户端无法反序列化响应并抛出此异常。
如果您知道如何解决这个问题,请与我分享一下吗? 任何线索都会非常感激,真的!
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement apple
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at com.audaxys.leaseclient.servicestub.generic.AppleFinderServiceStub.fromOM(AppleFinderServiceStub.java:1015)
at com.audaxys.leaseclient.servicestub.generic.AppleFinderServiceStub.loadApple(AppleFinderServiceStub.java:343)
at com.audaxys.lease.ws.client.TestDummyServices.testLoadApple(TestDummyServices.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException: Unexpected subelement apple
at com.audaxys.www.namespaces.leasews.LoadAppleResponse$Factory.parse(LoadAppleResponse.java:454)
at com.audaxys.leaseclient.servicestub.generic.AppleFinderServiceStub.fromOM(AppleFinderServiceStub.java:981)
... 18 more
Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement apple
at com.audaxys.www.namespaces.leasews.LoadAppleResponse$Factory.parse(LoadAppleResponse.java:448)
... 19 more
package com.audaxys.lease.model.generic;
import .....;
@WebService(name="AppleFinderService", serviceName="AppleFinderService", portName="Rpc", targetNamespace="http://www.audaxys.com/namespaces/leasews")
@SOAPBinding(style = Style.RPC, parameterStyle = ParameterStyle.WRAPPED)
public class AppleFinderImpl {
@WebResult(name = "apple")
public Apple loadApple(String appType) {
Apple a = new Apple();
a.setAppleType(appType);
return a;
}
}
package com.audaxys.lease.model.generic;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(namespace="http://www.audaxys.com/namespaces/leasews")
public class Apple {
private String appleType;
public Apple() {
super();
}
public String getAppleType() {
return appleType;
}
public void setAppleType(String appleType) {
this.appleType = appleType;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="AppleFinderService" targetNamespace="http://www.audaxys.com/namespaces/leasews" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.audaxys.com/namespaces/leasews" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://jaxb.dev.java.net/array">
<types>
<xsd:schema>
<xsd:import namespace="http://www.audaxys.com/namespaces/leasews" schemaLocation="AppleFinderService.Rpc?xsd=AppleFinderService_schema1.xsd" />
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://jaxb.dev.java.net/array" schemaLocation="AppleFinderService.Rpc?xsd=AppleFinderService_schema2.xsd" />
</xsd:schema>
</types>
<message name="loadAppleResponse">
<part name="apple" type="tns:apple" />
</message>
<message name="getAppleArray">
<part name="arg0" type="xsd:string" />
</message>
<message name="loadApple">
<part name="arg0" type="xsd:string" />
</message>
<portType name="AppleFinderService">
<operation name="getAppleArray">
<input message="tns:getAppleArray" />
<output message="tns:getAppleArrayResponse" />
</operation>
<operation name="loadApple">
<input message="tns:loadApple" />
<output message="tns:loadAppleResponse" />
</operation>
</portType>
<binding name="RpcBinding" type="tns:AppleFinderService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getAppleArray">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" namespace="http://www.audaxys.com/namespaces/leasews" />
</input>
<output>
<soap:body use="literal" namespace="http://www.audaxys.com/namespaces/leasews" />
</output>
</operation>
<operation name="loadApple">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" namespace="http://www.audaxys.com/namespaces/leasews" />
</input>
<output>
<soap:body use="literal" namespace="http://www.audaxys.com/namespaces/leasews" />
</output>
</operation>
</binding>
<service name="AppleFinderService">
<port name="Rpc" binding="tns:RpcBinding">
<soap:address location="http://10.10.5.25:8080/lease.services/soap/services/AppleFinderService.Rpc/" />
</port>
</service>
</definitions>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.audaxys.com/namespaces/leasews" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://www.audaxys.com/namespaces/leasews">
<xs:element name="apple" type="tns:apple" />
<xs:complexType name="apple">
<xs:sequence>
<xs:element minOccurs="0" name="appleType" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType final="#all" name="appleArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns:apple" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<loadApple xmlns="http://www.audaxys.com/namespaces/leasews">
<arg0>Red</arg0>
</loadApple>
</soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<rpcOp:loadAppleResponse xmlns:rpcOp="http://www.audaxys.com/namespaces/leasews">
<rpcOp:apple xmlns:ns3="http://com.audaxys.lease/" xmlns="">
<appleType>Red</appleType>
</rpcOp:apple>
</rpcOp:loadAppleResponse>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:1)
您的帖子很难阅读,但我相信问题出在WSDL和XSD中。你有一个元素,complexType和消息部分都具有相同的名称“苹果”。我会尝试按照惯例here重新编写WSDL:
<element name="Apple" type="tns:AppleType"/>
<complexType name="AppleType">
...
</complexType>
<message name="loadAppleResponse">
<part name="apple" element="tns:Apple"/>
</message>
答案 1 :(得分:0)
我遇到过类似的问题,我使用JAX-WS API注释了EJB SLSB,并使用RPC作为SOAP Bindind样式。在JBoss5.1中部署了EJB,JBOSSWS生成了WSDL。
当我通过Axis1客户端测试Web服务时,它工作正常,但在使用Axis2客户端进行测试时,请求已发送到服务器,甚至数据库事务也成功。
但是当响应来到客户端时,它表示意外的子元素返回,依此类推。然后我改变了它与Axis2一起使用的SOAP绑定样式。
@WebService
@SOAPBinding(style=Style.DOCUMENT, parameterStyle = ParameterStyle.WRAPPED)
public interface BillingAccountManagement_SEI { // TODO}