// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; namespace Ws.Soap2 { [DataContract(Namespace="http://soap.ws")] public class T1 { public T1() : this(0, "") { } public T1(int f1, string f2) { this.f1 = f1; this.f2 = f2; } [DataMember] public int f1 { get; set; } [DataMember] public string f2 { get; set; } } [ServiceContract(Name="Test",Namespace="http://soap.ws")] public interface ITest { [OperationContract] T1 getOne(int f1); [OperationContract] T1[] getAll(); [OperationContract] bool save(int f1, string f2); [OperationContract] bool saveObject(T1 o); [OperationContract] bool delete(int f1); } [ServiceBehavior(Namespace = "http://soap.ws/")] public class Test : ITest { public T1 getOne(int f1) { // dummy implementation return new T1(f1, "getOne"); } public T1[] getAll() { // dummy implementation T1[] res = new T1[3]; res[0] = new T1(1, "getAll #1"); res[1] = new T1(2, "getAll #2"); res[2] = new T1(3, "getAll #3"); return res; } public bool save(int f1, string f2) { // dummy implementation return f1 > 0 && f2.Length > 0; } public bool saveObject(T1 o) { // dummy implementation return o.f1 > 0 && o.f2.Length > 0; } public bool delete(int f1) { // dummy implementation return f1 > 0; } } }