• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need of the Holder class in Web service?

 
Rahul Ba
Ranch Hand
Posts: 206
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have posted same question on sun forum, but did not get the response from the users. Hence posting here...

Here is my Question.

I read many articles regarding Holder class in Java....but still does not getting what is the use of that. In one article I saw Order as a object which has properties OrderId, OrderDate. They put Holder class as OrderHolder.java

I read one sentense as Holder classes enable the mapping to preserve the intended WSDL signature and parameter-passing semantics.

I am not getting this sentense. How it (OrederHolder class) preserves the order in intended WSDL signature?

Please explain me.

Thanks,
Rahul
 
Peer Reynders
Bartender
Posts: 2933
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume that you are referring to this article: Developing JAX-RPC-based Web Services

"Holder classes enable the mapping to preserve the intended WSDL signature and parameter-passing semantics."

Look just above:

Rajesh Sumra wrote:
OUT type: An OUT parameter is passed as copy without any input value to the Web service method. The Web service method fills the OUT parameter and returns it to the client.
INOUT type: An INOUT parameter is passed as copy with an input value to the Web service method. The Web service method uses the input value, processes it, fills the INOUT parameter with a new value, and returns it to the client.


Java-based example:


In pure Java "result" will be "false" because "myNumber" still references "Integer(10)". However if "webMethod" was a web service operation then according to WSDL parameter rules "myNumber" should be referencing an "Integer(99)" instance (and "result" should be "true") as OUT or (modified) INOUT parameters are copied back (which never happens in pure Java).

So in Java this behavior is faked by using "Holder" objects.

Now in Java the "result" will be "true" - because it can copy back the value/reference assigned in the method.

JAX-WS uses the Generic javax.xml.ws.Holder<T> for the same purpose (so you would be using javax.xml.ws.Holder<Integer> instead of javax.xml.rpc.holders.IntegerWrapperHolder).

So
{WSDL}: void webMethod(Integer [IN] num) becomes {Java}: void webMethod(Integer num)
{WSDL}: void webMethod(Integer [OUT] num) becomes {Java}: void webMethod(Holder<Integer> numHolder)
{WSDL}: void webMethod(Integer [INOUT] num) becomes {Java}: void webMethod(Holder<Integer> numHolder)


See also: what where they thinking with Holder?!?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic