From this example you can see that webservices is very tolerant of extra fields or missing fields. One issue though is that if you run one of the webservices and then update the other project's web reference it generates partial class code for your remote object in the namespace of the webservice. This is a problem.
For instance:
If you run the solution Version1 and then open the solution
Version2 and update the Web Reference in the project (you have to show hidden files) you get a file called Reference.cs.
In Reference.cs the system generates a wrapper for the class Foo
/// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml","2.0.50727.1378")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")]
public partial class Foo {...}
The problem is that when it does this it will return this object as when you call HelloWorld.
static void Main(string[] args) { ConsoleApplication1.localhost.Service1 s1 = new Service1(); MyLibrary.Foo f1 = new MyLibrary.Foo(); f1.Prop1 = "New"; MyLibrary.Foo f2 = (MyLibrary.Foo)s1.HelloWorld( f1); System.Console.WriteLine("F1.Prop1=" + f2.Prop1); }
Which is not what you want. The intended object is MyLibrary.Foo not ConsoleApplication1.localhost.Foo. Please figure out how prevent VS from creating the wrapper or any other solution.
Below are the project codes:
"MyLibrary.cs"
using System;using System.Data;using System.Configuration;using System.Xml;using System.Xml.Serialization;namespace MyLibrary{ public class Foo { private string m_prop1 = null; public string Prop1 { get { return m_prop1; } set { m_prop1 = value; } } private string m_prop2 = null; public string Prop2 { get { return m_prop2; } set { m_prop2 = value; } }
public Foo() { m_prop1 = "abc"; m_prop2 = "cde"; } }}
Console application: "Program.cs"
*** NOte *** localhost is the name of the web services when i add reference.