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 Alex Greenland <ag...@cromwells.co.uk> on 2002/01/24 17:17:35 UTC
SOAP Messaging with Apache SOAP
Hi all
Please forgive me if this is a daft question as I am relativley new to
Apache SOAP.
I am trying to send a SOAP message to a proprietry SOAP server, the
message looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:putPerson xmlns:m="http://www.myurl.org/gateway/"
TimeStampGMT="2002-01-18T10:26:22" Version="1.0">
<Name>ALEX</Name>
<Address>
<Line1>25 The Road</Line1>
<Town>London</Town>
<County>Sussex</County>
</Address>
</m:putPerson >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The problem I am having is how to create the structed XML for the Body
of the message. I can create a message using a flat structure, i.e
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:putPerson xmlns:m="http://www.myurl.org/gateway/"
TimeStampGMT="2002-01-18T10:26:22" Version="1.0">
<Name>ALEX</Name>
<Line1>25 The Road</Line1>
<Town>London</Town>
<County>Sussex</County>
</m:putPerson >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Is there a way to create the structured XML?
Thanks in advance
Alex
Re: SOAP Messaging with Apache SOAP
Posted by Fred Meredith <fm...@nc.rr.com>.
> > From: Fred Meredith [mailto:fmeredith@nc.rr.com]
> > Sent: Thursday, January 24, 2002 5:16 PM
> >
> > I'd use a StringBuffer object to build the XML string the way
> > you need it to
> > be and then do something like this:
> >
> > DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
> > Document doc = xdb.parse(new InputSource(new
> > StringReader(stringBuffer.toString())));
> > Envelope env = Envelope.unmarshall(doc.getDocumentElement());
> >
>
> Correct me if I'm wrong, but you seem to be saying:
> Build it as a string.
> Parse it.
> Unparse it.
>
> That doesn't seem right. One may as well just insert the string into the
> envelope directly.
>
> If you want to build a DOM version, doesn't it make more sense to build it
> directly, instead of building the string and parsing it?
>
> Gary
Consider the above a generic example...
Instead of building a string to parse, I could have just as easily read the
XML structure from a file by using the line: Document doc = xdb.parse(new
InputSource(new FileReader(filename)));
Yes, if I wanted to build a DOM structure and knew the string values to
build into it, it definitely would make more sense to do it that way. You
are correct, Gary.
I'm not aware of any direct method that will allow creating an Envelope
object directly from an input string... is there a way? I've always done it
as above; if there's a better way, I'd love to know.
Re: SOAP Messaging with Apache SOAP
Posted by Fred Meredith <fm...@nc.rr.com>.
> > From: Fred Meredith [mailto:fmeredith@nc.rr.com]
> > Sent: Thursday, January 24, 2002 5:16 PM
> >
> > I'd use a StringBuffer object to build the XML string the way
> > you need it to
> > be and then do something like this:
> >
> > DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
> > Document doc = xdb.parse(new InputSource(new
> > StringReader(stringBuffer.toString())));
> > Envelope env = Envelope.unmarshall(doc.getDocumentElement());
> >
>
> Correct me if I'm wrong, but you seem to be saying:
> Build it as a string.
> Parse it.
> Unparse it.
>
> That doesn't seem right. One may as well just insert the string into the
> envelope directly.
>
> If you want to build a DOM version, doesn't it make more sense to build it
> directly, instead of building the string and parsing it?
>
> Gary
Consider the above a generic example...
Instead of building a string to parse, I could have just as easily read the
XML structure from a file by using the line: Document doc = xdb.parse(new
InputSource(new FileReader(filename)));
Yes, if I wanted to build a DOM structure and knew the string values to
build into it, it definitely would make more sense to do it that way. You
are correct, Gary.
I'm not aware of any direct method that will allow creating an Envelope
object directly from an input string... is there a way? I've always done it
as above; if there's a better way, I'd love to know.
RE: SOAP Messaging with Apache SOAP
Posted by Gary Feldman <ga...@rtr.com>.
> From: Fred Meredith [mailto:fmeredith@nc.rr.com]
> Sent: Thursday, January 24, 2002 5:16 PM
>
> I'd use a StringBuffer object to build the XML string the way
> you need it to
> be and then do something like this:
>
> DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
> Document doc = xdb.parse(new InputSource(new
> StringReader(stringBuffer.toString())));
> Envelope env = Envelope.unmarshall(doc.getDocumentElement());
>
Correct me if I'm wrong, but you seem to be saying:
Build it as a string.
Parse it.
Unparse it.
That doesn't seem right. One may as well just insert the string into the
envelope directly.
If you want to build a DOM version, doesn't it make more sense to build it
directly, instead of building the string and parsing it?
Gary
====================================================================
Ready-to-Run Software, Inc.
The Industry's Leading Provider of
Cross-Platform and Porting Services
*****************************
email: gaf@rtr.com Gary Feldman
fax : 1-978-692-5401 Ready-to-Run Software, Inc.
voice: 1-978-251-5431 11 School Street
www : http://www.rtr.com North Chelmsford, MA 01863
USA
RE: SOAP Messaging with Apache SOAP
Posted by Gary Feldman <ga...@rtr.com>.
> From: Fred Meredith [mailto:fmeredith@nc.rr.com]
> Sent: Thursday, January 24, 2002 5:16 PM
>
> I'd use a StringBuffer object to build the XML string the way
> you need it to
> be and then do something like this:
>
> DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
> Document doc = xdb.parse(new InputSource(new
> StringReader(stringBuffer.toString())));
> Envelope env = Envelope.unmarshall(doc.getDocumentElement());
>
Correct me if I'm wrong, but you seem to be saying:
Build it as a string.
Parse it.
Unparse it.
That doesn't seem right. One may as well just insert the string into the
envelope directly.
If you want to build a DOM version, doesn't it make more sense to build it
directly, instead of building the string and parsing it?
Gary
====================================================================
Ready-to-Run Software, Inc.
The Industry's Leading Provider of
Cross-Platform and Porting Services
*****************************
email: gaf@rtr.com Gary Feldman
fax : 1-978-692-5401 Ready-to-Run Software, Inc.
voice: 1-978-251-5431 11 School Street
www : http://www.rtr.com North Chelmsford, MA 01863
USA
Re: SOAP Messaging with Apache SOAP
Posted by Fred Meredith <fm...@nc.rr.com>.
I'd use a StringBuffer object to build the XML string the way you need it to
be and then do something like this:
DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
Document doc = xdb.parse(new InputSource(new
StringReader(stringBuffer.toString())));
Envelope env = Envelope.unmarshall(doc.getDocumentElement());
And then you can send the message:
Message msg = new Message();
msg.send(url, "", env);
That should get you started...
Hi all
Please forgive me if this is a daft question as I am relativley new to
Apache SOAP.
I am trying to send a SOAP message to a proprietry SOAP server, the
message looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:putPerson xmlns:m="http://www.myurl.org/gateway/"
TimeStampGMT="2002-01-18T10:26:22" Version="1.0">
<Name>ALEX</Name>
<Address>
<Line1>25 The Road</Line1>
<Town>London</Town>
<County>Sussex</County>
</Address>
</m:putPerson >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The problem I am having is how to create the structed XML for the Body
of the message. I can create a message using a flat structure, i.e
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:putPerson xmlns:m="http://www.myurl.org/gateway/"
TimeStampGMT="2002-01-18T10:26:22" Version="1.0">
<Name>ALEX</Name>
<Line1>25 The Road</Line1>
<Town>London</Town>
<County>Sussex</County>
</m:putPerson >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Is there a way to create the structured XML?
Thanks in advance
Alex
Re: SOAP Messaging with Apache SOAP
Posted by Fred Meredith <fm...@nc.rr.com>.
I'd use a StringBuffer object to build the XML string the way you need it to
be and then do something like this:
DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
Document doc = xdb.parse(new InputSource(new
StringReader(stringBuffer.toString())));
Envelope env = Envelope.unmarshall(doc.getDocumentElement());
And then you can send the message:
Message msg = new Message();
msg.send(url, "", env);
That should get you started...
Hi all
Please forgive me if this is a daft question as I am relativley new to
Apache SOAP.
I am trying to send a SOAP message to a proprietry SOAP server, the
message looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:putPerson xmlns:m="http://www.myurl.org/gateway/"
TimeStampGMT="2002-01-18T10:26:22" Version="1.0">
<Name>ALEX</Name>
<Address>
<Line1>25 The Road</Line1>
<Town>London</Town>
<County>Sussex</County>
</Address>
</m:putPerson >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The problem I am having is how to create the structed XML for the Body
of the message. I can create a message using a flat structure, i.e
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:putPerson xmlns:m="http://www.myurl.org/gateway/"
TimeStampGMT="2002-01-18T10:26:22" Version="1.0">
<Name>ALEX</Name>
<Line1>25 The Road</Line1>
<Town>London</Town>
<County>Sussex</County>
</m:putPerson >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Is there a way to create the structured XML?
Thanks in advance
Alex