0
votes

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

2

2 Answers

0
votes

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

0
votes

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.

Later I have changed the SOAP binding style to DOCUMENT and then I have regenerated the client stubs with Axis2. After that I was able to invoke the Web Services successfully and got the proper response as well. 

 So, Change the SOAP binding style to DOCUMENT.