How to process a web service answer? http://forums.asp.net/t/1204653.aspx/1?How+to+process+a+web+service+answer+Sat, 12 Jan 2008 20:09:47 -050012046532105705http://forums.asp.net/p/1204653/2105705.aspx/1?How+to+process+a+web+service+answer+How to process a web service answer? <p>Hi </p> <p>Suppose a web service returns a string: </p> <p>&lt;book&gt;</p> <p>&lt;title&gt;Hamlet&lt;/title&gt;</p> <p>&lt;body&gt;To be or not to be&lt;/body&gt;</p> <p>&lt;/book&gt;</p> <p>How to get the title string (&quot;Hamlet&quot;) from web service answer. I think that C# should proces xml web service answer by itself. Why C# does not generate any class like</p> <p>class Answer{</p> <p>string title;</p> <p>string body;</p> <p>public string getTitle();</p> <p>public string getBody();</p> <p>}&nbsp;</p> <p>&nbsp;Do i really have to process xml data&nbsp;returned by web service by myself?</p> <p>&nbsp;</p> <p>Thanx :-)&nbsp;</p> <p>&nbsp;</p> 2008-01-12T10:25:52-05:002105919http://forums.asp.net/p/1204653/2105919.aspx/1?Re+How+to+process+a+web+service+answer+Re: How to process a web service answer? <p>It depends. What is the return type from the webservice?&nbsp; 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.</p> <p>&nbsp;</p> <p>Nick</p> 2008-01-12T16:01:55-05:002105933http://forums.asp.net/p/1204653/2105933.aspx/1?Re+How+to+process+a+web+service+answer+Re: How to process a web service answer? <p>&nbsp;Is it returning a single string that contains &quot;&lt;book&gt;&lt;title&gt;Hamlet&lt;/title&gt;&lt;body&gt;To be or not to be&lt;/body&gt;&lt;/book&gt;&quot; in which case you need to use XSLT to get the value, other make the return type liek the following:</p> <p>using System;<br> <br> <font face="courier new,courier">public class Answer<br> {<br> &nbsp; private string msBody = String.Empty;<br> &nbsp; private string msTitle = String.Empty;<br> <br> &nbsp; /// &lt;summary&gt;<br> &nbsp; /// Body of book<br> &nbsp; /// &lt;/summary&gt;<br> &nbsp; public string Body<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; get { return msBody;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; set { msBody = value;&nbsp; }<br> &nbsp; }<br> &nbsp; /// &lt;summary&gt;<br> &nbsp; /// Title of book<br> &nbsp; /// &lt;/summary&gt;<br> &nbsp; public string Title<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; get { return msTitle;&nbsp; }<br> &nbsp;&nbsp;&nbsp; set { msTitle = value; }<br> &nbsp; } <br> } </font><br> </p> 2008-01-12T16:19:57-05:002106097http://forums.asp.net/p/1204653/2106097.aspx/1?Re+How+to+process+a+web+service+answer+Re: How to process a web service answer? <p>Hi Tatworth,</p> <p>It returns a single string so i see i have to use XSLT.</p> <p>Thanx :-)</p> <p>&nbsp;</p> 2008-01-12T20:09:47-05:00