Search code examples
javaweb-servicessoapaxisjax-rpc

Configuring WSDD to match the WSDL in AXIS


I have WSDL (I got it from external provider). There are lines like this:

  <xsd:complexType name="SalesRequest">
                <xsd:all>
                    <xsd:element name="merchantid" type="xsd:int"/>
                    <xsd:element name="password" type="xsd:string"/>
                    ...
                </xsd:all>
  </xsd:complexType>

  ... 
  <message name="SalesResponse">
        <part name="request" type="tns:SalesResponse"/>
  </message>
  ..
  <portType name="InterfacePortType">
    <operation name="Sales">
        <documentation>some text</documentation>
        <input message="tns:SalesRequest"/>
        <output message="tns:SalesResponse"/>
  </operation>

I've generated Java classes based on this WSDL (using JAX-RPC).

Then I created Axis Service (MyService implements InterfacePortType).

I prepared XSDD file do deploy MyService to web app.

So, then I call one of the my methods of MySerive and got this error in the moment of response serialization on the server side:

unexpected element name: expected=request, actual=SalesReturn

It means that my XSDL and XSDD do not much it other. MyService prepared response like this (but count not send it via the net):

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope 
...
<SalesReturn href="#id0"/></ns1:SalesResponse><multiRef xmlns:ns2=
...
</soapenv:Envelope>

The question is: What I should do with WSDD in order to have the 'request' instead of 'SalesReturn' in response XML from service?

I have not idea where this 'Return' suffix came from.

-- some steps I already did:

I googled, and found that WSDL should have 'schema elementFormDefault="qualified"' in it. But I can not change WSDL, because it is external one, it was provided me by external provider.


Solution

  • I found the solution, I generated WSDD using axistools-maven-plugin, setting: serverSide parameter to true - then it generates the WSDD file.

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
         <artifactId>axistools-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>wsdl2java-job</id>
                     <phase>generate-sources</phase>
                        <goals>
                          <goal>wsdl2java</goal>
                        </goals>
                      <configuration>
                          <sourceDirectory>
                               src/main/config/wsdl2java/myfolder 
                           </sourceDirectory>
                            <outputDirectory>
                                ${generatedSourcesDirectory} 
                            </outputDirectory>
                            <testCases>false</testCases>
                            <serverSide>true</serverSide>
                            <subPackageByFileName> false 
                            </subPackageByFileName>
                            <packageSpace> my.api 
                            </packageSpace>
                            </configuration>
                       </execution>
         </plugin>
    

    Btw, when I launch this plugin it ends up with compilation exception, but, nevertheless, it could generated me WSDD.

    Then if look at WSDD wich was generated, there are some interesting line that I did not have in my manually made WSDD:

    <operation name="sales" qname="operNS:Sales" 
    xmlns:operNS="urn:Interface" 
    returnQName="request" 
    returnType="rtns:SalesResponse" 
    xmlns:rtns="urn:Interface" soapAction="urn:Interface#Sales" >
      <parameter qname="in" type="tns:SalesRequest" xmlns:tns="urn:Interface"/>
    </operation>
    

    This part: returnQName="request"

    Also it generates "typeMapping" tags (but I used beanMapping)

    So, as soon as I put this changes to my file I got everything working.

    Actually, originally for generating my initial sources I have used another plugin: maven-antrun-plugin

    But there were no option to generate WSDD.