dcsimg
C++ -> Java: MessageFactory cannot read a SocketInputStream, but can read a FileInputStream...?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nick_Fenwick
Posted On:   Thursday, March 7, 2002 07:21 AM

Hi there, I am sending SOAP messages from a C++ program (using Microsoft SOAP Toolkit beta 2, MSSOAP1.dll) to a Java program (using JavaTM Web Services Developer Pack EA1, JAXM). I am not using a Servlet and therefore cannot derive from JAXMServlet and use the ReqRespListender.onMessage() interface (which would be soo easy); instead, I am opening sockets manually and trying to pass the incoming byte stream to MessageFactory in order to create a SOAPMessage object. I have been having problems relating to a "Connection reset by peer: JVM_recv in socket input stream read" exception. I can attach a simple Visual Basic listener to my socket and read what looks like a perfectly    More>>

Hi there,



I am sending SOAP messages from a C++ program (using Microsoft SOAP Toolkit beta 2, MSSOAP1.dll) to a Java program

(using JavaTM Web Services Developer Pack EA1, JAXM). I am not using a Servlet and therefore cannot derive from

JAXMServlet and use the ReqRespListender.onMessage() interface (which would be soo easy); instead, I am opening sockets

manually and trying to pass the incoming byte stream to MessageFactory in order to create a SOAPMessage object.



I have been having problems relating to a "Connection reset by peer: JVM_recv in socket input stream read" exception.

I can attach a simple Visual Basic listener to my socket and read what looks like a perfectly valid HTTP POST request

containing a SOAP xml document. However attaching a Java SocketInputStream to the socket and giving that to

MessageFactory.createMessage (after successfully reading the MIMEHeaders object off the start of the stream) throws an

exception when I call SOAPMessage.getEnvelope() on the resulting SOAPMessage object.



I have decided it's a socket problem, because on the receiving end I can pipe the incoming SocketInputStream bytes to

a file, then open that file as a FileInputStream, and pass that input stream to MessageFactory.createMessage(MIMEHeader,

InputStream) and get a valid SOAPMessage object back which supports getEnvelope() calls. However, if I take the original

Socket.getInputStream() input stream and pass that to MessageFactory.createMessage(), I get the following nasty sounding

exception when I call getEnvelope():



			"Unable to get header stream in saveChanges: SOAP exception while trying to externalize:
			
Unable to create envelope from given source: Connection reset by peer: JVM_recv in socket
input stream read Nested exception: Connection reset by peer: JVM_recv in socket input stream read".


So, this throws an exception:

			C++ -> MSSOAP1.dll --Socket--> Java --SocketInputStream--> MessageFactory ->
			

SOAPMessage.getSOAPPart().getEnvelope()

However, this doesn't:

			C++ -> MSSOAP1.dll --Socket--> Java SocketInputStream -> File --FileInputStream--> MessageFactory ->
			

SOAPMessage.getSOAPPart().getEnvelope()



There must be some difference between the SocketInputStream that the Socket.accept().getInputStream() returns and the

FileInputStream that I get when opening a file containing an HTTP SOAP request. The only difference I can see offhand is

that the SocketInputStream.available() method returns 0, presumably because the socket doesn't know how many bytes are

coming in off the socket, while the FileInputStream.available() returns a valid number (the same number as the

"Content-Length" MIME header line says).



I will have to stick for now with my piggy-in-the-middle approach of saving the incoming bytes off the socket to a

file, then opening the file and passing that to MessageFactory. It's far from satisfactory. I'm a bit of a Java newbie

so there must be something to do with InputStreams that I don't understand. One conclusion I've come to is that the

MessageFactory.createMessage(MIMEHeaders, InputStream) call returns a SOAPMessage but does not parse the input stream

immediately. The SOAPMessage object retains a source reference which is seems to try to use when you call

getEnvelope() on the SOAPMessage's SOAPPart i.e.:



			
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage(head, myStream);
SOAPEnvelope env = msg.getSOAPPart().getEnvelope(); // <-- throws here!
}


Any help/advice/comments would be much appreciated.


Nick Fenwick
   <<Less

Re: C++ -&gt; Java: MessageFactory cannot read a SocketInputStream, but can read a FileInputStream...?

Posted By:   Nick_Fenwick  
Posted On:   Thursday, March 7, 2002 07:35 AM

Original author Nick Fenwick here,



I should mention that it's probably not Microsoft's fault. You may think from the chain of events that I describe that it's the socket from MSSOAP1.dll that's at fault. I have also created a simple Java class which reads the valid SOAP message from file and pipes it byte by byte through a socket, and connected that socket's input stream to MessageFactory.createMessage(), only to find exactly the same problem as before. So, it does not appear to matter where the socket is coming from, MessageFactory cannot use the SocketInputStream to parse a SOAP message.



Nick Fenwick
About | Sitemap | Contact