Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SaxParseException

 
Dave Ehrlich
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dave Ehrlich
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic