axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trebor iksrazal <>
Subject Re: Problem with RPC attachment
Date Thu, 04 Dec 2003 12:55:17 GMT

<> wrote:
> Hi folks,
> I have been facing a problem while using soap RPC
> attachment. Let me
> summarize as follows:
> 1) Create a header
> 2) Create a body that contains information about an
> operation. The operation
> or method takes javax.activation.DataHandler as an
> input
> 3) Create envelope by combining header and body
> 4) Create a document from the envelope [Later, I
> will sign this document and
> send the signed XML for invoking secured
> webservices]
> I am able to succeed until step3. While I try to
> create the document object
> at step 4, I am getting DataHandler serializer
> error. The error description
> is as follows:

There's two ways that I convert SOAPMessage to
Document - with and without serializattion. Without
serialization requires a SOAPPart that implements
Document - available in CVS. Actually I'm also doing
XML signatures - doing the header part elsewhere. 

The code below is nicked from . 

This is how I do it with Serialization:

private static class MyByteArrayOutputStream extends
ByteArrayOutputStream {
		public MyByteArrayOutputStream(){
		public ByteArrayInputStream
			return new ByteArrayInputStream(buf, 0, count);

public static Document toDocument(SOAPMessage soapMsg)
				ParserConfigurationException, SAXException,
SOAPException, IOException {
		MyByteArrayOutputStream baos = new
		ByteArrayInputStream bais =

      	DocumentBuilderFactory dbf =
		DocumentBuilder db = dbf.newDocumentBuilder();
		Document doc = db.parse(bais);
		return doc;

Without Serialization. I had some problems here with
encryption, which I posted on this list a few days
ago. This assumes that everything just works:

public static Document toDocument(SOAPMessage soapMsg)
TransformerException, SOAPException, IOException {
		Source src = soapMsg.getSOAPPart().getContent();
		TransformerFactory tf =
		Transformer transformer = tf.newTransformer();
		DOMResult result = new DOMResult();
		transformer.transform(src, result);
		return (Document)result.getNode();

Hope that helps,

Do you Yahoo!?
Free Pop-Up Blocker - Get it now

View raw message