Spot the web RSS 2.0
# Wednesday, December 24, 2008

Don't use your web methods to return strings as most programmers do, use them to return true XMLs.


instead of using this:

[WebMethod]
public string MyLameWebMethod()
{
XmlDocument dom = new XmlDocument();
// load XML Data ...
return dom.OuterXml;
}

Now when we want to read it on the client side we want the XML and then the operation is:
XML -> String -> XML


Use this:

[WebMethod]
public XmlDocument MyBetterWebMethod()
{
XmlDocument dom = new XmlDocument();
// load some XML ...
return dom;
}

Here we are skipping over the String step and using much more valid XML document.


Now you are avoiding an added level of transferring your XML document to string and then back to XML.
Wednesday, December 24, 2008 12:01:38 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
.Net | C# | XML
Comments are closed.
Navigation
Archive
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Guy Levin
Sign In
Statistics
Total Posts: 63
This Year: 0
This Month: 0
This Week: 0
Comments: 14
Themes
All Content © 2010, Guy Levin