Axis2客户端意外的子元素苹果 [英] Axis2 client Unexpected subelement apple

查看:83
本文介绍了Axis2客户端意外的子元素苹果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Axis2版本1.5.4,Java 1.6开发了服务器和客户端应用程序,并且服务器已部署在tomcat 6上. 服务使用注释声明,因此没有.aar文件或任何此类文件. WSDL由Axis2自动创建. 客户端是使用WSDL2Java生成的存根和参数并使用以下命令制成的:

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

当客户端应用程序调用方法public Apple loadApple(String appType)时,服务器将返回一个Apple类实例进行响应,但客户端无法反序列化响应并引发此异常.

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!

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

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

苹果类

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>

请求

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

推荐答案

我遇到了类似的问题,我使用JAX-WS API注释了EJB SLSB,并使用RPC作为SOAP Bindind样式. JBoss5.1和JBOSSWS生成WSDL.

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.

当我通过Axis1客户端测试Web服务时,它可以正常工作,但是在使用Axis2客户端进行测试时,请求已发送到服务器,甚至DB事务也成功了.

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.

但是当响应到达客户时,它表示意外的子元素返回,依此类推.然后,我更改了它与Axis2一起使用的SOAP绑定样式.

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}

这篇关于Axis2客户端意外的子元素苹果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆