• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JAX-WS Question

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello to all,

i have a couple of question regarding JAX-WS.


1. What is the functionality of object Factory generated using wsimport ? How does it relate to web service architecture ?

2. I have web service Service endpoint implementation class written by me with the method signature like this :



The parameter for the Custorder is derived from database where the package is Entity.Custorder but when i used the wsimport to generate the JAXB Mapped class, it has different type which is ServiceClient.Custorder.

On top of that, I drag and drop the service client invocation using netbeans IDE and with this method signature.



As far as i know, the @WebParam annotation is used to automatically convert the SOAP message to java object. Therefore, I wonder which one (ServiceClient.Custorder or Entity.Custorder) to use in the service endpoint implementation signature.

If i use the ServiceClient.Custorder (JAXB generated), then how to convert to Entity.Custorder (JPA generated) ?

From my experience, i have developed RESTFul web service with entity class which can convert to xml and mapped to database table. Previous, i using @XMLRootElement and @Entity

How to implement a POJO which can convert to XML and database entity in JAX-WS ?

3. How to relate the annotation in Java to wsdl standard ? Any tutorial that explain wsdl elements with Java annotation mapping ?

4. How does this createOrder.java generated using wsimport related to SOAP message ?



5. What is client invocation flow to web service endpoint (service endpoint implementation) for JAX-WS web service ?

6. As far as i know, there are couples of methods to invoke web service implementation.
1. Stubs code

Extends service class
The @WebServiceReference is used to find the web service using UDDI.
Used service.getServicePort proxy to call the interface exposed by Service endpoint implementation. Is this correct and any other explanation ?

2. Proxy
3. JAX-WS Dispatch API

What is the difference between all these ? How does this relate to the web service architecture ?

Please help me.

Thanks.
 
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

peter wong ka chon wrote:1. What is the functionality of object Factory generated using wsimport ? How does it relate to web service architecture ?


The object factory/factories are JAXB object factories generated by XJC, which in turn is invoked by wsimport in one way or another.
Usually, you do not need to use these classes when using client stubs.
Best wishes!
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:
The object factory/factories are JAXB object factories generated by XJC, which in turn is invoked by wsimport in one way or another.
Usually, you do not need to use these classes when using client stubs.
Best wishes!



What is the functionality of this JAXB object factory ? Is it instantiated the request/response wrapper bean ?
When do need to use this class directly besides client stubs approach ?

Please answers my rest of question.

Thanks.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

peter wong ka chon wrote:
What is the functionality of this JAXB object factory ? Is it instantiated the request/response wrapper bean ?
When do need to use this class directly besides client stubs approach ?


If you want to use JAXB to transform a Java object structure to XML data, then you would use the object factory directly, creating instances of JAXB beans in which you then insert data.
If you want to know about the functionality of the object factory I suggest you open such a generated class up and have a look! :-)
Yes, the request/response beans are usually JAXB beans and thus the object factory can create such instances.
Best wishes!
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:
If you want to use JAXB to transform a Java object structure to XML data, then you would use the object factory directly, creating instances of JAXB beans in which you then insert data.
If you want to know about the functionality of the object factory I suggest you open such a generated class up and have a look! :-)
Yes, the request/response beans are usually JAXB beans and thus the object factory can create such instances.
Best wishes!



I got it. Can you enlighten me on the question two ? Thanks for the reply.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
The way I would use to transfer data from a JAXB bean to an entity (and vice versa) is to write code - a kind of transformer, if you wish.
The transformer calls a getter method on, for instance, a JAXB bean and then a setter method on the entity object.
Best wishes!
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:Hi!
The way I would use to transfer data from a JAXB bean to an entity (and vice versa) is to write code - a kind of transformer, if you wish.
The transformer calls a getter method on, for instance, a JAXB bean and then a setter method on the entity object.
Best wishes!




As far as i know, when i was working with RestFul web services, there is an entity class which used by the JAXB to transfer to xml automatically and there is a JSON mapping feature from Jersey which used to construct the java object in Json format.


Therefore, i see no point (not convenient) to separate two data interface format
1. One for database
2. One for JAXB bean

Is there any alternative approach for this problem ?

Appreciate your help on this question.

Thanks for your input.

 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My theory solution to the question 2 is :

Merge the JAXB Bean class with entity persistence class and did some customization the wsimport process to avoid the regenerate the JAXB Bean class with default JAXB solution without entity class.

Thanks.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
My experience tells me that the database representation may change independently of the data transferred by the web service and vice versa.
When I have tried to avoid additional work, merging these two things into one, it has often caused even more work later on.
However, the system you are developing may be different from the ones I have developed, so your suggestion may be more appropriate in your case.
Best wishes!
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:Hi!
My experience tells me that the database representation may change independently of the data transferred by the web service and vice versa.
When I have tried to avoid additional work, merging these two things into one, it has often caused even more work later on.
However, the system you are developing may be different from the ones I have developed, so your suggestion may be more appropriate in your case.
Best wishes!

a


I understand your theory but how to transfer the data from xml representation to database representation.

I have two interfaces separated right now which one for database persistence purpose and one for XML representation purpose.

Thanks.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
You have two interfaces - excellent!
Then just implement two different classes (for example A and B); each class implement one of the interfaces you have.
Then you write some "transformer" code that retrieves data from an instance of A and inserts the data into an instance of B and/or vice versa.
When data is received by the web service, the transformer is supplied an instance of the class containing the incoming data (for example A) and produces an instance of the other class (for example B) which then is used to persist the data. The procedure is reversed if data that is retrieved from the database is to be sent to a client in a response to a request.
Hope this was able to convey my ideas - if not do not hesitate to ask!
Best wishes!
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just realized that the Web Service Client and Web Service has two different method signatures which are

There are no inherits from single hierarchy.

Please help me to solve this problem.

Thanks.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
So you have two different representations of the same concept (Order) in your domain model?
This is something of a drawback - if the two order types are fundamentally different, then perhaps two different entities, with different names, may be warranted.
If the client and server is to share the Order entity, then containing it in some kind of shared library may be a good idea.
You will need to write code that re-packages data received in a JAXB-generated bean (assuming you use this) to be contained in an instance of the Order entity class from the common library. The reverse procedure, taking data from an Order entity and inserting it into a JAXB-generated bean, will be necessary if your code is to send out representations of Order entities.
Best wishes!
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:Hi!
So you have two different representations of the same concept (Order) in your domain model?
This is something of a drawback - if the two order types are fundamentally different, then perhaps two different entities, with different names, may be warranted.
If the client and server is to share the Order entity, then containing it in some kind of shared library may be a good idea.
You will need to write code that re-packages data received in a JAXB-generated bean (assuming you use this) to be contained in an instance of the Order entity class from the common library. The reverse procedure, taking data from an Order entity and inserting it into a JAXB-generated bean, will be necessary if your code is to send out representations of Order entities.
Best wishes!



I think i need to rewrite the Web Service Server to accept ServiceClient.Order then i will convert to Order Entity. This is just a theory. Thanks by the way.

I got a question from here
http://stackoverflow.com/questions/7281913/import-war-to-another-project-in-netbeans

Thanks.
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

peter wong ka chon wrote:

Ivan Krizsan wrote:Hi!
So you have two different representations of the same concept (Order) in your domain model?
This is something of a drawback - if the two order types are fundamentally different, then perhaps two different entities, with different names, may be warranted.
If the client and server is to share the Order entity, then containing it in some kind of shared library may be a good idea.
You will need to write code that re-packages data received in a JAXB-generated bean (assuming you use this) to be contained in an instance of the Order entity class from the common library. The reverse procedure, taking data from an Order entity and inserting it into a JAXB-generated bean, will be necessary if your code is to send out representations of Order entities.
Best wishes!



I think i need to rewrite the Web Service Server to accept ServiceClient.Order then i will convert to Order Entity when persist to database. This is just a theory. Thanks by the way.

I got a question from here
http://stackoverflow.com/questions/7281913/import-war-to-another-project-in-netbeans

Thanks.

 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

peter wong ka chon wrote:
I think i need to rewrite the Web Service Server to accept ServiceClient.Order then i will convert to Order Entity. This is just a theory.


Well, give it a try then!
Don't forget to report back on your experiences and what you learned in the process!
Best wishes!
 
reply
    Bookmark Topic Watch Topic
  • New Topic