<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx</link><description>I have probably seen a half a dozen article submissions to MSDN in the last year with authors who do the following: // Bad Bad Bad [WebMethod] public string MyLameWebMethod() { XmlDocument dom = new XmlDocument(); // load some XML ... return dom.OuterXml;</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>OK, I admit...</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130648</link><pubDate>Wed, 12 May 2004 21:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130648</guid><dc:creator>markorangel.com</dc:creator><description /></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130653</link><pubDate>Wed, 12 May 2004 19:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130653</guid><dc:creator>Jeff Perrin</dc:creator><description>What happens when you're accessing the service with another technology, like PHP or ASP?  (I really don't know this...)  I've created a few XML-RPC based web services that return xml documents as strings, which is exactly what an xml document is...  If a PHP client, for example, is accessing a .NET webservice with a return type of XmlDocument, can it easily process it?</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130683</link><pubDate>Wed, 12 May 2004 19:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130683</guid><dc:creator>brady gaster</dc:creator><description>AMEN (to the post, not the comment)</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130700</link><pubDate>Wed, 12 May 2004 19:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130700</guid><dc:creator>David Barnhill</dc:creator><description>Returning XmlDocument from a web server serializes itself to xml, so if you are accessing the web server from a non-.Net environment it still works OK.  What you save is the XmlDocument-&amp;gt;String and String-&amp;gt;XmlDocument conversions.  </description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130725</link><pubDate>Wed, 12 May 2004 20:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130725</guid><dc:creator>Matt Powell</dc:creator><description>As for interop, As David points out, XmlDocument basically just sticks XML in the body of the envelope so it should definitely be x-platform goodness.&lt;br&gt;&lt;br&gt;And by the way, I've done this too ... back in the early SOAP Toolkit days when a change in toolkit versions changed the wire protocol and we had to live with it until the next revision of our app.  But we fixed it as soon as we could - and appropriately repented.&lt;br&gt;</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130738</link><pubDate>Wed, 12 May 2004 21:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130738</guid><dc:creator>Mike Julier</dc:creator><description>So is this a question of changing the type of object that gets wrapped around the bytes?  It sounds like the bytes don't change but that perhaps they get copied.  Is this what the rant is about?</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130740</link><pubDate>Wed, 12 May 2004 21:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130740</guid><dc:creator>Matt Powell</dc:creator><description>The bytes do change.  Sending the string sends this:&lt;br&gt;&lt;br&gt;&amp;lt;envelope&amp;gt;&lt;br&gt;&amp;lt;body&amp;gt;&lt;br&gt;&amp;amp;lt;a&amp;amp;gt;&amp;amp;lt;b&amp;amp;gt;blah&amp;amp;lt;/b&amp;amp;gt;&amp;amp;lt;c&amp;amp;gt;blah&amp;amp;lt;/c&amp;amp;gt;&amp;amp;lt;/a&amp;amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/envelope&amp;gt;&lt;br&gt;&lt;br&gt;Sending the XML sends this:&lt;br&gt;&lt;br&gt;&amp;lt;envelope&amp;gt;&lt;br&gt;&amp;lt;body&amp;gt;&lt;br&gt;  &amp;lt;a&amp;gt;&lt;br&gt;    &amp;lt;b&amp;gt;blah&amp;lt;/b&amp;gt;&lt;br&gt;    &amp;lt;c&amp;gt;blah&amp;lt;/c&amp;gt;&lt;br&gt;  &amp;lt;/a&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/envelope&amp;gt;&lt;br&gt;&lt;br&gt;(I hope this formats okay in my comments.)&lt;br&gt;&lt;br&gt;   -Matt</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130745</link><pubDate>Wed, 12 May 2004 21:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130745</guid><dc:creator>Serban Florea</dc:creator><description>Well, it is somewhat cleaner (and safer), but it's not that we dispensed with serialization altogether...</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130848</link><pubDate>Thu, 13 May 2004 00:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130848</guid><dc:creator>David Taylor</dc:creator><description>Hi Matt,&lt;br&gt;&lt;br&gt;I have been working with the new MS CRM and note that it sends XML between the client and server as strings, which I also found frustrating!</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130883</link><pubDate>Thu, 13 May 2004 02:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130883</guid><dc:creator>Christoph Schittko </dc:creator><description>The office team is defined interfaces with stings containing XML for their research and translation web services as well. It would help if service interfaces published by Microsoft Web would follow best practices.&lt;br&gt;&lt;br&gt;I am sure many developers new to Web services will follow practices the see in interfaces published by the big guys. &lt;br&gt;&lt;br&gt;Christoph </description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130886</link><pubDate>Thu, 13 May 2004 02:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130886</guid><dc:creator>Simon Fell</dc:creator><description>All you need to do now is make the same fix in your products!, seriously go checkout the SOAP interface for MS-CRM, it blows chunks.</description></item><item><title>Rant continued: Some reasons...that don't usually apply</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130921</link><pubDate>Thu, 13 May 2004 06:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130921</guid><dc:creator>Matt Powell</dc:creator><description /></item><item><title>Take Outs for 12 May 2004</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#130943</link><pubDate>Thu, 13 May 2004 08:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:130943</guid><dc:creator>Enjoy Every Sandwich</dc:creator><description>Take Outs for 12 May 2004</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#131103</link><pubDate>Thu, 13 May 2004 13:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:131103</guid><dc:creator>kevin</dc:creator><description>Does this also apply to SignedXML objects? Can they be returned directly as well?</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#131200</link><pubDate>Thu, 13 May 2004 15:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:131200</guid><dc:creator>chadbr</dc:creator><description>What if you don't want the overhead of creating the DOM on the server in the 1st place?&lt;br&gt;&lt;br&gt;If you look @ a typical &amp;quot;read&amp;quot; stack it's:&lt;br&gt;&lt;br&gt;client request =&amp;gt; server =&amp;gt; some object(s) =&amp;gt; database (or data store) request&lt;br&gt;&lt;br&gt;(unwinding stack)&lt;br&gt;data results =&amp;gt; some data format =&amp;gt; soap serializer =&amp;gt; client&lt;br&gt;&lt;br&gt;Why would I want to take on the server overhead of &amp;quot;some data format&amp;quot; being a DOM? &lt;br&gt;&lt;br&gt;If I want to process the data from a database before it's sent back to the client, I probably want to process it in the form of a dataset or datareader -- neither returns a DOM – &lt;br&gt;&lt;br&gt;So are you suggesting the overhead of creating a DOM so it can be returned in native XML is worth the server overhead?&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#131309</link><pubDate>Thu, 13 May 2004 17:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:131309</guid><dc:creator>Michaeljon Miller</dc:creator><description>Yup, agreed about the MS-CRM interfaces. There's a lot of history around why they're shaped the way they are, but that doesn't really matter any more. We (that is, the MS-CRM team) are looking at a bunch of approaches to make this all better in upcoming releases and I'll try to post some information as I can.&lt;br&gt;&lt;br&gt;The problem was really one of timing and a requirement to handle type extensibility in the field. The timing problem is simple - the only tool available when we started MS-CRM was ATL server (and only in beta). Sure, we ended up slipping way past the VS.Net release date, but that's a different story. The type extensibility problem is that customers want to and need to change the shape of their entities on the fly. There were no types available for ATL server that we could leverage that could automatically extend (struct would never work, it's hard-coded in the type system), so we ended up choosing strings.&lt;br&gt;&lt;br&gt;XML strings as parameters suck. They suck at the programming model level for both the client and the service. Building XML strings is error prone to say the least. But they also suck for type safety reasons on the wire. Trust me, I've stared at enough netmon traces of our stuff to get dizzy - it would be tremendously better if we had objects.&lt;br&gt;&lt;br&gt;We're getting there. Slowly, but we're getting there. All I can recommend right now, and it's a short term hack, is to look at Dan Roger's &amp;lt;a href=&amp;quot;&lt;a target="_new" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=de0cc46b-4dea-4786-9eb0-8733e41bf5a8&amp;amp;DisplayLang=en&amp;quot;&amp;gt;XSDObjectGen&amp;lt;/a&amp;gt;"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=de0cc46b-4dea-4786-9eb0-8733e41bf5a8&amp;amp;DisplayLang=en&amp;quot;&amp;gt;XSDObjectGen&amp;lt;/a&amp;gt;&lt;/a&gt; tool and build classes from the XSD (it's what I do when I'm programming against the CRM SOAP interfaces). Although, on that topic, the V1.0 XSD were buggy out of the box. I think v1.2 fixed it and if not I might be persuaded to hand out the right fix.</description></item><item><title>Rant Continued: Avoiding the DOM?</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#131379</link><pubDate>Thu, 13 May 2004 22:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:131379</guid><dc:creator>Matt Powell</dc:creator><description /></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#132107</link><pubDate>Fri, 14 May 2004 18:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:132107</guid><dc:creator>Shaun McDonnell</dc:creator><description>What about Classic ASP object incompatability?&lt;br&gt;&lt;br&gt;For example, if I have an &amp;quot;Account&amp;quot; object on my .NET side of things and decide make that object a return value in my .NET Web Service, will ASP know how to handle the object?  I don't think so.&lt;br&gt;&lt;br&gt;In order to keep my .NET apps object-oriented, we just serialize our objects into Xml like this:&lt;br&gt;&lt;br&gt;&amp;lt;I&amp;gt;&lt;br&gt;Account asq = new Account()&lt;br&gt;StringWriter swQuery = new StringWriter();&lt;br&gt;			XmlSerializer xsQuery = new XmlSerializer(typeof(Account));&lt;br&gt;			xsQuery.Serialize(swQuery, asq);&lt;br&gt;return swQuery.ToString();&lt;br&gt;&amp;lt;/I&amp;gt;&lt;br&gt;&lt;br&gt;Is there a better way to do this in order to avoid returning a string of Xml?  I know the overhead is enormous and would love to know the answer.  Thanks!&lt;br&gt;&lt;br&gt;Shaun McDonnell&lt;br&gt;Citigroup</description></item><item><title>Rant continued again: Don't put XML in Strings</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#132222</link><pubDate>Fri, 14 May 2004 23:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:132222</guid><dc:creator>Matt Powell</dc:creator><description /></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#142602</link><pubDate>Wed, 26 May 2004 21:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:142602</guid><dc:creator>Tim Huffam</dc:creator><description>What about loose coupling?  &lt;br&gt;&lt;br&gt;Bundling various parameters into an primitive type like a string (like the MSCRM APIs do)provides a simple way to acheive loose coupling does it not?&lt;br&gt;&lt;br&gt;Tim</description></item><item><title>How to return well-formed XML from WebServices without the DOM: from XmlReader and XPathNavigator</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#144949</link><pubDate>Mon, 31 May 2004 19:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:144949</guid><dc:creator>TrackBack</dc:creator><description /></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#144952</link><pubDate>Mon, 31 May 2004 16:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:144952</guid><dc:creator>Daniel Cazzulino</dc:creator><description>It's not necessary at all to load a DOM to return well-formed XML from a webservice. And as the DOM will be the &amp;quot;legacy-deprecated-dying&amp;quot; API in .NET, it only makes sense to move to XmlReader and XPathNavigator-based processing.&lt;br&gt;Here's how you can return well-formed XML without wasting server resources in loading DOMs you don't need: &lt;a target="_new" href="http://weblogs.asp.net/cazzu/archive/2004/05/31/144922.aspx"&gt;http://weblogs.asp.net/cazzu/archive/2004/05/31/144922.aspx&lt;/a&gt; (How to return well-formed XML from WebServices without the DOM: from XmlReader and XPathNavigator)</description></item><item><title>re: Rant: Don't return XML in string variables!</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#180091</link><pubDate>Sun, 11 Jul 2004 17:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:180091</guid><dc:creator>yn</dc:creator><description>Why go through the trouble of instantiating an XmlDocument, XmlReader or even an XPathNavigator if you already have the XML as a string to begin with and have no interest in interacting with it in that context?&lt;br&gt;&lt;br&gt;Let's take Oracle's (9i+) xmltype for example. It holds and returns XML as CLOB, which you normally cast to string. Assuming I simply want to forward this record from Oracle to my client, without interacting with it at all, why waste time and space over deserialization?&lt;br&gt;&lt;br&gt;In the client I can simply (assuming client is the browser in this sample and 'result' is callService's callback argument):&lt;br&gt;&lt;br&gt;var xmlDoc=document.createElement(&amp;quot;xml&amp;quot;);&lt;br&gt;xmlDoc.loadXML(result.value);</description></item><item><title>National Weather (Web) Service</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#276010</link><pubDate>Tue, 07 Dec 2004 02:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:276010</guid><dc:creator>Matt Powell</dc:creator><description /></item><item><title>High-Performance Web Services: Avoid XmlNode, Use IXmlSerializable</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#570224</link><pubDate>Thu, 06 Apr 2006 22:45:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:570224</guid><dc:creator>Kirk Allen Evans' Blog</dc:creator><description>Avoid returning XmlNode from a web service method at all costs. &amp;nbsp;In this post, I show why you should avoid returning XmlNode in web services, and demonstrate how to use the IXmlSerializable interface in .NET 2.0 web services for high performance XML serialization</description></item><item><title> Matt Powell Rant Don t return XML in string variables | work from home</title><link>http://blogs.msdn.com/mpowell/archive/2004/05/12/130637.aspx#9761202</link><pubDate>Tue, 16 Jun 2009 15:09:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9761202</guid><dc:creator> Matt Powell Rant Don t return XML in string variables | work from home</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://workfromhomecareer.info/story.php?id=31774"&gt;http://workfromhomecareer.info/story.php?id=31774&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>