With all the talk going on I agree that this is bad:
[WebService]public class MyWebService{ [WebMethod] public string GetSomeXML() { // get some xml return xml; }}
And:
public class MyClient{ public static void Main() { MyWebService objWS = new MyWebService(); string strXML = objWS.GetSomeXML(); XmlDocument doc = new XmlDocument(); doc.LoadXml(strXml); // processing }}
A lot better (in most situations) is:
[WebService]public class MyWebService{ [WebMethod] public XmlDocument GetSomeXML() { // return xml }}
The former scenario serializes the document directly into the output SOAP stream, therefore bypassing double string (de)serialization.
There are special cases, when one would like to bypass the other approach (passing XML as XmlDocument) on the server side. If you have all the data ready and want to pass it as quickly as humanly possible, without rehydrating the entire full blown DOM-capable object, you would use System.String (xsd:string in the XML world) and System.Text.StringBuilder to contacenate it.
If you don't know what to choose I propose this:
In any case, things will change in late July or early August.
Remember Me
The opinions expressed herein are my own personal opinions and do not represent my company's view in any way.
My views often change.
This blog is just a collection of bytes.
Copyright © 2003-2024Matevž Gačnik
E-mail