0 Replies Latest reply on Dec 7, 2009 3:43 AM by freakwave10

    EJB3 web service

    freakwave10

      Hi all,

      I have a question in regards to designing web services with EJB3.
      One part of our application is to load data into the App, e.g. Person, Groups and Organizations via CRUD operation.

      So we would have something like a createPerson operation.
      To simplify things, it would be very nice to have a method like this:

      @WebMethod
       @Begin
       public ServiceCallResult createPersonAlt(Person person) {
       // TODO Auto-generated method stub
      




      The Person Object here is a Entity bean.
      The WSDL schema generated is a very complex one since it contains all the person relationships. This is not very user friendly for somebody how needs to use the exposed service.
      I think a better service would be to provide something like:

      @WebMethod
       @Begin
       public ServiceCallResult createPerson(@WebParam(name = "firstname") String firstname,
       @WebParam(name = "lastname") String lastname, @WebParam(name = "groupName") List<String> groupNames) {
       // TODO Auto-generated method stub





      So here the WSDL schema is much more straight forward and understandable, but it becomes quite combersome to extend in case we want to add attributes to the Person.

      So here are my options I figured out myself, but don't know if these are viable solutions:

      1) Use Entity Beans as Web Service parameters and customize WSDL to not expose complex associations
      2) Use custom web service methods for maximum user friendliness
      3) Create another layer of Pojo's e.g. PersonWS that only contains attributes that should be exposed in Web Service API.

      Perhaps I am totally on the wrong track here, but any suggestions are highly welcome.

      Also in regards to the return value. I created a ServiceCallResult class that contains return code, and return message. This works very well, but
      for the above scenario, it would be very nice to also contain the ID that was generated for the person.
      I looked in the OUT paramters of WebServices which I generally like very much, but I think the support for OUT parameters is very limited when you look into client implementations. Many clients seem not to be able to understand this concept.
      So I guess I extend the ServiceCallResult and have a PersonServiceCallResult, GroupServiceCallResult ... as return types.

      Again, any suggestion very welcome.

      Kind regards,

      Wolfgang