This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes SaxParseException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SaxParseException" Watch "SaxParseException" New topic
Author

SaxParseException

Dave Ehrlich
Greenhorn

Joined: Nov 12, 2002
Posts: 20
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
Ritu Kama
Ranch Hand

Joined: Sep 10, 2001
Posts: 72
Hi,
Can you post your client code to give some more idea of how you are recieving the response from .NET Web service.
Ritu
Dave Ehrlich
Greenhorn

Joined: Nov 12, 2002
Posts: 20
Here is the client clode that handles the response. The code is based on a How To article from MSDN at:
HOW TO: Integrate an Apache SOAP 2.2 Client with a .NET XML web service
It works well for trasmitting the data, but I can't read the string being sent back by the web service.
Ritu Kama
Ranch Hand

Joined: Sep 10, 2001
Posts: 72
Is there a way you can dump the raw stream on the screen or file to see what's coming in exactly.
The code doesn't seem to have any error the way described in the URL document.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
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


Spritle Software Blogs
Dave Ehrlich
Greenhorn

Joined: Nov 12, 2002
Posts: 20
Rita,
The following commands:

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
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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 ]
Dave Ehrlich
Greenhorn

Joined: Nov 12, 2002
Posts: 20
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SaxParseException
 
Similar Threads
unable to connect to .Net web service using axis with java
java.net.MalformedURLException: no protocol: <soap:Envelope ?
Error processing response from .NET web service
How to convert string to xml file in java
SOAP Header Authentication!!!