JIMWU's WebLog

Xml parameter handling through SOAP

People have raised the question, "How do I use the new xml data type as a parameter through SOAP?"

Unfortunately, this isn't as clean as we like it.  For now this is what you would have to do if you are using Visual Studio 2005 Beta1:

   EndpointClass proxy = new EndpointClass();
   proxy.Credentials = // whatever credentials you want to use eg. System.Net.CredentialCache.DefaultCredentials;

   EndpointClass.xml a = new EndpointClass.xml();
   a.Any = new System.Xml.XmlNode[1];  // it's a node array.  for ease of example, I'm only creating an one node array.
   System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
   xDoc.LoadXml("<foo>bar</foo>");
   a.Any[0] = x.DocumentElement;

   EndpointClass.xml retXml = proxy.XmlMethod( a );
   System.Windows.Forms.MessageBox.Show(retXml.Any[0].OuterXml);

Flame me if there's a bug in my sample.

Published Monday, February 28, 2005 6:34 PM by jimwu

Comments

 

Xml parameter handling through SOAP said:

November 26, 2007 12:33 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker