3 Replies Latest reply on Jan 20, 2006 2:15 PM by YCS WYW

    JSR181 + EJB3 (build: CVSTag=HEAD date=200601151019)

    YCS WYW Newbie

      Hello,

      I'm getting an incorrect WSDL for a WebService implemeted as EJB3+JSR181 annotations, when methods return complex type arrays.
      It is a bug on my code? or it is a Jboss' one?
      (I haven't found an open bug on JIRA for this subject, so should it be opened/reopened?):


      This is a sample implementation of a WebService (EJB3+JSR181) with the same problem:

      package myEJB3;
      
      import java.util.List;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.Query;
      import javax.persistence.PersistenceContext;
      
      import javax.jws.WebService;
      import javax.jws.WebMethod;
      import javax.jws.soap.SOAPBinding;
      
      
      @WebService(name = "MySessionBean", targetNamespace = "http://localhost:8080/webservices/types", serviceName = "MySessionService")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      @Remote(MySession.class)
      @Stateless
      public class MySessionBean implements MySession
      {
       @PersistenceContext(unitName="myPU")
       private EntityManager manager;
      
       @WebMethod
       public MyEntity[] findAll()
       {
       Query query = manager.createQuery("SELECT OBJECT(e) FROM MyEntity e");
       List<MyEntity> entities = query.getResultList();
       MyEntity retval[] = new MyEntity[entities.size()];
       return entities.toArray(retval);
       }
      
       @WebMethod
       public MyEntity findByPrimaryKey(int pk)
       {
       return manager.find(MyEntity.class, pk);
       }
      
      }
      
      



      Sample interface of my session EJB3:

      package myEJB3;
      
      import javax.ejb.Remote;
      import javax.jws.WebService;
      import javax.jws.WebMethod;
      import javax.jws.soap.SOAPBinding;
      
      
      @Remote
      public interface MySession
      {
       MyEntity[] findAll();
       MyEntity findByPrimaryKey(int pk);
      
      }
      




      And this is a sample for the not so complex type (entity bean):

      package myEJB3;
      
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      
      
      @Entity()
      public class MyEntity implements java.io.Serializable
      {
       Integer id;
       String name;
      
       @Id
       @Column(name = "ID")
       public Integer getId()
       {
       return id;
       }
      
       public void setId(Integer id)
       {
       this.id = id;
       }
      
      
       @Column(name = "NAME", nullable = false, length = 50)
       public String getName()
       {
       return name;
       }
      
       public void setName(String str)
       {
       name = str;
       }
      
      }
      



      Also, this is a sample "persistence.xml" (for the previous "myPU" persistence unit):

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence-unit name="myPU" transaction-type="JTA">
      <jta-data-source>java:/DefaultDS</jta-data-source>




      </persistence-unit>



      Then, I deploy the previous code as a "jar" module ("myWS.jar"), and obtain the incorrect WSDL code from "http://localhost:8080/myWS/MySessionBean?wsdl", where there is an incorrect definition of MyEntity complex type (as if it were an array), and an incorrect definition of the "findAll" response message (as if it were only returning a simple instance, instead of an array of MyEntity objects).


      <definitions name='MySessionService' targetNamespace='http://localhost:8080/webservices/types' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://localhost:8080/webservices/types' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
      
       <types>
      
       <schema elementFormDefault='qualified' targetNamespace='http://localhost:8080/webservices/types' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://localhost:8080/webservices/types' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
      
      
       <complexType name='MyEntity'>
      
      
       <sequence>
      
      
       <element maxOccurs='unbounded' minOccurs='0' name='value' nillable='true' type='tns:MyEntity'/>
      
      
       </sequence>
      
      
       </complexType>
      
      
       </schema>
      
       </types>
      
       <message name='MySessionBean_findByPrimaryKeyResponse'>
      
       <part name='result' type='tns:MyEntity'/>
      
       </message>
      
       <message name='MySessionBean_findAll'>
       </message>
      
       <message name='MySessionBean_findByPrimaryKey'>
      
       <part name='int_1' type='xsd:int'/>
      
       </message>
      
       <message name='MySessionBean_findAllResponse'>
      
       <part name='result' type='tns:MyEntity'/>
      
       </message>
      
       <portType name='MySessionBean'>
      
       <operation name='findAll'>
      
       <input message='tns:MySessionBean_findAll'/>
      
       <output message='tns:MySessionBean_findAllResponse'/>
      
       </operation>
      
       <operation name='findByPrimaryKey' parameterOrder='int_1'>
      
       <input message='tns:MySessionBean_findByPrimaryKey'/>
      
       <output message='tns:MySessionBean_findByPrimaryKeyResponse'/>
      
       </operation>
      
       </portType>
      
       <binding name='MySessionBeanBinding' type='tns:MySessionBean'>
      
       <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
      
       <operation name='findAll'>
      
       <soap:operation soapAction=''/>
      
       <input>
      
       <soap:body namespace='http://localhost:8080/webservices/types' use='literal'/>
      
       </input>
      
       <output>
      
       <soap:body namespace='http://localhost:8080/webservices/types' use='literal'/>
      
       </output>
      
       </operation>
      
       <operation name='findByPrimaryKey'>
      
       <soap:operation soapAction=''/>
      
       <input>
      
       <soap:body namespace='http://localhost:8080/webservices/types' use='literal'/>
      
       </input>
      
       <output>
      
       <soap:body namespace='http://localhost:8080/webservices/types' use='literal'/>
      
       </output>
      
       </operation>
      
       </binding>
      
       <service name='MySessionService'>
      
       <port binding='tns:MySessionBeanBinding' name='MySessionBeanPort'>
      
       <soap:address location='http://k7:8080/myWS/MySessionBean'/>
      
       </port>
      
       </service>
      
      </definitions>
      



      Should I deploy the corresponding "jaxrpc-mapping.xml"?
      (or it is automatically generated by "jboss" deployer?).

      Thanks in advance.