This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am calling a .NET web service from a Java client. I have been able to successfully send string data from the Java client to the .NET web service. When I try to extract the response, I get the following error: "Content is not allowed in prolog". The error is thrown from the following line of code: xmlReader.parse( new InputSource( new StringReader( soapMsg.getContent().toString() ) ) ); This seems to imply that there's something about the SOAP format being sent back that is a problem. My SOAP response is as follows: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <DownloadTablesResponse xmlns="http://SLR.org/"> <DownloadTablesResult>Success</DownloadTablesResult> </DownloadTablesResponse> </soap:Body> </soap:Envelope> Any help would be appreciated. Thanks, Dave
Originally posted by Dave Ehrlich: I am calling a .NET web service from a Java client. Thanks, Dave
Hi Dave, Try to run the below java client code from ur machine which access a web service from ASP.NET and invoke an operation "ADD", I used WSDL2Java utility from apache axis to write this java client code,if that suits your case then u can give a try.BYW the below code is not a good pattern to write java client code.See wsdl2java pattern.
I guess the moderator will soon move this thread to web services
produce the following result from the Windows command (DOS) window: java.io.ByteArrayInputStream@66e815 I don't know if its a problem with how I'm trying to dump the input stream or something else. The strange thing is that TcpTunnelGui shows the SOAP response correctly. Thanks, Dave
Hi Dave, This means that the soapMsg.getContent() returns an InputStream Just read the contents of this input stream into a string. You can use the following method to do so:
This just highlights one more time the risks of using the toString() method [ November 19, 2002: Message edited by: Beno�t d'Oncieu ]
Joined: Nov 12, 2002
Solved!!! Benoit, Although I didn't need your code in the final result, it was crucial in making the breakthrough that determined the correct answer. The original code below won't work because the parser wants a character string:
However, this code works:
It seems that the parser want a character stream and not an input stream. If there are any comments on this, or how it could be done better, please let me know. Thanks, Dave