axis-java-dev mailing list archives

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

--- "GANDHIRAJAN,AYYAPPAN (HP-India,ex2)"
<ayyappan.gandhirajan@hp.com> 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 www.j2ee-security.net . 

This is how I do it with Serialization:

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

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

      	DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		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)
throws
				TransformerConfigurationException,
TransformerException, SOAPException, IOException {
		Source src = soapMsg.getSOAPPart().getContent();
		TransformerFactory tf =
TransformerFactory.newInstance();
		Transformer transformer = tf.newTransformer();
		DOMResult result = new DOMResult();
		transformer.transform(src, result);
		return (Document)result.getNode();
	}

Hope that helps,
iksraal

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

Mime
View raw message