Configuring WSDD to match the WSDL in AXIS
Asked Answered
A

2

6

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.

Apiculture answered 27/9, 2012 at 20:35 Comment(4)
it seems it is related to: ws-rx.blogspot.ca/2006/12/…Apiculture
Did you use the same Wsdl to create the client and server parts? Ie did you start with the Wsdl each time?Praenomen
nope. only for client. this the question, how to use one for both? I have asked this already here: #12608782Apiculture
Have a look at your other question - you need to generate both from the WSDL. This is usually allowed in most web services frameworks.Praenomen
A
3

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.

Apiculture answered 28/9, 2012 at 17:5 Comment(0)
C
0

What the error is telling you is that request should looks like

<soapenv:Envelope> <request> <SalesRequest>...

and you are sending

<soapenv:Envelope> <SalesReturn>...

Best way to get this figure out is to try with a tool like SOAP UI and compare the payload they send with what you are generating from your tool - some tools have an option to wrap or unwrap the part name in the input/output messages.

hope this helps

Conducive answered 28/9, 2012 at 0:55 Comment(1)
I know it. I saw it. But how to fix it? This +Return is generated by sever automatically (i guess based on WSDD)Apiculture

© 2022 - 2024 — McMap. All rights reserved.