You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Joseph George <Jo...@sophia.inria.fr> on 2001/07/18 20:12:10 UTC
extracting soap part from http request
Hi,
How do I extract the soap part of a http request in a java servlet? For example, suppose my client sends a soap request to http://localhost:8080/servlets/TestServlet and i want to print out the body of the soap request...how do i do that in TestServlet? Thanks.
-joseph.
Re: extracting soap part from http request
Posted by Tom Myers <to...@dreamscape.com>.
At 08:12 PM 7/18/2001 +0200, Joseph George wrote:
>Hi,
>How do I extract the soap part of a http request in a java servlet? For example, suppose my client sends a soap request to <http://localhost:8080/servlets/TestServlet>http://localhost:8080/servlets/TestServlet and i want to print out the body of the soap request...how do i do that in TestServlet? Thanks
Well, look at RPCRouterServlet.java and you'll see that the body comes in via
req.getInputStream()
which is being passed to something which passes it to something which passes it to a
new TransportMessage(..)
which does a
> while ((offset < contentLength) && (bytesRead >= 0)) {
> bytesRead = is.read(bytes, offset, contentLength - offset);
> offset += bytesRead;
So presumably you can make that work, or you might prefer to make it a reader...
InputStreamReader reader=new InputStreamReader(is,"iso-8859-1");
StringWriter sw=new java.io.StringWriter();
for(int ch=reader.read();ch>=0;ch=reader.read())sw.write((char)ch);
String resString=sw.toString();
(clipped from something I was looking at anyway; this will of course be slower
than the byte-array approach, but you don't have to think about the contentlength.)
Or am I missing something again?
Tom Myers
Re: extracting soap part from http request
Posted by Tom Myers <to...@dreamscape.com>.
At 08:12 PM 7/18/2001 +0200, Joseph George wrote:
>Hi,
>How do I extract the soap part of a http request in a java servlet? For example, suppose my client sends a soap request to <http://localhost:8080/servlets/TestServlet>http://localhost:8080/servlets/TestServlet and i want to print out the body of the soap request...how do i do that in TestServlet? Thanks
Well, look at RPCRouterServlet.java and you'll see that the body comes in via
req.getInputStream()
which is being passed to something which passes it to something which passes it to a
new TransportMessage(..)
which does a
> while ((offset < contentLength) && (bytesRead >= 0)) {
> bytesRead = is.read(bytes, offset, contentLength - offset);
> offset += bytesRead;
So presumably you can make that work, or you might prefer to make it a reader...
InputStreamReader reader=new InputStreamReader(is,"iso-8859-1");
StringWriter sw=new java.io.StringWriter();
for(int ch=reader.read();ch>=0;ch=reader.read())sw.write((char)ch);
String resString=sw.toString();
(clipped from something I was looking at anyway; this will of course be slower
than the byte-array approach, but you don't have to think about the contentlength.)
Or am I missing something again?
Tom Myers