Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2005

Tip: Looking for answers? Try searching our database.

Best way to export XML from a web service.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gregory_may - 16 Feb 2005 23:17 GMT
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!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.