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 Ni...@progressive.com on 2002/08/20 20:47:11 UTC

XML response in SOAP message ???

Hello everyone..

I have successfully used SOAP to make a telephone directory Web service.

Right now I am returning "String" as return type from my Web service method
back to the client and my client displays the string in HTML based browser.

I was wondering if there is a way by which I can return the "XML" response
(or
XML return type) from SOAP web service method
to client code which will parse the XML to produce Stylesheet-based tabular
output.

Here's the section of code from my SOAP method, I was trying to play with:

/*** variable declaration***/
String mainStr;
.....
.....

/*** assigning initial value to mainStr****/

mainStr = "<?xml version=\"1.0\"?> ";
.......
......
..
/*** creation of recordset based on some SQL query *******/

while (rs.next())
{
                                firstn = rs.getString(1);
                             lastn = rs.getString(2);
                          phone = rs.getString(3);
                             pager = rs.getString(5);
                             home = rs.getString(6);
                             count = count+1;

          /**** trying to create a XML string here which can then be
returned *****/

                          mainStr = mainStr + " <Employee_Info> <Firstname>
"+ firstn +" </Firstname><Lastname> "+lastn + " </Lastname> "+" <Extension>
"+ phone +" </Extension> "+" <Pager> "+pager+" </Pager> "+ " <Home> "+ home
+" </Home></Employee_Info>" + "\n";
}
.......
......
/**** returning XML string *****/

return mainSTr;

Now when I am trying to return a string in the form of XML it is not
showing any XML tags at
web browser side.

I was wondering why my the string my client application recieves doesnot
see XML tags and
displays simple string showing firstname, lastname, phone,..etc

Thanks a lot in advance.

Nishant Awasthi
330-328-0243 (cell)
nishant_awasthi@progressive.com


Re: XML response in SOAP message ???

Posted by Scott Nichol <sn...@scottnichol.com>.
>>>>
If the client that calls the SOAP method correctly "un-escapes" these
sequences, the resulting string will look like the string of XML text you
created.
<<<<

I put this out there rather cavalierly: I don't think the Apache SOAP client
un-escape this on its own.

Scott Nichol



--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: XML response in SOAP message ???

Posted by Scott Nichol <sn...@scottnichol.com>.
>>>>
If the client that calls the SOAP method correctly "un-escapes" these
sequences, the resulting string will look like the string of XML text you
created.
<<<<

I put this out there rather cavalierly: I don't think the Apache SOAP client
un-escape this on its own.

Scott Nichol



Re: XML response in SOAP message ???

Posted by Scott Nichol <sn...@scottnichol.com>.
The string being returned from the SOAP method must itself be embedded
within an XML document, so it is "escaped", e.g. '<' is turned into '&lt;'.
If the client that calls the SOAP method correctly "un-escapes" these
sequences, the resulting string will look like the string of XML text you
created.

An alternative is to have the SOAP method return a DOM Element using literal
XML encoding, and instead of creating an XML string within the method,
create the DOM representation of the phone book entry.   This works great
for Apache SOAP, e.g. in the GetAllListings addressbook sample.  However, it
does not interoperate with other SOAP implementations.

Scott Nichol

----- Original Message -----
From: <Ni...@progressive.com>
To: <so...@xml.apache.org>
Cc: <so...@xml.apache.org>
Sent: Tuesday, August 20, 2002 2:47 PM
Subject: XML response in SOAP message ???


Hello everyone..

I have successfully used SOAP to make a telephone directory Web service.

Right now I am returning "String" as return type from my Web service method
back to the client and my client displays the string in HTML based browser.

I was wondering if there is a way by which I can return the "XML" response
(or
XML return type) from SOAP web service method
to client code which will parse the XML to produce Stylesheet-based tabular
output.

Here's the section of code from my SOAP method, I was trying to play with:

/*** variable declaration***/
String mainStr;
.....
.....

/*** assigning initial value to mainStr****/

mainStr = "<?xml version=\"1.0\"?> ";
.......
......
..
/*** creation of recordset based on some SQL query *******/

while (rs.next())
{
                                firstn = rs.getString(1);
                             lastn = rs.getString(2);
                          phone = rs.getString(3);
                             pager = rs.getString(5);
                             home = rs.getString(6);
                             count = count+1;

          /**** trying to create a XML string here which can then be
returned *****/

                          mainStr = mainStr + " <Employee_Info> <Firstname>
"+ firstn +" </Firstname><Lastname> "+lastn + " </Lastname> "+" <Extension>
"+ phone +" </Extension> "+" <Pager> "+pager+" </Pager> "+ " <Home> "+ home
+" </Home></Employee_Info>" + "\n";
}
.......
......
/**** returning XML string *****/

return mainSTr;

Now when I am trying to return a string in the form of XML it is not
showing any XML tags at
web browser side.

I was wondering why my the string my client application recieves doesnot
see XML tags and
displays simple string showing firstname, lastname, phone,..etc

Thanks a lot in advance.

Nishant Awasthi
330-328-0243 (cell)
nishant_awasthi@progressive.com


--
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: XML response in SOAP message ???

Posted by Scott Nichol <sn...@scottnichol.com>.
The string being returned from the SOAP method must itself be embedded
within an XML document, so it is "escaped", e.g. '<' is turned into '&lt;'.
If the client that calls the SOAP method correctly "un-escapes" these
sequences, the resulting string will look like the string of XML text you
created.

An alternative is to have the SOAP method return a DOM Element using literal
XML encoding, and instead of creating an XML string within the method,
create the DOM representation of the phone book entry.   This works great
for Apache SOAP, e.g. in the GetAllListings addressbook sample.  However, it
does not interoperate with other SOAP implementations.

Scott Nichol

----- Original Message -----
From: <Ni...@progressive.com>
To: <so...@xml.apache.org>
Cc: <so...@xml.apache.org>
Sent: Tuesday, August 20, 2002 2:47 PM
Subject: XML response in SOAP message ???


Hello everyone..

I have successfully used SOAP to make a telephone directory Web service.

Right now I am returning "String" as return type from my Web service method
back to the client and my client displays the string in HTML based browser.

I was wondering if there is a way by which I can return the "XML" response
(or
XML return type) from SOAP web service method
to client code which will parse the XML to produce Stylesheet-based tabular
output.

Here's the section of code from my SOAP method, I was trying to play with:

/*** variable declaration***/
String mainStr;
.....
.....

/*** assigning initial value to mainStr****/

mainStr = "<?xml version=\"1.0\"?> ";
.......
......
..
/*** creation of recordset based on some SQL query *******/

while (rs.next())
{
                                firstn = rs.getString(1);
                             lastn = rs.getString(2);
                          phone = rs.getString(3);
                             pager = rs.getString(5);
                             home = rs.getString(6);
                             count = count+1;

          /**** trying to create a XML string here which can then be
returned *****/

                          mainStr = mainStr + " <Employee_Info> <Firstname>
"+ firstn +" </Firstname><Lastname> "+lastn + " </Lastname> "+" <Extension>
"+ phone +" </Extension> "+" <Pager> "+pager+" </Pager> "+ " <Home> "+ home
+" </Home></Employee_Info>" + "\n";
}
.......
......
/**** returning XML string *****/

return mainSTr;

Now when I am trying to return a string in the form of XML it is not
showing any XML tags at
web browser side.

I was wondering why my the string my client application recieves doesnot
see XML tags and
displays simple string showing firstname, lastname, phone,..etc

Thanks a lot in advance.

Nishant Awasthi
330-328-0243 (cell)
nishant_awasthi@progressive.com


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>