In/out and Multiple Out Parameters

WSDL

In certain RPC situations, WSDL can specify message parts that appear on both the input message and output message; these translate to in/out parameters. Further, WSDL can specify an output message with more than one part. In/out and multipart output messages pose an interesting problem for translating WSDL to Java.

The operation named op1 has a message part named inout1 appearing in both the input message and output message. Further, you will notice that the output message of the operation has three output parts: the inout1 part, and two parts that appear only in the output message, out1 and out2.

How is it possible in Java to have a parameter that is both on the input and the output,or to have multiple output values? This is where the holder classes come in.
As we have seen, Axis WSDL tooling generates holder classes for each of the input,output, and in/out parameters. The classes generated when this WSDL file was processed included InHolder.Java, InOutHolder.Java, and OutHolder.Java. These holder classes are simple: They contain a value of the given underlying type and provide a simple constructor.

Note the way the target Web service is dispatched. Holder objects are created for the in/out and the second out parameter and passed to the implementation. The implementation then puts a value in the Out2Holder object passed and potentially modifies the value in the InoutHolder that is passed. All three values are passed back to the requestor as RPCParams.

This is a simple program that takes the input value and increments the in/out value by that amount. Further, it returns in one output parameter the product of the in and the original in/out value, and in the "real" output of the message, returns the sum of the newly incremented in/out value and the other output parameter. It is a useless function, but it illustrates the in/out and multiple out situations in a simple fashion.

This program produces the following output SOAP response:HTTP/1.0 200 OK…

Note the way the multiref element is used to contain the holder values back to the requestor. The test program shown in Listing 6.8 then takes these values from the returned holder classes and prints the following out on the screen:

2*3 = 6
2+3 = 5
2*3 + 2+3 = 11

This would have been extremely tricky to do manually, but it was nothing for the Axis WSDL tooling.