0 Replies Latest reply on Aug 25, 2008 2:00 AM by Nandan Tiwari

    Error passing Complex Types as parameters in Web Service

    Nandan Tiwari Newbie

      Hi,

      I have created a simple Hello World Web Service.
      I have created a POJO HelloParam
      The method exposed in the web service "sayHello" takes HelloParam object as parameter.
      The WSDL is generated and is deployed successfully over JBoss.
      But when I run the client, I get the following error:

      Exception in thread "main" org.jboss.ws.WSException: Cannot obtain java type mapping for: {http://ejb3webservice.wipro.com/}helloParam

      Following are the classes that I have created:

      package com.wipro.ejb3webservice;
      
      import java.io.Serializable;
      
      public class HelloParam implements Serializable{
       /**
       *
       */
       private static final long serialVersionUID = 5446103626304202057L;
       String firstName;
       String lastName;
      
       /**
       * @return the firstName
       */
       public String getFirstName() {
       return firstName;
       }
       /**
       * @param firstName the firstName to set
       */
       public void setFirstName(String firstName) {
       this.firstName = firstName;
       }
       /**
       * @return the lastName
       */
       public String getLastName() {
       return lastName;
       }
       /**
       * @param lastName the lastName to set
       */
       public void setLastName(String lastName) {
       this.lastName = lastName;
       }
       /**
       * @param firstName
       * @param lastName
       */
       public HelloParam(String firstName, String lastName) {
       super();
       this.firstName = firstName;
       this.lastName = lastName;
       }
       /**
       *
       */
       public HelloParam() {
      
       }
      }
      


      The interface that is exposed as webservice is :

      package com.wipro.ejb3webservice;
      
      import java.rmi.Remote;
      
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      
      
      @WebService
      @SOAPBinding(style = Style.RPC)
      public interface HelloWorld extends Remote {
       public void sayHello(HelloParam helloParam);
      }


      And the implementation of the interfaces is:

      package com.wipro.ejb3webservice;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebService;
      
      
      @Stateless
      @Remote(HelloWorld.class)
      @WebService(name="HelloWorldName" ,serviceName="HelloWorldImplService",endpointInterface = "com.wipro.ejb3webservice.HelloWorld")
      public class HelloWorldImpl implements HelloWorld {
      
       @WebMethod
       public void sayHello(
       @WebParam(name="helloParam" )
       HelloParam helloParam)
       {
       System.out.println("first name" + helloParam.getFirstName()+"last name--"+ helloParam.getLastName());
      
       }
      }



      The WSDL file genereated is:

      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="HelloWorldImplService" targetNamespace="http://ejb3webservice.wipro.com/" xmlns:tns="http://ejb3webservice.wipro.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
       <types>
       <xs:schema targetNamespace="http://ejb3webservice.wipro.com/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:complexType name="helloParam">
       <xs:sequence>
       <xs:element minOccurs="0" name="firstName" type="xs:string"/>
       <xs:element minOccurs="0" name="lastName" type="xs:string"/>
       </xs:sequence>
       </xs:complexType>
       </xs:schema>
       </types>
       <message name="HelloWorld_sayHelloResponse">
       </message>
       <message name="HelloWorld_sayHello">
       <part name="arg0" type="tns:helloParam">
       </part>
       </message>
       <portType name="HelloWorld">
       <operation name="sayHello" parameterOrder="arg0">
       <input message="tns:HelloWorld_sayHello">
       </input>
       <output message="tns:HelloWorld_sayHelloResponse">
       </output>
       </operation>
       </portType>
       <binding name="HelloWorldBinding" type="tns:HelloWorld">
       <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="sayHello">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://ejb3webservice.wipro.com/"/>
       </input>
       <output>
       <soap:body use="literal" namespace="http://ejb3webservice.wipro.com/"/>
       </output>
       </operation>
       </binding>
       <service name="HelloWorldImplService">
       <port name="HelloWorldNamePort" binding="tns:HelloWorldBinding">
       <soap:address location="http://localhost:8080/Ejb3Webservice/HelloWorldImpl"/>
       </port>
       </service>
      </definitions>
      


      Can any one help me on this issue.
      Its very urgent.

      Thanks and Regards
      -Nandan