• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB ObjectFactory to create an empty xml tag example

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic