You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by Sebastian <th...@informatik.hu-berlin.de> on 2002/08/01 11:02:54 UTC
ServerUtils
Hello everyone!
I am trying to transport SOAP using BEEP. For this, I have written a
class which is supposed to read an InputStream and extract from it
the SOAP-Envelope. I have used the ServerUtils.readEnvelopeFromInputStream
method there but it doesn't seem to work, does anyone have an idea why?
I keep getting this exception:
"Exception caught:Root element of a SOAP message must be:
'http://schemas.xmlsoap.org/soap/envelope/:Envelope'."
Which is funny, because the message does have this element as a root element.
Here is my code fragment (without the rest of the soap-string):
String msg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"...";
StringBufferInputStream sstream = new StringBufferInputStream(msg);
SOAPContext ctx = new SOAPContext();
EnvelopeEditorAdapter editor = new EnvelopeEditorAdapter();
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Envelope callEnv = ServerUtils.readEnvelopeFromInputStream
(builder, sstream, msg.length(),"text/xml", editor, ctx);
Re: ServerUtils
Posted by Scott Nichol <sn...@scottnichol.com>.
You create your DocumentBuilder using
DocumentBuilderFactory.newInstance().newDocumentBuilder();
This creates a DB that is *not* namespace aware. Instead, create using
org.apache.soap.util.xml.XMLParserUtils.getXMLDocBuilder();
Scott Nichol
----- Original Message -----
From: "Sebastian" <th...@informatik.hu-berlin.de>
To: <so...@xml.apache.org>
Sent: Thursday, August 08, 2002 8:05 AM
Subject: Re: ServerUtils
At 15:48 01.08.2002 -0400, you wrote:
>It may be your use of StringBufferInputStream. The javadoc for this says
>"Deprecated. This class does not properly convert characters into bytes. As
>of JDK 1.1, the preferred way to create a stream from a string is via the
>StringReader class."
>
>Scott Nichol
I tried it with proper streams and still I get the same exception.
Below is my Test class, maybe someone can see what I did wrong.
=============================================
Source Code
=============================================
import org.apache.soap.rpc.SOAPContext;
import org.apache.soap.transport.EnvelopeEditorAdapter;
import org.apache.soap.Envelope;
import org.apache.soap.server.ServerUtils;
import java.io.PipedOutputStream;
import java.io.PipedInputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
class Test
{
SOAPContext ctx;
EnvelopeEditorAdapter editor;
DocumentBuilder builder = null;
String contentType, soapMsg;
Envelope callEnv;
PipedInputStream input;
PipedOutputStream output;
public static void main (String[] args) {
Test t = new Test();
t.go();
}
public void go() {
//Create an empty SOAPcontext
ctx = new SOAPContext();
//Create EditorAdaptor
editor = new EnvelopeEditorAdapter();
//Create DocumentBuilder
try
{
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
catch (ParserConfigurationException pe)
{
System.err.println("Error while trying to obtain a
DocumentBuilder.");
}
//Create contentType-string
contentType = "text/xml";
//Create Message
soapMsg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<s:Body><purchaseOrder xmlns=\"urn:po-processor\"
orderDate=\"1999-10-20\">" +
"<shipTo country=\"US\"> <name>Alice Smith</name>
<street>123 Maple Street</street>" +
"<city>Mill Valley</city> <state>CA</state>
<zip>90952</zip> </shipTo>" +
"</purchaseOrder> </s:Body> </s:Envelope>";
try
{
// Create Input/Output-Pipe
output = new PipedOutputStream();
input = new PipedInputStream();
output.connect(input);
//Write String to OutputStream
output.write(soapMsg.getBytes(), 0,
soapMsg.length());
//is this needed?
output.flush();
output.close();
}
catch (java.io.IOException ioe)
{
System.out.println("Something went wrong during
Stream init/writing: " +
ioe.getMessage());
}
try {
System.out.print ("Trying to call
ServerUtils.readEnvelopeFromInputStream...");
callEnv =
ServerUtils.readEnvelopeFromInputStream
(builder, input, soapMsg.length(),contentType, editor, ctx);
System.out.print("\tdone.\n\n");
System.out.println(callEnv.toString());
}
catch (org.apache.soap.SOAPException se) {
System.out.println("\nSOAP Exception: " +
se.getMessage());
}
catch (java.io.IOException ioe) {
System.out.println("\nIO Exception: " +
ioe.getMessage());
}
catch (java.lang.IllegalArgumentException iae) {
System.out.println("\nIllegal Argument: " +
iae.getMessage());
}
catch (javax.mail.MessagingException me) {
System.out.println("\nMessaging Exception: " +
me.getMessage());
}
}
};
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
Re: ServerUtils
Posted by Scott Nichol <sn...@scottnichol.com>.
You create your DocumentBuilder using
DocumentBuilderFactory.newInstance().newDocumentBuilder();
This creates a DB that is *not* namespace aware. Instead, create using
org.apache.soap.util.xml.XMLParserUtils.getXMLDocBuilder();
Scott Nichol
----- Original Message -----
From: "Sebastian" <th...@informatik.hu-berlin.de>
To: <so...@xml.apache.org>
Sent: Thursday, August 08, 2002 8:05 AM
Subject: Re: ServerUtils
At 15:48 01.08.2002 -0400, you wrote:
>It may be your use of StringBufferInputStream. The javadoc for this says
>"Deprecated. This class does not properly convert characters into bytes. As
>of JDK 1.1, the preferred way to create a stream from a string is via the
>StringReader class."
>
>Scott Nichol
I tried it with proper streams and still I get the same exception.
Below is my Test class, maybe someone can see what I did wrong.
=============================================
Source Code
=============================================
import org.apache.soap.rpc.SOAPContext;
import org.apache.soap.transport.EnvelopeEditorAdapter;
import org.apache.soap.Envelope;
import org.apache.soap.server.ServerUtils;
import java.io.PipedOutputStream;
import java.io.PipedInputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
class Test
{
SOAPContext ctx;
EnvelopeEditorAdapter editor;
DocumentBuilder builder = null;
String contentType, soapMsg;
Envelope callEnv;
PipedInputStream input;
PipedOutputStream output;
public static void main (String[] args) {
Test t = new Test();
t.go();
}
public void go() {
//Create an empty SOAPcontext
ctx = new SOAPContext();
//Create EditorAdaptor
editor = new EnvelopeEditorAdapter();
//Create DocumentBuilder
try
{
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
catch (ParserConfigurationException pe)
{
System.err.println("Error while trying to obtain a
DocumentBuilder.");
}
//Create contentType-string
contentType = "text/xml";
//Create Message
soapMsg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<s:Body><purchaseOrder xmlns=\"urn:po-processor\"
orderDate=\"1999-10-20\">" +
"<shipTo country=\"US\"> <name>Alice Smith</name>
<street>123 Maple Street</street>" +
"<city>Mill Valley</city> <state>CA</state>
<zip>90952</zip> </shipTo>" +
"</purchaseOrder> </s:Body> </s:Envelope>";
try
{
// Create Input/Output-Pipe
output = new PipedOutputStream();
input = new PipedInputStream();
output.connect(input);
//Write String to OutputStream
output.write(soapMsg.getBytes(), 0,
soapMsg.length());
//is this needed?
output.flush();
output.close();
}
catch (java.io.IOException ioe)
{
System.out.println("Something went wrong during
Stream init/writing: " +
ioe.getMessage());
}
try {
System.out.print ("Trying to call
ServerUtils.readEnvelopeFromInputStream...");
callEnv =
ServerUtils.readEnvelopeFromInputStream
(builder, input, soapMsg.length(),contentType, editor, ctx);
System.out.print("\tdone.\n\n");
System.out.println(callEnv.toString());
}
catch (org.apache.soap.SOAPException se) {
System.out.println("\nSOAP Exception: " +
se.getMessage());
}
catch (java.io.IOException ioe) {
System.out.println("\nIO Exception: " +
ioe.getMessage());
}
catch (java.lang.IllegalArgumentException iae) {
System.out.println("\nIllegal Argument: " +
iae.getMessage());
}
catch (javax.mail.MessagingException me) {
System.out.println("\nMessaging Exception: " +
me.getMessage());
}
}
};
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
Re: ServerUtils
Posted by Sebastian <th...@informatik.hu-berlin.de>.
At 15:48 01.08.2002 -0400, you wrote:
>It may be your use of StringBufferInputStream. The javadoc for this says
>"Deprecated. This class does not properly convert characters into bytes. As
>of JDK 1.1, the preferred way to create a stream from a string is via the
>StringReader class."
>
>Scott Nichol
I tried it with proper streams and still I get the same exception.
Below is my Test class, maybe someone can see what I did wrong.
=============================================
Source Code
=============================================
import org.apache.soap.rpc.SOAPContext;
import org.apache.soap.transport.EnvelopeEditorAdapter;
import org.apache.soap.Envelope;
import org.apache.soap.server.ServerUtils;
import java.io.PipedOutputStream;
import java.io.PipedInputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
class Test
{
SOAPContext ctx;
EnvelopeEditorAdapter editor;
DocumentBuilder builder = null;
String contentType, soapMsg;
Envelope callEnv;
PipedInputStream input;
PipedOutputStream output;
public static void main (String[] args) {
Test t = new Test();
t.go();
}
public void go() {
//Create an empty SOAPcontext
ctx = new SOAPContext();
//Create EditorAdaptor
editor = new EnvelopeEditorAdapter();
//Create DocumentBuilder
try
{
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
catch (ParserConfigurationException pe)
{
System.err.println("Error while trying to obtain a
DocumentBuilder.");
}
//Create contentType-string
contentType = "text/xml";
//Create Message
soapMsg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<s:Body><purchaseOrder xmlns=\"urn:po-processor\"
orderDate=\"1999-10-20\">" +
"<shipTo country=\"US\"> <name>Alice Smith</name>
<street>123 Maple Street</street>" +
"<city>Mill Valley</city> <state>CA</state>
<zip>90952</zip> </shipTo>" +
"</purchaseOrder> </s:Body> </s:Envelope>";
try
{
// Create Input/Output-Pipe
output = new PipedOutputStream();
input = new PipedInputStream();
output.connect(input);
//Write String to OutputStream
output.write(soapMsg.getBytes(), 0, soapMsg.length());
//is this needed?
output.flush();
output.close();
}
catch (java.io.IOException ioe)
{
System.out.println("Something went wrong during
Stream init/writing: " +
ioe.getMessage());
}
try {
System.out.print ("Trying to call
ServerUtils.readEnvelopeFromInputStream...");
callEnv =
ServerUtils.readEnvelopeFromInputStream
(builder, input, soapMsg.length(),contentType, editor, ctx);
System.out.print("\tdone.\n\n");
System.out.println(callEnv.toString());
}
catch (org.apache.soap.SOAPException se) {
System.out.println("\nSOAP Exception: " +
se.getMessage());
}
catch (java.io.IOException ioe) {
System.out.println("\nIO Exception: " +
ioe.getMessage());
}
catch (java.lang.IllegalArgumentException iae) {
System.out.println("\nIllegal Argument: " +
iae.getMessage());
}
catch (javax.mail.MessagingException me) {
System.out.println("\nMessaging Exception: " +
me.getMessage());
}
}
};
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
Re: ServerUtils
Posted by Sebastian <th...@informatik.hu-berlin.de>.
At 15:48 01.08.2002 -0400, you wrote:
>It may be your use of StringBufferInputStream. The javadoc for this says
>"Deprecated. This class does not properly convert characters into bytes. As
>of JDK 1.1, the preferred way to create a stream from a string is via the
>StringReader class."
>
>Scott Nichol
I tried it with proper streams and still I get the same exception.
Below is my Test class, maybe someone can see what I did wrong.
=============================================
Source Code
=============================================
import org.apache.soap.rpc.SOAPContext;
import org.apache.soap.transport.EnvelopeEditorAdapter;
import org.apache.soap.Envelope;
import org.apache.soap.server.ServerUtils;
import java.io.PipedOutputStream;
import java.io.PipedInputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
class Test
{
SOAPContext ctx;
EnvelopeEditorAdapter editor;
DocumentBuilder builder = null;
String contentType, soapMsg;
Envelope callEnv;
PipedInputStream input;
PipedOutputStream output;
public static void main (String[] args) {
Test t = new Test();
t.go();
}
public void go() {
//Create an empty SOAPcontext
ctx = new SOAPContext();
//Create EditorAdaptor
editor = new EnvelopeEditorAdapter();
//Create DocumentBuilder
try
{
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
catch (ParserConfigurationException pe)
{
System.err.println("Error while trying to obtain a
DocumentBuilder.");
}
//Create contentType-string
contentType = "text/xml";
//Create Message
soapMsg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<s:Body><purchaseOrder xmlns=\"urn:po-processor\"
orderDate=\"1999-10-20\">" +
"<shipTo country=\"US\"> <name>Alice Smith</name>
<street>123 Maple Street</street>" +
"<city>Mill Valley</city> <state>CA</state>
<zip>90952</zip> </shipTo>" +
"</purchaseOrder> </s:Body> </s:Envelope>";
try
{
// Create Input/Output-Pipe
output = new PipedOutputStream();
input = new PipedInputStream();
output.connect(input);
//Write String to OutputStream
output.write(soapMsg.getBytes(), 0, soapMsg.length());
//is this needed?
output.flush();
output.close();
}
catch (java.io.IOException ioe)
{
System.out.println("Something went wrong during
Stream init/writing: " +
ioe.getMessage());
}
try {
System.out.print ("Trying to call
ServerUtils.readEnvelopeFromInputStream...");
callEnv =
ServerUtils.readEnvelopeFromInputStream
(builder, input, soapMsg.length(),contentType, editor, ctx);
System.out.print("\tdone.\n\n");
System.out.println(callEnv.toString());
}
catch (org.apache.soap.SOAPException se) {
System.out.println("\nSOAP Exception: " +
se.getMessage());
}
catch (java.io.IOException ioe) {
System.out.println("\nIO Exception: " +
ioe.getMessage());
}
catch (java.lang.IllegalArgumentException iae) {
System.out.println("\nIllegal Argument: " +
iae.getMessage());
}
catch (javax.mail.MessagingException me) {
System.out.println("\nMessaging Exception: " +
me.getMessage());
}
}
};
Re: ServerUtils
Posted by Scott Nichol <sn...@scottnichol.com>.
It may be your use of StringBufferInputStream. The javadoc for this says
"Deprecated. This class does not properly convert characters into bytes. As
of JDK 1.1, the preferred way to create a stream from a string is via the
StringReader class."
Scott Nichol
----- Original Message -----
From: "Sebastian" <th...@informatik.hu-berlin.de>
To: <so...@xml.apache.org>
Sent: Thursday, August 01, 2002 5:02 AM
Subject: ServerUtils
Hello everyone!
I am trying to transport SOAP using BEEP. For this, I have written a
class which is supposed to read an InputStream and extract from it
the SOAP-Envelope. I have used the ServerUtils.readEnvelopeFromInputStream
method there but it doesn't seem to work, does anyone have an idea why?
I keep getting this exception:
"Exception caught:Root element of a SOAP message must be:
'http://schemas.xmlsoap.org/soap/envelope/:Envelope'."
Which is funny, because the message does have this element as a root
element.
Here is my code fragment (without the rest of the soap-string):
String msg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"...";
StringBufferInputStream sstream = new StringBufferInputStream(msg);
SOAPContext ctx = new SOAPContext();
EnvelopeEditorAdapter editor = new EnvelopeEditorAdapter();
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Envelope callEnv = ServerUtils.readEnvelopeFromInputStream
(builder, sstream, msg.length(),"text/xml", editor, ctx);
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
Re: ServerUtils
Posted by Scott Nichol <sn...@scottnichol.com>.
It may be your use of StringBufferInputStream. The javadoc for this says
"Deprecated. This class does not properly convert characters into bytes. As
of JDK 1.1, the preferred way to create a stream from a string is via the
StringReader class."
Scott Nichol
----- Original Message -----
From: "Sebastian" <th...@informatik.hu-berlin.de>
To: <so...@xml.apache.org>
Sent: Thursday, August 01, 2002 5:02 AM
Subject: ServerUtils
Hello everyone!
I am trying to transport SOAP using BEEP. For this, I have written a
class which is supposed to read an InputStream and extract from it
the SOAP-Envelope. I have used the ServerUtils.readEnvelopeFromInputStream
method there but it doesn't seem to work, does anyone have an idea why?
I keep getting this exception:
"Exception caught:Root element of a SOAP message must be:
'http://schemas.xmlsoap.org/soap/envelope/:Envelope'."
Which is funny, because the message does have this element as a root
element.
Here is my code fragment (without the rest of the soap-string):
String msg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"...";
StringBufferInputStream sstream = new StringBufferInputStream(msg);
SOAPContext ctx = new SOAPContext();
EnvelopeEditorAdapter editor = new EnvelopeEditorAdapter();
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Envelope callEnv = ServerUtils.readEnvelopeFromInputStream
(builder, sstream, msg.length(),"text/xml", editor, ctx);
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
RE: ServerUtils
Posted by Henk Schipper <he...@software684.com>.
Hi Sebastian,
Maybe a silly question, but where is the end-tag ('>')?
Henk.
-----Original Message-----
From: Sebastian [mailto:thiebes@informatik.hu-berlin.de]
Sent: Thursday, 01 August, 2002 11:03 AM
To: soap-dev@xml.apache.org
Subject: ServerUtils
Hello everyone!
I am trying to transport SOAP using BEEP. For this, I have written a
class which is supposed to read an InputStream and extract from it
the SOAP-Envelope. I have used the ServerUtils.readEnvelopeFromInputStream
method there but it doesn't seem to work, does anyone have an idea why?
I keep getting this exception:
"Exception caught:Root element of a SOAP message must be:
'http://schemas.xmlsoap.org/soap/envelope/:Envelope'."
Which is funny, because the message does have this element as a root
element.
Here is my code fragment (without the rest of the soap-string):
String msg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"...";
StringBufferInputStream sstream = new StringBufferInputStream(msg);
SOAPContext ctx = new SOAPContext();
EnvelopeEditorAdapter editor = new EnvelopeEditorAdapter();
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Envelope callEnv = ServerUtils.readEnvelopeFromInputStream
(builder, sstream, msg.length(),"text/xml", editor, ctx);
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
RE: ServerUtils
Posted by Henk Schipper <he...@software684.com>.
Hi Sebastian,
Maybe a silly question, but where is the end-tag ('>')?
Henk.
-----Original Message-----
From: Sebastian [mailto:thiebes@informatik.hu-berlin.de]
Sent: Thursday, 01 August, 2002 11:03 AM
To: soap-dev@xml.apache.org
Subject: ServerUtils
Hello everyone!
I am trying to transport SOAP using BEEP. For this, I have written a
class which is supposed to read an InputStream and extract from it
the SOAP-Envelope. I have used the ServerUtils.readEnvelopeFromInputStream
method there but it doesn't seem to work, does anyone have an idea why?
I keep getting this exception:
"Exception caught:Root element of a SOAP message must be:
'http://schemas.xmlsoap.org/soap/envelope/:Envelope'."
Which is funny, because the message does have this element as a root
element.
Here is my code fragment (without the rest of the soap-string):
String msg = "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"...";
StringBufferInputStream sstream = new StringBufferInputStream(msg);
SOAPContext ctx = new SOAPContext();
EnvelopeEditorAdapter editor = new EnvelopeEditorAdapter();
builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Envelope callEnv = ServerUtils.readEnvelopeFromInputStream
(builder, sstream, msg.length(),"text/xml", editor, ctx);
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>