How to get the title string ("Hamlet") from web service answer. I think that C# should proces xml web service answer by itself. Why C# does not generate any class like
class Answer{
string title;
string body;
public string getTitle();
public string getBody();
}
Do i really have to process xml data returned by web service by myself?
It depends. What is the return type from the webservice? If its a Answer object (or any specific business object), than no you dont. If its an XMLDocument, then yes, you need to parse it yourself.
Is it returning a single string that contains "<book><title>Hamlet</title><body>To be or not to be</body></book>" in which case you need to use XSLT to get the value, other make the return type liek the following:
using System;
public class Answer
{
private string msBody = String.Empty;
private string msTitle = String.Empty;
/// <summary>
/// Body of book
/// </summary>
public string Body
{
get { return msBody; }
set { msBody = value; }
}
/// <summary>
/// Title of book
/// </summary>
public string Title
{
get { return msTitle; }
set { msTitle = value; }
}
}
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Marked as answer by Nice2007 on Jan 12, 2008 08:09 PM
Nice2007
Member
85 Points
78 Posts
How to process a web service answer?
Jan 12, 2008 10:25 AM|LINK
Hi
Suppose a web service returns a string:
<book>
<title>Hamlet</title>
<body>To be or not to be</body>
</book>
How to get the title string ("Hamlet") from web service answer. I think that C# should proces xml web service answer by itself. Why C# does not generate any class like
class Answer{
string title;
string body;
public string getTitle();
public string getBody();
}
Do i really have to process xml data returned by web service by myself?
Thanx :-)
nick-w
Contributor
2785 Points
558 Posts
Re: How to process a web service answer?
Jan 12, 2008 04:01 PM|LINK
It depends. What is the return type from the webservice? If its a Answer object (or any specific business object), than no you dont. If its an XMLDocument, then yes, you need to parse it yourself.
Nick
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: How to process a web service answer?
Jan 12, 2008 04:19 PM|LINK
Is it returning a single string that contains "<book><title>Hamlet</title><body>To be or not to be</body></book>" in which case you need to use XSLT to get the value, other make the return type liek the following:
using System;
public class Answer
{
private string msBody = String.Empty;
private string msTitle = String.Empty;
/// <summary>
/// Body of book
/// </summary>
public string Body
{
get { return msBody; }
set { msBody = value; }
}
/// <summary>
/// Title of book
/// </summary>
public string Title
{
get { return msTitle; }
set { msTitle = value; }
}
}
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Nice2007
Member
85 Points
78 Posts
Re: How to process a web service answer?
Jan 12, 2008 08:09 PM|LINK
Hi Tatworth,
It returns a single string so i see i have to use XSLT.
Thanx :-)