You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michael Hudson <mi...@slac.com> on 2002/10/08 21:12:41 UTC

Message class bug? Sending/Receiving XML documents

I don't know if this has been fixed in the recent official version, but
the following constructor for the Message class worked in RC1, but not in
RC2:

Message ( java.lang.Object , boolean )

I have code that put a org.w3c.dom.Document file into a InputStream and
sent it to this constructor, while the boolean value was true (thus
declaring that the first value was an InputStream AND carried only the
body of the message, not the envelope).  I was then able to do a
setRequestMessage with this Message object on an instance of a Call
object.  After calling invoke(), I essentially was able to send a Document
object to the web service that met the Document method signature as
advertised in Apache's user guide.

However, now in RC2 (as opposed to RC1)... it says the body is null, as if
the InputStream isn't being read into the SOAP message. The code I'm using
looks something like this:

call.setRequestMessage(new Message(xmlInputStream, true));
call.getMessageContext().getMessage().writeTo(new ByteOutputStream());
call.invoke();

where xmlInputStream is a java.io.InputStream carrying a
org.w3c.dom.Document.  And the 2nd line is a hack that was needed to force
Axis to create the SOAP Envelope and Body.
Anybody know why this doesn't work now in RC2?


In any case, I do have a workaround... this is essentially how I do the
Document to Document message service thing with Axis:


SOAPBodyElement soapBody = new SOAPBodyElement (
					xmlMessage.getDocumentElement () );
soapBody.setNamespaceURI ("foo");
call.invoke ( new Object[] { soapBody } );
Document xmlResponse =
	call.getResponseMessage().getSOAPEnvelope().getFirstBody().getAsDocument();


where xmlMessage is a org.w3c.dom.Document object.


Thanks,

==============================================================================
Michael J. Hudson    |                               |        mike@slac.com

                "Search for the perfect church, if you will;
 		       when you find it, join it, and
       realize that on that day it becomes something less than perfect."
 -Rev. Andrew Greeley responding to the moral crisis in the Catholic church.

                     |                               |
==============================================================================