File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Xml document as a SOAP payload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Xml document as a SOAP payload" Watch "Xml document as a SOAP payload" New topic

Xml document as a SOAP payload

Suhas Joshi

Joined: Nov 16, 2008
Posts: 2
I'm presently working on a web services implementation in which it is required that the Client must send a xml document as the request payload. I'm using the SOAP UI to send the request and get the response. How to include the xml file in the SOAP request? What should be the parameter type in the service method?
The response payload is also an xml.
Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
In WSDL the presence of a generic XML document is flagged with the "xsd:anyType" (Mapping XML document to xsd:anyType) or "xsd:any". Under JAX-RPC 1.1 "xsd:any" automatically maps to javax.xml.soap.SOAPElement from which you can extract your org.w3c.dom.Document (which is a org.w3c.dom.Node) for incoming XML. For outgoing XML you simply populate the javax.xml.soap.SOAPElement parameter/return value with your org.w3c.dom.Document.

JAX-WS 2.0 maps "xsd:any" and "xsd:anyType" to org.w3c.dom.Element rather than javax.xml.soap.SOAPElement. (See: Realizing Strategies for Document-Based Web Services With JAX-WS 2.0: Part 3 in a Series)

Tip: xsd:any: A cautionary tale
I agree. Here's the link:
subject: Xml document as a SOAP payload
It's not a secret anymore!