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 ObjectFactory to create an empty xml tag example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAXB ObjectFactory to create an empty xml tag example" Watch "JAXB ObjectFactory to create an empty xml tag example" New topic
Author

JAXB ObjectFactory to create an empty xml tag example

Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
I'm calling a web service inside my java program using the JAX-RPC generated artifacts. I want to remove value of a Date field. It accepts a Calendar object and I tried to pass it null as below but no luck

setStartDate(null)

When I use SoapUI, I only need to pass it an empty tag as below

<StartDate></StartDate>

and it worked fine but I don't know how to do it in java.

I've heard you can use the ObjectFactory of JAXB to do this but I have no clue on how to do it. Can you help me please?

Thanks
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
What is the result if you supply null as the date parameter?
The problem with generated artifacts, be it JAX-WS or JAX-RPC, is that they help you construct the XML of the request message to be sent to the service.
You have no control over the actual XML generation, except for the parameters you pass in to the generated code.
To obtain a greater degree of influence over the XML generation, you should use a more low-level approach to send XML requests. In JAX-WS you would obtain an object that implements the Dispatch interface. I do not do JAX-RPC, but I think the name of the interface is the same.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
When I passed in Null to the Date object, the value was not changed so I guess the Date xml tag was removed from the payload so it's not being sent over.

I couldn't find any Dispatch interface for JAX-RPC. I only found Call. Is that correct?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Ong Vua wrote:
I couldn't find any Dispatch interface for JAX-RPC. I only found Call. Is that correct?

Yes, Call is the JAX-RPC equivalent to the Dispatch interface.
Here is an article that shows how to use it, in case you have any doubts: http://www.ibm.com/developerworks/webservices/library/ws-javaclient/
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB ObjectFactory to create an empty xml tag example
 
Similar Threads
jaxb external customization with WSDL (and imported WSDL)
Problems with JAXB-generated javadoc code
unable to generate correct xml using jaxb
what is empty tag?
Passing Set<java.lang.Object> and List<java.lang.Object> in Axis 2.0