• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JAXB ObjectFactory to create an empty xml tag example

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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!
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic