File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes JAXB vc JAX-RPC mapping files Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "JAXB vc JAX-RPC mapping files" Watch "JAXB vc JAX-RPC mapping files" New topic
Author

JAXB vc JAX-RPC mapping files

S Kapoor
Greenhorn

Joined: Mar 31, 2006
Posts: 20
I am a bit confused about when to use JAXB vs when to use the mapping files for JAX-RPC.
The blueprints book refers to the mapping files only in context of a J2EE client and refers to JAXB in the context of parsing xml.
What is the difference??
Thanks in advance.
[ March 31, 2006: Message edited by: S Kapoor ]

SCJP, SCJWS, SCWCD
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
JAX-RPC Mapping files help the WSDL2Java conversion map the XML fragments within the SOAP message payload to some custom classes (btw. Axis doesn't support mapping files). This would usually be used with a RPC-style web service.

JAXB would be used in a document-based Web service. In this case the generated endpoint code does not convert the incoming SOAP payload to Java objects. Based on what the service finds in the XML document it may decide to convert the entire document or part of it to Java objects using JAXB.

It seems that JWSDP 2.0 is relying heavily on JAXB for some of its internal processing (i.e. the XML2Java and Java2XML conversions).

In Core J2EE Patterns, 2nd Edition one strategy (Java Binder Strategy p.560) uses Servlets & JAXB to implement a (non-SOAP) Web Service Broker.


"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
S Kapoor
Greenhorn

Joined: Mar 31, 2006
Posts: 20
Thanks for the reply.

However since wsdl types could be imported from an external schema, couldnt JAXB be used in case of rpc-type services also?

When you said 'generated endpoint code' do you mean the client code?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Originally posted by S Kapoor:
However since wsdl types could be imported from an external schema, couldnt JAXB be used in case of rpc-type services also?
When you said 'generated endpoint code' do you mean the client code?

Java2WSDL and WSDL2Java style tools are capable of generating both client stubs and server endpoint skeletons. With RPC-style modes the Java data-types are usually already mapped to and from XML in that generated code, unless the XML is passed as a string or javax.xml.soap.SOAPElement. Internally in JWSDP 2.0 this mapping is apparently done with JAXB. However generally there is little reason with an RPC-style Web service to use JAXB.
For a document-style Web service the XML document still has to be mapped after (or before) the generated code is done with it - that's where JAXB can be used in Web services.
4.5.2 Use the Most Appropriate API
3.7 Handling XML Documents in a Web Service
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JAXB vc JAX-RPC mapping files
 
Similar Threads
Mark Hansen - JWS, JEE 6
How to use wstools in ant
Webservices made easier ?
XSD Compliance with WebService and JAXB
JAX-RPC2.0 become JAX-WS