[corlib] Use ManualResetEvent.WaitOne instead of Thread.Sleep to test Thread.Interrupt
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel / ChannelFactory_1Test.cs
1 //
2 // ChannelFactory_1Test.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2006 Novell, Inc.  http://www.novell.com
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using System;
30 using System.Collections.ObjectModel;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
34 using System.ServiceModel.Description;
35 using System.Threading;
36 using System.Xml;
37 using System.Xml.Serialization;
38 using MonoTests.System.ServiceModel.Channels;
39 using NUnit.Framework;
40
41 using MonoTests.Helpers;
42
43 namespace MonoTests.System.ServiceModel
44 {
45         [TestFixture]
46         public class ChannelFactory_1Test
47         {
48                 class MyChannelFactory<T> : ChannelFactory<T>
49                 {
50                         public MyChannelFactory (Binding b, EndpointAddress a)
51                                 : base (b, a)
52                         {
53                         }
54
55                         public void OpenAnyways ()
56                         {
57                                 EnsureOpened ();
58                         }
59                 }
60
61                 [Test]
62                 [ExpectedException (typeof (InvalidOperationException))]
63                 public void CreateChannelForClass ()
64                 {
65                         //ChannelFactory<TestService> f =
66                                 new ChannelFactory<TestService> (
67                                         new BasicHttpBinding (),
68                                         new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort ()));
69                 }
70
71                 [Test]
72                 public void EndpointAddressAfterCreateChannel ()
73                 {
74                         var f = new ChannelFactory<ITestService> (new BasicHttpBinding ());
75                         f.CreateChannel (new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort ()), null);
76                         Assert.IsNull (f.Endpoint.Address, "#1");
77                 }
78
79                 [Test]
80                 [Ignore ("fails under .NET; I never bothered to fix the test")]
81                 public void CtorNullArgsAllowed ()
82                 {
83                         ChannelFactory<ICtorUseCase1> f1;
84                         f1 = new ChannelFactory<ICtorUseCase1> ("CtorUseCase1_1", null);
85                         Assert.AreEqual (new EndpointAddress ("http://test1_1"), f1.Endpoint.Address, "#01");
86                         f1 = new ChannelFactory<ICtorUseCase1> (new BasicHttpBinding (), (EndpointAddress)null);
87                         Assert.AreEqual (null, f1.Endpoint.Address, "#01");
88                 }
89
90                 [Test]
91                 [ExpectedException (typeof (InvalidOperationException))]
92                 public void CreateChannelFromDefaultConfigWithTwoConfigs ()
93                 {
94                         new ChannelFactory<ICtorUseCase2> ("*");
95                 }
96
97                 [Test]
98                 [ExpectedException (typeof (InvalidOperationException))]
99                 public void CreateChannelFromDefaultConfigWithNoConfigs ()
100                 {
101                         new ChannelFactory<ICtorUseCase3> ("*");
102                 }
103
104                 [Test]
105                 [ExpectedException (typeof (ArgumentNullException))]
106                 public void CtorArgsTest1 ()
107                 {
108                         new ChannelFactory<ICtorUseCase1> (new BasicHttpBinding (), (string)null);
109                 }
110
111                 [Test]
112                 [ExpectedException (typeof (InvalidOperationException))]
113                 public void CtorArgsTest2 ()
114                 {
115                         new ChannelFactory<ICtorUseCase1> ("CtorUseCase1_Incorrect");
116                 }
117
118                 [Test]
119                 [ExpectedException (typeof (ArgumentNullException))]
120                 public void CtorArgsTest3 ()
121                 {
122                         new ChannelFactory<ICtorUseCase1> ((string)null, new EndpointAddress ("http://test"));
123                 }
124
125                 [Test]
126                 [ExpectedException (typeof (ArgumentNullException))]
127                 public void ConstructorNullServiceEndpoint ()
128                 {
129                         new ChannelFactory<IFoo> ((ServiceEndpoint) null);
130                 }
131
132                 [Test]
133                 [ExpectedException (typeof (ArgumentNullException))]
134                 public void ConstructorNullBinding ()
135                 {
136                         new ChannelFactory<IFoo> ((Binding) null);
137                 }
138
139                 [Test]
140                 public void ConfigEmptyCtor ()
141                 {
142                         // It has no valid configuration, but goes on.
143                         new ChannelFactory<ICtorUseCase1> ();
144                 }
145
146                 [Test]
147                 [ExpectedException (typeof (InvalidOperationException))]
148                 public void ConfigEmptyCtor2 ()
149                 {
150                         var cf = new ChannelFactory<ICtorUseCase1> ();
151                         // It cannot go on further.
152                         cf.CreateChannel ();
153                 }
154
155                 [Test]
156                 [Ignore ("fails under .NET; I never bothered to fix the test")]
157                 public void ConfigCtor ()
158                 {
159                         new ChannelFactory<ICtorUseCase1> ("CtorUseCase1_1");
160                 }
161
162                 [Test]
163                 public void EnsureOpened ()
164                 {
165                         MyChannelFactory<ITestService> f =
166                                 new MyChannelFactory<ITestService> (
167                                         new BasicHttpBinding (),
168                                         new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort ()));
169                         Assert.AreEqual (CommunicationState.Created,
170                                 f.State, "#1");
171                         f.OpenAnyways ();
172                         Assert.AreEqual (CommunicationState.Opened,
173                                 f.State, "#1");
174                 }
175
176                 [Test]
177                 // I was deceived by MSDN and currently ChannelFactory<T>
178                 // only accepts IChannel as T. It will be fixed. -> done.
179                 public void CreateChannel ()
180                 {
181                         ChannelFactory<ITestService> f =
182                                 new ChannelFactory<ITestService> (
183                                         new BasicHttpBinding (),
184                                         new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort ()));
185                         f.CreateChannel ();
186                 }
187
188                 private T CreateChannel<T> (RequestSender handler)
189                 {
190                         CustomBinding b = new CustomBinding (new HandlerTransportBindingElement (handler));
191                         ChannelFactory<T> f = new ChannelFactory<T> ( b, new EndpointAddress ("urn:dummy"));
192                         return f.CreateChannel ();
193                 }
194
195                 [Test]
196                 public void InvokeFoo ()
197                 {
198                         ITestService ts = CreateChannel<ITestService> (
199                                 delegate (Message input) {
200                                         BodyWriter bw = new HandlerBodyWriter (
201                                                 delegate (XmlDictionaryWriter writer) {
202                                                         writer.WriteStartElement ("FooResponse", "http://tempuri.org/");
203                                                         writer.WriteElementString ("FooResult", "http://tempuri.org/", "cecil");
204                                                         writer.WriteEndElement ();
205                                                 }
206                                         );
207                                         return Message.CreateMessage (input.Version, input.Headers.Action + "Response", bw);
208                                 }
209                         );
210                         Assert.AreEqual ("cecil", ts.Foo ("il offre sa confiance et son amour"));
211                 }
212
213                 [Test]
214                 public void InvokeBar ()
215                 {
216                         ITestService ts = CreateChannel<ITestService> (
217                                 delegate (Message input) {
218                                         BodyWriter bw = new HandlerBodyWriter (
219                                                 delegate (XmlDictionaryWriter writer) {
220                                                         writer.WriteStartElement ("BarResponse", "http://tempuri.org/");
221                                                         writer.WriteElementString ("DummyBarResponse", "http://tempuri.org/", "cecil");
222                                                         writer.WriteEndElement ();
223                                                 }
224                                         );
225                                         return Message.CreateMessage (input.Version, input.Headers.Action + "Response", bw);
226                                 }
227                         );
228                         ts.Bar ("il offre sa confiance et son amour");
229                 }
230
231                 Message ToMessage<T> (Message input, bool isXml, T val)
232                 {
233                         TypedMessageConverter tm;
234                         if (isXml)
235                                 tm = TypedMessageConverter.Create (typeof (T),
236                                         input.Headers.Action + "Response", new XmlSerializerFormatAttribute ());
237                         else
238                                 tm = TypedMessageConverter.Create (typeof (T),
239                                         input.Headers.Action + "Response");
240                         return tm.ToMessage (val, input.Version);
241                 }
242
243                 T FromMessage<T> (Message input, bool isXml)
244                 {
245                         TypedMessageConverter tm;
246                         if (isXml)
247                                 tm = TypedMessageConverter.Create (typeof (T), input.Headers.Action,
248                                         new XmlSerializerFormatAttribute ());
249                         else
250                                 tm = TypedMessageConverter.Create (typeof (T), input.Headers.Action);
251                         return (T)tm.FromMessage (input);
252                 }
253
254                 [Test]
255                 public void InvokeFooOutEnumParam ()
256                 {
257                         ITestService ts = CreateChannel<ITestService> (
258                                 delegate (Message input) {
259                                         // Test input for in and out Enum args.
260                                         XmlDocument doc = new XmlDocument ();
261                                         doc.LoadXml (input.ToString ());
262
263                                         XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
264                                         nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
265                                         nss.AddNamespace ("t", "http://tempuri.org/");
266                                         XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooOutEnumParam", nss) as XmlElement;
267                                         Assert.IsNotNull (el, "I#0");
268                                         XmlNode arg1 = el.SelectSingleNode ("t:arg1", nss);
269                                         Assert.IsNotNull (arg1, "I#2");
270                                         Assert.AreEqual ("Blue", arg1.InnerText, "I#3");
271
272                                         return ToMessage (input, false,
273                                                 new FooOutEnumParamResponse (FooColor.Green, FooColor.Red));
274                                 }
275                         );
276
277                         FooColor argOut;
278                         FooColor res = ts.FooOutEnumParam (FooColor.Blue, out argOut);
279                         Assert.AreEqual (FooColor.Green, res, "#1");
280                         Assert.AreEqual (FooColor.Red, argOut, "#2");
281                 }
282
283                 public T CreateVoidFooOutParamChannel<T> (bool isXml)
284                 {
285                         return CreateChannel<T> (
286                                 delegate (Message input) {
287                                         // Test input for in and ref args.
288                                         XmlDocument doc = new XmlDocument ();
289                                         doc.LoadXml (input.ToString ());
290
291                                         XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
292                                         nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
293                                         nss.AddNamespace ("t", "http://tempuri.org/");
294                                         XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:VoidFooOutParam", nss) as XmlElement;
295                                         Assert.IsNotNull (el, "I#0");
296                                         XmlNode arg1 = el.SelectSingleNode ("t:arg1", nss);
297                                         Assert.IsNotNull (arg1, "I#2");
298                                         Assert.AreEqual ("testIt", arg1.InnerText, "I#3");
299                                         XmlNode arg2 = el.SelectSingleNode ("t:arg2", nss);
300                                         Assert.IsNotNull (arg2, "I#4");
301                                         Assert.AreEqual ("testRef", arg2.InnerText, "I#4");
302
303                                         return ToMessage (input, isXml,
304                                                 new VoidFooOutParamResponse ("refArg", "outArg"));
305                                 }
306                         );
307                 }
308
309                 [Test]
310                 public void InvokeVoidFooOutParam ()
311                 {
312                         ITestService ts = CreateVoidFooOutParamChannel<ITestService> (false);
313                         string argRef = "testRef";
314                         string argOut;
315                         ts.VoidFooOutParam ("testIt", ref argRef, out argOut);
316                         Assert.AreEqual ("refArg", argRef, "#1");
317                         Assert.AreEqual ("outArg", argOut, "#2");
318                 }
319
320                 [Test]
321                 public void XmlInvokeVoidFooOutParam ()
322                 {
323                         ITestServiceXml ts = CreateVoidFooOutParamChannel<ITestServiceXml> (true);
324                         string argRef = "testRef";
325                         string argOut;
326                         ts.VoidFooOutParam ("testIt", ref argRef, out argOut);
327                         Assert.AreEqual ("refArg", argRef, "#1");
328                         Assert.AreEqual ("outArg", argOut, "#2");
329                 }
330
331                 public T CreateFooOutParamChannel<T> (bool isXml)
332                 {
333                         return CreateChannel<T> (
334                                 delegate (Message input) {
335                                         // Test input for in and ref args.
336                                         XmlDocument doc = new XmlDocument ();
337                                         doc.LoadXml (input.ToString ());
338
339                                         XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
340                                         nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
341                                         nss.AddNamespace ("t", "http://tempuri.org/");
342                                         XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooOutParam", nss) as XmlElement;
343                                         Assert.IsNotNull (el, "I#0");
344                                         XmlNode arg1 = el.SelectSingleNode ("t:arg1", nss);
345                                         Assert.IsNotNull (arg1, "I#2");
346                                         Assert.AreEqual ("testIt", arg1.InnerText, "I#3");
347                                         XmlNode arg2 = el.SelectSingleNode ("t:arg2", nss);
348                                         Assert.IsNotNull (arg2, "I#4");
349                                         Assert.AreEqual ("testRef", arg2.InnerText, "I#4");
350
351                                         return ToMessage (input, isXml,
352                                                 new FooOutParamResponse ("callResult", "refArg", "outArg"));
353                                 }
354                         );
355                 }
356
357                 [Test]
358                 public void InvokeFooOutParam ()
359                 {
360                         ITestService ts = CreateFooOutParamChannel<ITestService> (false);
361                         string argRef = "testRef";
362                         string argOut;
363                         string res = ts.FooOutParam ("testIt", ref argRef, out argOut);
364                         Assert.AreEqual ("callResult", res, "#1");
365                         Assert.AreEqual ("refArg", argRef, "#2");
366                         Assert.AreEqual ("outArg", argOut, "#3");
367                 }
368
369                 [Test]
370                 public void XmlInvokeFooOutParam ()
371                 {
372                         ITestServiceXml ts = CreateFooOutParamChannel<ITestServiceXml> (true);
373                         string argRef = "testRef";
374                         string argOut;
375                         string res = ts.FooOutParam ("testIt", ref argRef, out argOut);
376                         Assert.AreEqual ("callResult", res, "#1");
377                         Assert.AreEqual ("refArg", argRef, "#2");
378                         Assert.AreEqual ("outArg", argOut, "#3");
379                 }
380
381                 [Test]
382                 public void InvokeFooComplex ()
383                 {
384                         ITestService ts = CreateChannel<ITestService> (
385                                 delegate (Message input) {
386                                         // Test input for in and ref args.
387                                         XmlDocument doc = new XmlDocument ();
388                                         doc.LoadXml (input.ToString ());
389
390                                         XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
391                                         nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
392                                         nss.AddNamespace ("t", "http://tempuri.org/");
393                                         nss.AddNamespace ("v", "http://schemas.datacontract.org/2004/07/MonoTests.System.ServiceModel");
394                                         XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooComplex", nss) as XmlElement;
395                                         Assert.IsNotNull (el, "I#0");
396                                         XmlNode arg1 = el.SelectSingleNode ("t:arg1/v:val", nss);
397                                         Assert.IsNotNull (arg1, "I#2");
398                                         Assert.AreEqual ("testIt", arg1.InnerText, "I#3");
399
400                                         return ToMessage (input, false, new FooComplexResponse ("callResult"));
401                                 }
402                         );
403
404                         TestData res = ts.FooComplex (new TestData ("testIt"));
405                         Assert.IsNotNull (res, "#1");
406                         Assert.AreEqual ("callResult", res.val, "#2");
407                 }
408
409                 [Test]
410                 [Ignore ("This somehow results in an infinite loop")]
411                 public void XmlInvokeFooComplex ()
412                 {
413                         ITestServiceXml ts = CreateChannel<ITestServiceXml> (
414                                 delegate (Message input) {
415                                         // Test input for in and ref args.
416                                         XmlDocument doc = new XmlDocument ();
417                                         doc.LoadXml (input.ToString ());
418
419                                         XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
420                                         nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
421                                         nss.AddNamespace ("t", "http://tempuri.org/");
422                                         XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooComplex", nss) as XmlElement;
423                                         Assert.IsNotNull (el, "I#0");
424                                         XmlElement arg1 = el.SelectSingleNode ("t:arg1", nss) as XmlElement;
425                                         Assert.IsNotNull (arg1, "I#2");
426                                         Assert.AreEqual ("testIt", arg1.GetAttribute ("val"), "I#3");
427
428                                         return ToMessage (input, true, new FooComplexResponse ("callResult"));
429                                 }
430                         );
431
432                         TestData res = ts.FooComplex (new TestData ("testIt"));
433                         Assert.IsNotNull (res, "#1");
434                         Assert.AreEqual ("callResult", res.val, "#2");
435                 }
436
437 #if NET_4_0
438                 [Test]
439                 public void ConstructorServiceEndpoint ()
440                 {
441                         // It is okay to pass ServiceEndpoint that does not have Binding or EndpointAddress.
442                         new ChannelFactory<IRequestChannel> (new ServiceEndpoint (ContractDescription.GetContract (typeof (IMetadataExchange)), null, null));
443                 }
444 #endif
445
446                 public T CreateFooComplexMC_Channel<T> (bool isXml)
447                 {
448                         return CreateChannel<T> (
449                                 delegate (Message input) {
450                                         TestMessage arg = FromMessage<TestMessage> (input, isXml);
451                                         Assert.IsNotNull (arg.data, "I#0");
452                                         Assert.AreEqual (arg.data.val, "testIt", "I#1");
453                                         Assert.IsNotNull (arg.msg, "I#2");
454                                         Assert.AreEqual (arg.msg.val, "testMsg", "I#3");
455
456                                         return ToMessage (input, isXml, new TestResult ("callResult", "callArg"));
457                                 }
458                         );
459                 }
460
461                 [Test]
462                 public void InvokeFooComplexMC ()
463                 {
464                         ITestService ts = CreateFooComplexMC_Channel<ITestService> (false);
465                         TestResult res = ts.FooComplexMC (new TestMessage ("testIt", "testMsg"));
466                         Assert.IsNotNull (res, "#1");
467                         Assert.AreEqual ("callResult", res.resData.val, "#2");
468                         Assert.AreEqual ("callArg", res.resMsg.val, "#3");
469                 }
470
471                 [Test]
472                 [Ignore ("This somehow results in an infinite loop")]
473                 public void XmlInvokeFooComplexMC ()
474                 {
475                         ITestServiceXml ts = CreateFooComplexMC_Channel<ITestServiceXml> (true);
476                         TestResult res = ts.FooComplexMC (new TestMessage ("testIt", "testMsg"));
477                         Assert.IsNotNull (res, "#1");
478                         Assert.AreEqual ("callResult", res.resData.val, "#2");
479                         Assert.AreEqual ("callArg", res.resMsg.val, "#3");
480                 }
481
482                 [Test]
483                 public void OneWayOperationWithRequestReplyChannel ()
484                 {
485                         var host = new ServiceHost (typeof (OneWayService));
486                         host.AddServiceEndpoint (typeof (IOneWayService),
487                                 new BasicHttpBinding (),
488                                 new Uri ("http://localhost:30158"));
489                         host.Open ();
490                         try {
491                                 var cf = new ChannelFactory<IOneWayService> (
492                                         new BasicHttpBinding (),
493                                         new EndpointAddress ("http://localhost:30158"));
494                                 var ch = cf.CreateChannel ();
495                                 ch.GiveMessage ("test");
496                                 
497                                 Assert.IsTrue (OneWayService.WaitHandle.WaitOne (TimeSpan.FromSeconds (5)), "#1");
498                         } finally {
499                                 host.Close ();
500                         }
501                 }
502
503                 [ServiceContract]
504                 public interface ITestService
505                 {
506                         [OperationContract]
507                         string Foo (string arg);
508
509                         [OperationContract]
510                         void Bar (string arg);
511
512                         [OperationContract]
513                         void Foo1 (string arg1, string arg2);
514
515                         [OperationContract]
516                         FooColor FooOutEnumParam (FooColor arg1, out FooColor arg2);
517
518                         [OperationContract]
519                         string FooOutParam (string arg1, ref string arg2, out string arg3);
520
521                         [OperationContract]
522                         void VoidFooOutParam (string arg1, ref string arg2, out string arg3);
523
524                         [OperationContract]
525                         TestData FooComplex (TestData arg1);
526
527                         [OperationContract]
528                         TestResult FooComplexMC (TestMessage arg1);
529                 }
530
531                 [ServiceContract]
532                 public interface ITestServiceXml
533                 {
534                         [OperationContract]
535                         string FooOutParam (string arg1, ref string arg2, out string arg3);
536
537                         [OperationContract]
538                         void VoidFooOutParam (string arg1, ref string arg2, out string arg3);
539
540                         [OperationContract]
541                         [XmlSerializerFormat]
542                         TestData FooComplex (TestData arg1);
543
544                         [OperationContract]
545                         [XmlSerializerFormat]
546                         TestResult FooComplexMC (TestMessage arg1);
547                 }
548
549                 [ServiceContract]
550                 public interface IOneWayService
551                 {
552                         [OperationContract (IsOneWay = true)]
553                         void GiveMessage (string input);
554                 }
555
556                 public class OneWayService : IOneWayService
557                 {
558                         public static ManualResetEvent WaitHandle = new ManualResetEvent (false);
559
560                         public void GiveMessage (string input)
561                         {
562                                 WaitHandle.Set ();
563                         }
564                 }
565
566                 public enum FooColor { Red = 1, Green, Blue }
567
568                 [DataContract]
569                 public class TestData
570                 {
571                         TestData () {}
572                         public TestData (string val) { this.val = val; }
573
574                         [DataMember]
575                         [XmlAttribute]
576                         public string val;
577                 }
578
579                 [MessageContract]
580                 public class TestMessage
581                 {
582                         TestMessage () {}
583                         public TestMessage (string a, string b) { data = new TestData (a); msg = new TestData (b); }
584
585                         [MessageBodyMember]
586                         public TestData data;
587
588                         [MessageBodyMember]
589                         public TestData msg;
590                 }
591
592                 [MessageContract]
593                 public class TestResult
594                 {
595                         TestResult () {}
596                         public TestResult (string a, string b) { resData = new TestData (a); resMsg = new TestData (b); }
597
598                         [MessageBodyMember]
599                         public TestData resData;
600
601                         [MessageBodyMember]
602                         public TestData resMsg;
603                 }
604
605                 [MessageContract (WrapperNamespace = "http://tempuri.org/")]
606                 class FooOutParamResponse
607                 {
608                         FooOutParamResponse () {}
609                         public FooOutParamResponse (string ret, string refArg, string outArg) { FooOutParamResult = ret; this.arg2 = refArg; this.arg3 = outArg; }
610
611                         [MessageBodyMember]
612                         public string FooOutParamResult;
613
614                         [MessageBodyMember]
615                         public string arg2;
616
617                         [MessageBodyMember]
618                         public string arg3;
619                 }
620
621                 [MessageContract (WrapperNamespace = "http://tempuri.org/")]
622                 class FooOutEnumParamResponse
623                 {
624                         FooOutEnumParamResponse () {}
625                         public FooOutEnumParamResponse (FooColor ret, FooColor outArg) { FooOutEnumParamResult = ret; this.arg2 = outArg; }
626
627                         [MessageBodyMember]
628                         public FooColor FooOutEnumParamResult;
629
630                         [MessageBodyMember]
631                         public FooColor arg2;
632                 }
633
634                 [MessageContract (WrapperNamespace = "http://tempuri.org/")]
635                 class VoidFooOutParamResponse
636                 {
637                         VoidFooOutParamResponse () {}
638                         public VoidFooOutParamResponse (string refArg, string outArg) { this.arg2 = refArg; this.arg3 = outArg; }
639
640                         [MessageBodyMember]
641                         public string arg2;
642
643                         [MessageBodyMember]
644                         public string arg3;
645                 }
646
647                 [MessageContract (WrapperNamespace = "http://tempuri.org/")]
648                 class FooComplexResponse
649                 {
650                         FooComplexResponse () {}
651                         public FooComplexResponse (string val) { FooComplexResult  = new TestData (val); }
652
653                         [MessageBodyMember]
654                         public TestData FooComplexResult;
655                 }
656
657                 class TestService
658                 {
659                         public string Foo (string arg)
660                         {
661                                 return arg;
662                         }
663                 }
664         }
665 }