Can I make Axis2 generate a WSDL with 'unwrapped' types?

Posted by Bedwyr Humphreys on Stack Overflow See other posts from Stack Overflow or by Bedwyr Humphreys
Published on 2009-11-12T19:04:31Z Indexed on 2010/06/13 23:02 UTC
Read the original article Hit count: 380

Filed under:
|
|
|
|

I'm trying to consume a hello world AXIS2 SOAP web service using a PHP client. The Java class is written in Netbeans and the AXIS2 aar file is generated using the Netbeans AXIS2 plugin.

You've all seen it before but here's the java class:

public class SOAPHello {    
    public String sayHello(String username) {
        return "Hello, "+username;
    }  
}

The wsdl genereated by AXIS2 seems to wrap all the parameters so that when I consume the service i have to use a crazy PHP script like this:

$client = new SoapClient("http://myhost:8080/axis2/services/SOAPHello?wsdl");
$parameters["username"] = "Dave";
$response = $client->sayHello($parameters)->return;
echo $response."!";

When all I really want to do is

   echo $client->sayHello("Dave")."!";

My question is two-fold: why is this happening? and what can I do to stop it? :)

Here's are the types, message and porttype sections of the generated wsdl:

<wsdl:types>
   <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://soap.axis2.myhost.co.uk">
      <xs:element name="sayHello">
         <xs:complexType>
            <xs:sequence>
               <xs:element minOccurs="0" name="username" nillable="true" type="xs:string"/>
            </xs:sequence>
         </xs:complexType>
      </xs:element>
      <xs:element name="sayHelloResponse">
         <xs:complexType>
            <xs:sequence>
               <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
            </xs:sequence>
         </xs:complexType>
      </xs:element>
   </xs:schema>
</wsdl:types>

<wsdl:message name="sayHelloRequest">
   <wsdl:part name="parameters" element="ns:sayHello"/>
</wsdl:message>    
<wsdl:message name="sayHelloResponse">
   <wsdl:part name="parameters" element="ns:sayHelloResponse"/>
</wsdl:message>

<wsdl:portType name="SOAPHelloPortType">
   <wsdl:operation name="sayHello">
      <wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello"/>
      <wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse"/>
   </wsdl:operation>
</wsdl:portType>

© Stack Overflow or respective owner

Related posts about php

Related posts about web-services