开发者

Axis2 client Unexpected subelement apple

I developed both a server and client application using Axis2 version 1.5.4, Java 1.6 and the server is deployed on tomcat 6. The services are declared using annotations, so there is no .aar files or anything of that sort. The WSDL was created automatically by Axis2. The client was made using the stubs and parameters generated by WSDL2Java using the command:

%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

When the client app calls the method public Apple loadApple(String appType) the server responds returning one instance of Apple class, but the client is unable to de-serialize the response and throws this exception.

If you know how to fix this, could you please share it with me? Any clues would be greatly appreciated, really!

Full stack trace:

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(JUnit3T开发者_Go百科estReference.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

ServiceDeclaration

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

Apple class

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

WSDL

<?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>

XSD

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

Request

<?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>

Responsse

<?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>


Your post is hard to read but I believe the problem is in the WSDL and XSD. You have an element, complexType and message part all with the same name "apple". I would try reworking the WSDL following the convention here:

<element name="Apple" type="tns:AppleType"/>
<complexType name="AppleType">
...
</complexType>

<message name="loadAppleResponse">
  <part name="apple" element="tns:Apple"/>        
</message>


I have faced the similiar kind of problem, I have annotated the EJB SLSB using JAX-WS API's and used RPC as the SOAP Bindind style.Deployed the EJB in JBoss5.1 and JBOSSWS generates the WSDL.

When I tested the Web Services by Axis1 client it worked fine, But while testing with Axis2 client, the request has sent to the server and even the DB transactions also was successfull.

But when the response came to the client, it says the Unexpected subelement return and so on. Then I changed the SOAP binding style it worked with Axis2.

 @WebService 
  @SOAPBinding(style=Style.DOCUMENT, parameterStyle = ParameterStyle.WRAPPED)
  public interface BillingAccountManagement_SEI { // TODO}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜