You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Rich Catlett <ri...@more.net> on 2001/08/07 18:22:36 UTC

sending XML documents via the messaging service

I am trying to send an precreated XML document via the soap messaging 
service.  The client takes as an input parameter the host soap is 
running on, the service, and the XML document to send.  I have created 
the envelope using Envelope.unmarshall() as the messaging example shows 
mine looks like this

DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
StringReader reader = new StringReader(XMLData);   //XMLData = input XML doc
Document doc = xdb.parse(new InputSource(reader));
Envelope msgenv = Envelope.unmarshall(doc.getDocumentElement());

then I send the message.  Currently all the service does is extract the 
body and send it back like this

Body body = env.getBody()  // env is the Envelope sent to the service
resctx.setRootPart(body.toString(), "text/xml");

I've used the TcpTunnelGui and it show that the XML document is indeed 
getting sent to the service, but then from the service all I get back is 
this

[Attributes={}] [BodyEntries=
[(0)=[purchaseOrder: null]]
]

Can someone tell me what I'm doing wrong or point me in the direction to 
figure it out.
Thanks.

Rich Catlett


Re: sending XML documents via the messaging service

Posted by Rich Catlett <ri...@more.net>.
In the service I did an envelope.toString of the envelope that comes in 
and this is the whole envelope that I am getting

[Attributes={ 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"}] 
[Header=null] [Body=[Attributes={}] [BodyEntries=
[(0)=[purchaseOrder: null]]
]] [EnvelopeEntries=]

I also thought this might help, this is the XML document I use to create 
the envelope

<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV: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>
   <billTo country="US">
   <name>Robert Smith</name>
   <street>8 Oak Avenue</street>
   <city>Old Town</city>
   <state>PA</state>
   <zip>95819</zip>
   </billTo>
   <comment>Hurry, my lawn is going wild!</comment>
   <items>
   <item partNum="872-AA">
           <productName>Lawnmower</productName>
           <quantity>1</quantity>
           <price>148.95</price>
           <comment>Confirm this is electric</comment>
   </item>
   <item partNum="926-AA">
           <productName>Baby Monitor</productName>
           <quantity>1</quantity>
           <price>39.98</price>
           <shipDate>1999-05-21</shipDate>
   </item>
   </items>
</purchaseOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


One other thought, first all of you guys who have worked on apache SOAP 
have done a great job, but the documentation is lacking in my opinion.  
It seems to be written for poeple who completely understand XML and 
marshalling and unmarshalling.  None of the methods in the api docs have 
any sort of documentation.  Just a thought wanted to see if anyones else 
shared it.

Tom Myers wrote:

> At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
> ...
> 
>> I've used the TcpTunnelGui and it show that the XML document is indeed getting sent to the service, but then from the service all I get back is this
>> 
>> [Attributes={}] [BodyEntries=
>> [(0)=[purchaseOrder: null]]
>> ]
>> 
>> Can someone tell me what I'm doing wrong or point me in the direction to figure it out.
> 
> 
>   Have you tried getting the service to dump it to a local file, or just to System.out
> (on Tomcat that would generally put it on the console window...) just some variation
> on 
> 
>>   new org.apache.xml.serialize
>>    .XMLSerializer(System.out,
>>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>>       .asDOMSerializer().serialize(doc);
> 
> 
> (assuming that you're using apache, of course)? In other words, the document is
> being lost, so you've just got to track it as far as it goes... :-) 
> 
> Tom Myers
> 


Re: sending XML documents via the messaging service

Posted by Rich Catlett <ri...@more.net>.
In the service I did an envelope.toString of the envelope that comes in 
and this is the whole envelope that I am getting

[Attributes={ 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"}] 
[Header=null] [Body=[Attributes={}] [BodyEntries=
[(0)=[purchaseOrder: null]]
]] [EnvelopeEntries=]

I also thought this might help, this is the XML document I use to create 
the envelope

<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV: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>
   <billTo country="US">
   <name>Robert Smith</name>
   <street>8 Oak Avenue</street>
   <city>Old Town</city>
   <state>PA</state>
   <zip>95819</zip>
   </billTo>
   <comment>Hurry, my lawn is going wild!</comment>
   <items>
   <item partNum="872-AA">
           <productName>Lawnmower</productName>
           <quantity>1</quantity>
           <price>148.95</price>
           <comment>Confirm this is electric</comment>
   </item>
   <item partNum="926-AA">
           <productName>Baby Monitor</productName>
           <quantity>1</quantity>
           <price>39.98</price>
           <shipDate>1999-05-21</shipDate>
   </item>
   </items>
</purchaseOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


One other thought, first all of you guys who have worked on apache SOAP 
have done a great job, but the documentation is lacking in my opinion.  
It seems to be written for poeple who completely understand XML and 
marshalling and unmarshalling.  None of the methods in the api docs have 
any sort of documentation.  Just a thought wanted to see if anyones else 
shared it.

Tom Myers wrote:

> At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
> ...
> 
>> I've used the TcpTunnelGui and it show that the XML document is indeed getting sent to the service, but then from the service all I get back is this
>> 
>> [Attributes={}] [BodyEntries=
>> [(0)=[purchaseOrder: null]]
>> ]
>> 
>> Can someone tell me what I'm doing wrong or point me in the direction to figure it out.
> 
> 
>   Have you tried getting the service to dump it to a local file, or just to System.out
> (on Tomcat that would generally put it on the console window...) just some variation
> on 
> 
>>   new org.apache.xml.serialize
>>    .XMLSerializer(System.out,
>>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>>       .asDOMSerializer().serialize(doc);
> 
> 
> (assuming that you're using apache, of course)? In other words, the document is
> being lost, so you've just got to track it as far as it goes... :-) 
> 
> Tom Myers
> 


Re: sending XML documents via the messaging service

Posted by Tom Myers <to...@dreamscape.com>.
At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
...
>I've used the TcpTunnelGui and it show that the XML document is indeed getting sent to the service, but then from the service all I get back is this
>
>[Attributes={}] [BodyEntries=
>[(0)=[purchaseOrder: null]]
>]
>
>Can someone tell me what I'm doing wrong or point me in the direction to figure it out.

  Have you tried getting the service to dump it to a local file, or just to System.out
(on Tomcat that would generally put it on the console window...) just some variation
on 
>   new org.apache.xml.serialize
>    .XMLSerializer(System.out,
>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>       .asDOMSerializer().serialize(doc);

(assuming that you're using apache, of course)? In other words, the document is
being lost, so you've just got to track it as far as it goes... :-) 

Tom Myers


Re: sending base64 encoding

Posted by William Brogden <wb...@bga.com>.

Gus Delgado wrote:
> 
> I'm sending an XML file back from the server to the client.
> How can I send an encodingType of base64 on one of the Elements of the
> XML file I send back?
> 
> example of what I'm trying to do:
> 
> <my-tag>
>   <thisnormaltag>hello</thisnormaltag>
>   <thisbase64tag encoding=base64>???</thisbase64tag>
> </my-tag>
> 
> I'm really struggling with this? thanks
> gus

Here is an example response from Apache SOAP - the method returned
a byte array.

<ns1:doXorResponse xmlns:ns1="urn:Exercise" 
 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="ns2:base64">BSkpPmhYXBQ3XFRyIiMlOkJXFCxSETo0ITEmEVdCJl==
</return>
</ns1:doXorResponse>

-- 
WBB - wbrogden@lanw.com
Java Cert mock exams http://www.lanw.com/java/javacert/
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2

Re: sending base64 encoding

Posted by William Brogden <wb...@bga.com>.

Gus Delgado wrote:
> 
> I'm sending an XML file back from the server to the client.
> How can I send an encodingType of base64 on one of the Elements of the
> XML file I send back?
> 
> example of what I'm trying to do:
> 
> <my-tag>
>   <thisnormaltag>hello</thisnormaltag>
>   <thisbase64tag encoding=base64>???</thisbase64tag>
> </my-tag>
> 
> I'm really struggling with this? thanks
> gus

Here is an example response from Apache SOAP - the method returned
a byte array.

<ns1:doXorResponse xmlns:ns1="urn:Exercise" 
 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="ns2:base64">BSkpPmhYXBQ3XFRyIiMlOkJXFCxSETo0ITEmEVdCJl==
</return>
</ns1:doXorResponse>

-- 
WBB - wbrogden@lanw.com
Java Cert mock exams http://www.lanw.com/java/javacert/
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2

sending base64 encoding

Posted by Gus Delgado <gu...@netquotient.com>.
I'm sending an XML file back from the server to the client.
How can I send an encodingType of base64 on one of the Elements of the
XML file I send back?

example of what I'm trying to do:

<my-tag>
  <thisnormaltag>hello</thisnormaltag>
  <thisbase64tag encoding=base64>???</thisbase64tag>
</my-tag>

I'm really struggling with this? thanks
gus

sending base64 encoding

Posted by Gus Delgado <gu...@netquotient.com>.
I'm sending an XML file back from the server to the client.
How can I send an encodingType of base64 on one of the Elements of the
XML file I send back?

example of what I'm trying to do:

<my-tag>
  <thisnormaltag>hello</thisnormaltag>
  <thisbase64tag encoding=base64>???</thisbase64tag>
</my-tag>

I'm really struggling with this? thanks
gus

Re: sending XML documents via the messaging service

Posted by Tom Myers <to...@dreamscape.com>.
At 05:44 PM 8/7/2001 -0500, Rich Catlett wrote:
>Okay I guess then that my question really is I send an envelope to a messaging service, the body of which I want to extract and pass on.  How do I extract the XML document which as best I can tell is in the body of the Envelope.  Do I have to marshall it back into an XML document.  Is there an easier way send an XML document so that I don't have to deal with marshalling and unmarshalling since I am doing that outside of SOAP.

Hmm...you want SOAP to send a particular text; the fact that the text
is XML and that SOAP is XML-aware is really incidental, isn't it?
And you've got the document as a string already, so why not just send
a string? SOAP really does work pretty well with params of String.class,
unless they're large -- there have been reports of performance issues
with large strings, and I keep meaning to see if this is sensitive to
the number of special chars ("<",">","&" and so forth) which get
converted; if I did this and had a performance problem, I'd try a
java.net.URLEncoder / URLDecoder pair just to see what happened.
(I'm not at all sure this addresses what you're doing, but it might.)

Tom Myers


Re: sending XML documents via the messaging service

Posted by Tom Myers <to...@dreamscape.com>.
At 05:44 PM 8/7/2001 -0500, Rich Catlett wrote:
>Okay I guess then that my question really is I send an envelope to a messaging service, the body of which I want to extract and pass on.  How do I extract the XML document which as best I can tell is in the body of the Envelope.  Do I have to marshall it back into an XML document.  Is there an easier way send an XML document so that I don't have to deal with marshalling and unmarshalling since I am doing that outside of SOAP.

Hmm...you want SOAP to send a particular text; the fact that the text
is XML and that SOAP is XML-aware is really incidental, isn't it?
And you've got the document as a string already, so why not just send
a string? SOAP really does work pretty well with params of String.class,
unless they're large -- there have been reports of performance issues
with large strings, and I keep meaning to see if this is sensitive to
the number of special chars ("<",">","&" and so forth) which get
converted; if I did this and had a performance problem, I'd try a
java.net.URLEncoder / URLDecoder pair just to see what happened.
(I'm not at all sure this addresses what you're doing, but it might.)

Tom Myers


Re: sending XML documents via the messaging service

Posted by Rich Catlett <ri...@more.net>.
Okay I guess then that my question really is I send an envelope to a 
messaging service, the body of which I want to extract and pass on.  How 
do I extract the XML document which as best I can tell is in the body of 
the Envelope.  Do I have to marshall it back into an XML document.  Is 
there an easier way send an XML document so that I don't have to deal 
with marshalling and unmarshalling since I am doing that outside of SOAP.

Tom Myers wrote:

> At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
> 
>> I am trying to send an precreated XML document via the soap messaging service.  The client takes as an input parameter the host soap is running on, the service, and the XML document to send.  I have created the envelope using Envelope.unmarshall() as the messaging example shows ...
> 
> 
> and his server code is
> 
>> Body body = env.getBody()  // env is the Envelope sent to the service
>> resctx.setRootPart(body.toString(), "text/xml");
> 
> 
> and this generates the output
> 
>> [Attributes={}] [BodyEntries=
>> [(0)=[purchaseOrder: null]]
>> ]
>> ...
>> Can someone tell me what I'm doing wrong or point me in the direction to figure it out.
> 
> 
> and the thing is, if you look at the source, the org.apache.soap.Body.toString() method
> is generating that (0)=[purchaseOrder: null] with code like so:
> 
>>   for (int i = 0; i < bodyEntries.size(); i++)
>>       {
>>         pw.println("[(" + i + ")=" + bodyEntries.elementAt(i) + "]");
>>       }
> 
> 
> Now, bodyEntries is a vector which generally contains DOM elements, but
> Element.toString() is not a method for reporting detailed contents, it's not a DOM
> method at all -- it's a debugging aid. I'd still suggest something like
> 
>>  Element purchaseOrder = (Element)(env.getBody().getBodyEntries().elementAt(0));
>>   new org.apache.xml.serialize
>>    .XMLSerializer(System.out,
>>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>>       .asDOMSerializer().serialize(purchaseOrder);
> 
> 
> to see if the Element is actually there--I just don't know, from what you've said.
> toString() may tell somebody, but it doesn't tell me much. (Maybe this will blow 
> up with a classcastexception because the elementAt(0) is not really even an Element.
> If not, it might help to figure out what it is. :-) )
> 
> Tom Myers
> 
> 


Re: sending XML documents via the messaging service

Posted by Rich Catlett <ri...@more.net>.
Okay I guess then that my question really is I send an envelope to a 
messaging service, the body of which I want to extract and pass on.  How 
do I extract the XML document which as best I can tell is in the body of 
the Envelope.  Do I have to marshall it back into an XML document.  Is 
there an easier way send an XML document so that I don't have to deal 
with marshalling and unmarshalling since I am doing that outside of SOAP.

Tom Myers wrote:

> At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
> 
>> I am trying to send an precreated XML document via the soap messaging service.  The client takes as an input parameter the host soap is running on, the service, and the XML document to send.  I have created the envelope using Envelope.unmarshall() as the messaging example shows ...
> 
> 
> and his server code is
> 
>> Body body = env.getBody()  // env is the Envelope sent to the service
>> resctx.setRootPart(body.toString(), "text/xml");
> 
> 
> and this generates the output
> 
>> [Attributes={}] [BodyEntries=
>> [(0)=[purchaseOrder: null]]
>> ]
>> ...
>> Can someone tell me what I'm doing wrong or point me in the direction to figure it out.
> 
> 
> and the thing is, if you look at the source, the org.apache.soap.Body.toString() method
> is generating that (0)=[purchaseOrder: null] with code like so:
> 
>>   for (int i = 0; i < bodyEntries.size(); i++)
>>       {
>>         pw.println("[(" + i + ")=" + bodyEntries.elementAt(i) + "]");
>>       }
> 
> 
> Now, bodyEntries is a vector which generally contains DOM elements, but
> Element.toString() is not a method for reporting detailed contents, it's not a DOM
> method at all -- it's a debugging aid. I'd still suggest something like
> 
>>  Element purchaseOrder = (Element)(env.getBody().getBodyEntries().elementAt(0));
>>   new org.apache.xml.serialize
>>    .XMLSerializer(System.out,
>>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>>       .asDOMSerializer().serialize(purchaseOrder);
> 
> 
> to see if the Element is actually there--I just don't know, from what you've said.
> toString() may tell somebody, but it doesn't tell me much. (Maybe this will blow 
> up with a classcastexception because the elementAt(0) is not really even an Element.
> If not, it might help to figure out what it is. :-) )
> 
> Tom Myers
> 
> 


Re: sending XML documents via the messaging service

Posted by Tom Myers <to...@dreamscape.com>.
At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
>I am trying to send an precreated XML document via the soap messaging service.  The client takes as an input parameter the host soap is running on, the service, and the XML document to send.  I have created the envelope using Envelope.unmarshall() as the messaging example shows ...

and his server code is

>Body body = env.getBody()  // env is the Envelope sent to the service
>resctx.setRootPart(body.toString(), "text/xml");

and this generates the output

>[Attributes={}] [BodyEntries=
>[(0)=[purchaseOrder: null]]
>]
>...
>Can someone tell me what I'm doing wrong or point me in the direction to figure it out.

and the thing is, if you look at the source, the org.apache.soap.Body.toString() method
is generating that (0)=[purchaseOrder: null] with code like so:

>   for (int i = 0; i < bodyEntries.size(); i++)
>       {
>         pw.println("[(" + i + ")=" + bodyEntries.elementAt(i) + "]");
>       }

Now, bodyEntries is a vector which generally contains DOM elements, but
Element.toString() is not a method for reporting detailed contents, it's not a DOM
method at all -- it's a debugging aid. I'd still suggest something like

>  Element purchaseOrder = (Element)(env.getBody().getBodyEntries().elementAt(0));
>   new org.apache.xml.serialize
>    .XMLSerializer(System.out,
>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>       .asDOMSerializer().serialize(purchaseOrder);

to see if the Element is actually there--I just don't know, from what you've said.
toString() may tell somebody, but it doesn't tell me much. (Maybe this will blow 
up with a classcastexception because the elementAt(0) is not really even an Element.
If not, it might help to figure out what it is. :-) )

Tom Myers



Re: sending XML documents via the messaging service

Posted by Tom Myers <to...@dreamscape.com>.
At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
>I am trying to send an precreated XML document via the soap messaging service.  The client takes as an input parameter the host soap is running on, the service, and the XML document to send.  I have created the envelope using Envelope.unmarshall() as the messaging example shows ...

and his server code is

>Body body = env.getBody()  // env is the Envelope sent to the service
>resctx.setRootPart(body.toString(), "text/xml");

and this generates the output

>[Attributes={}] [BodyEntries=
>[(0)=[purchaseOrder: null]]
>]
>...
>Can someone tell me what I'm doing wrong or point me in the direction to figure it out.

and the thing is, if you look at the source, the org.apache.soap.Body.toString() method
is generating that (0)=[purchaseOrder: null] with code like so:

>   for (int i = 0; i < bodyEntries.size(); i++)
>       {
>         pw.println("[(" + i + ")=" + bodyEntries.elementAt(i) + "]");
>       }

Now, bodyEntries is a vector which generally contains DOM elements, but
Element.toString() is not a method for reporting detailed contents, it's not a DOM
method at all -- it's a debugging aid. I'd still suggest something like

>  Element purchaseOrder = (Element)(env.getBody().getBodyEntries().elementAt(0));
>   new org.apache.xml.serialize
>    .XMLSerializer(System.out,
>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>       .asDOMSerializer().serialize(purchaseOrder);

to see if the Element is actually there--I just don't know, from what you've said.
toString() may tell somebody, but it doesn't tell me much. (Maybe this will blow 
up with a classcastexception because the elementAt(0) is not really even an Element.
If not, it might help to figure out what it is. :-) )

Tom Myers



Re: sending XML documents via the messaging service

Posted by Tom Myers <to...@dreamscape.com>.
At 11:22 AM 8/7/2001 -0500, Rich Catlett wrote:
...
>I've used the TcpTunnelGui and it show that the XML document is indeed getting sent to the service, but then from the service all I get back is this
>
>[Attributes={}] [BodyEntries=
>[(0)=[purchaseOrder: null]]
>]
>
>Can someone tell me what I'm doing wrong or point me in the direction to figure it out.

  Have you tried getting the service to dump it to a local file, or just to System.out
(on Tomcat that would generally put it on the console window...) just some variation
on 
>   new org.apache.xml.serialize
>    .XMLSerializer(System.out,
>                   new org.apache.xml.serialize.OutputFormat("xml","utf-8",true))
>       .asDOMSerializer().serialize(doc);

(assuming that you're using apache, of course)? In other words, the document is
being lost, so you've just got to track it as far as it goes... :-) 

Tom Myers