• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enable auto JAXB bindings OR do JAXB manually

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are considering 2 approaches while exposing web services to internal applications. Please help in deciding the pros and cons of each.

Approach-1 is now standard in which JAXB bindings are applied at both sides (client and server) internally. Client and Server code work on Java objects and not on SOAP XML message directly.

Approach-2 is old way in which JAXB bindings are NOT applied at both sides (client and server) internally. Client constructs SOAP XML message and server receives XML and unmarshall into JAXB object.
 
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!
I would suggest using approach 1 with automated generation of client artifacts in the client's build script. This way all client artifacts, including JAXB binding classes, are created when the build script is run and you do not need to write any code dealing with those parts. If the web service changes significantly, then of course you will have to modify the code using the generated artifacts.

Motivation:
As far as I understand, this will save you time and reduce the amount of code you need to write.
However, there may be circumstances that justify processing of raw XML which I do not know about. Please include more details if you want further analysis.

Special case:
If you want to develop a general, document-based, web service that is to be extensible by, for instance, adding support for processing documents belonging to new namespaces, then the JAXB approach may have limited value.
Best wishes!
 
Nitin Gaur
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Evan,

But I wonder how would I generate the XML just by looking at the schema (if available). I must generate JAXB bindings from WSDL, populate them and then do marshaling to generate the XML SOAP message. Right?

The motivation to process raw XML is to provide uniform processing at server side that defines XML as common input format to integrate through any type of communication medium e.g. SOAP/HTTP or JMS or RMI (rare case)
 
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!

Nitin Gaur wrote:But I wonder how would I generate the XML just by looking at the schema (if available). I must generate JAXB bindings from WSDL, populate them and then do marshaling to generate the XML SOAP message. Right?


Well, you can write code that expects certain XML data using, for instance, the SAAJ API. This is of course much more work than using JAXB, but it is still an available option.


The motivation to process raw XML is to provide uniform processing at server side that defines XML as common input format to integrate through any type of communication medium e.g. SOAP/HTTP or JMS or RMI (rare case)


Well again, what is stopping you from using JAXB independent of the transport medium?
If you use the XJC JAXB schema compiler, generating JAXB classes, then you can write your own code that uses these JAXB classes, regardless of whether the XML data is received over HTTP, JMS, RMI or even in an email.
Of course you can still use the JAXB classes generated by wsimport in your own code.
Best wishes!
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic