I have a web service that is returning several data elements. Currently I
am just exporting as a single string element with Pipe delimiters between my
data.
How do I "return" my data elements as an XML structure (rather than one big
string)?
Thanks!
Michael Barnhart - 17 Feb 2005 02:26 GMT
Hello gregory_may,
You can declare the return type to be an XmlElement such as
[WebMethod]
public XmlElement MethodX(XmlElement UserInfo, XmlElement DataItem)
{}
The client then has to handle the XML document manually versus having some
wizard parse the individual elements.
> I have a web service that is returning several data elements.
> Currently I am just exporting as a single string element with Pipe
[quoted text clipped - 4 lines]
>
> Thanks!
Brad Wood - 17 Feb 2005 14:45 GMT
> How do I "return" my data elements as an XML structure (rather than one big
> string)?
Use an XmlTextWriter like yay:
new XmlTextWriter( new StringWriter );
.WriteStartDocument()
.WriteStartElement()
.WriteAttributeString("whatever")
// add more stuff
.WriteEndElement();
.WriteEndDocument();
Then return the xml string when finished:
StringWriter.GetStringBuilder().ToString()
gregory_may - 17 Feb 2005 20:01 GMT
Good feedback. Let me take a look at this. Probably be a day or two.
>I have a web service that is returning several data elements. Currently I
>am just exporting as a single string element with Pipe delimiters between
[quoted text clipped - 4 lines]
>
> Thanks!
Ghislain Tanguay - 18 Feb 2005 18:57 GMT
Simply create a Structure not a class or XML string.
It will be more easy to work with from the client side with Intelisense.
<WebMethod> _
public function GetUser(byval ID as integer) as User
....
end function
Public Structure User
Public UserName as string
....
End Structure
> I have a web service that is returning several data elements. Currently I
> am just exporting as a single string element with Pipe delimiters between my
[quoted text clipped - 4 lines]
>
> Thanks!