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 Need of the Holder class in Web service?  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Need of the Holder class in Web service?  " Watch "Need of the Holder class in Web service?  " New topic
Author

Need of the Holder class in Web service?

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205

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

Joined: Aug 19, 2005
Posts: 2922
    
    5
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?!?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need of the Holder class in Web service?