-
I’ve got the WSDL for a SOAP web service
-
I created a “Top down, Java Bean” web service client in RAD Developer (an Eclipse based compiler used with IBM Websphere) and auto-generated a bunch of JAX-WS .java modules
-
Here is the auto-generated JAX-WS code for one of the operations:
@WebMethod(operationName = "CommitTransaction", action = "http://myuri.com/wsdl/gitsearchservice/CommitTransaction")
@RequestWrapper(localName = "CommitTransaction", targetNamespace = "http://myuri.com/wsdl/gitsearchservice", className = "com.myuri.shwsclients.CommitTransaction")
@ResponseWrapper(localName = "CommitTransactionResponse", targetNamespace = "http://myuri.com/wsdl/gitsearchservice", className = "com.myuri.shwsclients.CommitTransactionResponse")
public void commitTransaction(
@WebParam(name = "requestOptions", targetNamespace = "http://myuri.com/wsdl/gitsearchservice")
RequestOptions requestOptions,
@WebParam(name = "transactionData", targetNamespace = "http://myuri.com/wsdl/gitsearchservice")
TransactionData transactionData);
QUESTION:
-
“transactionData” comes from a large, complex XML data record. The WSDL format exactly matches the XML I’ll be writing on the Java side, and exactly matches what the Web service will be reading on the server side.
-
Q: How do I bypass Java serialization for the “transactionData” parameter, to send raw XML in my SOAP message? Instead of having to read my XML, parse it, and pack the Java “TransactionType” structure field-by-field?
Thank you in advance!
I see two approaches:
complicated, and will fall apart as soon as any generated code is re-genereated…
Dig into the Service, Dispatch, and BindingProvider implementations that are created in your generated service Proxy class — you can get the behavior you want by substituting your own BindingProvider implementation, but you have to make other substitutions to get there.
go through XML serializtion, but without the hassle of “packing field by field”
starting with your string of raw XML that you say “exactly matches” the expected format
if the jaxb generated class ‘TransactionData’ class is not annotated as ‘XmlRootElement’ then you should still be able to accomplish this like so:
If you deal with a lot of XML records of various types, you can throw these together, and make the desired output class a parameter and have a generic xml-to-object utility: