Merge pull request #2338 from BogdanovKirill/httpwritefix3
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel.Dispatcher / Bug652331_2Test.cs
1 //
2 // Authors:
3 //      David Straw
4 //      Atsushi Enomoto <atsushi@ximian.com>
5 //
6 // Copyright (C) 2011 Novell, Inc.  http://www.novell.com
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //
27 using System;
28 using System.Collections.Generic;
29 using System.Collections.ObjectModel;
30 using System.Linq;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Description;
34 using System.Threading;
35 using NUnit.Framework;
36
37 using WebServiceMoonlightTest.ServiceReference2;
38
39 using MonoTests.Helpers;
40
41 namespace MonoTests.System.ServiceModel.Dispatcher
42 {
43         [TestFixture]
44         public class Bug652331_2Test
45         {
46                 [Test]
47                 [Category ("NotWorking")]
48                 public void Bug652331_3 ()
49                 {
50                         // Init service
51                         ServiceHost serviceHost = new ServiceHost(typeof(Service1), new Uri("http://localhost:" + NetworkHelpers.FindFreePort () + "/Service1"));
52                         serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), string.Empty);
53
54                         // Enable metadata exchange (WSDL publishing)
55                         ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
56                         mexBehavior.HttpGetEnabled = true;
57                         serviceHost.Description.Behaviors.Add(mexBehavior);
58                         serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
59
60                         serviceHost.Open();
61
62                         try {
63                                 RunClient ();
64                         } finally {
65                                 serviceHost.Close ();
66                         }
67                 }
68
69                 void RunClient ()
70                 {
71                         var binding = new BasicHttpBinding ();
72                         var remoteAddress = new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort () + "/Service1");
73
74                         var normalClient      = new Service1Client (binding, remoteAddress);
75                         var collectionClient  = new Service1Client (binding, remoteAddress);
76                         var nestedClient      = new Service1Client (binding, remoteAddress);
77                         var dbClient          = new Service1Client (binding, remoteAddress);
78
79                         {
80                                 ManualResetEvent wait = new ManualResetEvent (false);
81                                 Exception error = null;
82                                 object result = null;
83
84                                 normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
85                                         try {
86                                                 error = e.Error;
87                                                 result = e.Error == null ? e.Result : null;
88                                         } finally {
89                                                 wait.Set ();
90                                         }
91                                 };
92                                 normalClient.GetDataAsync ();
93
94                                 Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#1 timeout");
95                                 Assert.IsNull (error, "#1.1, inner exception: {0}", error);
96                                 Assert.AreEqual ("A", ((DataType1) result).Id, "#1.2");
97                         }
98
99                         {
100                                 ManualResetEvent wait = new ManualResetEvent (false);
101                                 Exception error = null;
102                                 ObservableCollection<object> result = null;
103
104                                 collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
105                                         try {
106                                                 error = e.Error;
107                                                 result = e.Error == null ? e.Result : null;
108                                         } finally {
109                                                 wait.Set ();
110                                         }
111                                 };
112                                 collectionClient.GetCollectionDataAsync ();
113
114                                 Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#2 timeout");
115                                 Assert.IsNull (error, "#2.1, inner exception: {0}", error);
116                                 Assert.AreEqual ("B,C", ItemsToString (result.Cast<DataType1> ()), "#2.2");
117                         }
118
119                         {
120                                 ManualResetEvent wait = new ManualResetEvent (false);
121                                 Exception error = null;
122                                 WebServiceMoonlightTest.ServiceReference2.DataType2 result = null;
123
124                                 nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
125                                         try {
126                                                 error = e.Error;
127                                                 result = e.Error == null ? e.Result : null;
128                                         } finally {
129                                                 wait.Set ();
130                                         }
131                                 };
132                                 nestedClient.GetNestedDataAsync ();
133
134                                 Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#3 timeout");
135                                 Assert.IsNull (error, "#3.1, inner exception: {0}", error);
136                                 Assert.AreEqual ("D,E", ItemsToString (result.Items.Cast<DataType1> ()), "#3.2");
137                         }
138
139                         {
140                                 ManualResetEvent wait = new ManualResetEvent (false);
141                                 Exception error = null;
142                                 string result = null;
143
144                                 dbClient.JSMGetDatabasesCompleted += delegate (object sender, JSMGetDatabasesCompletedEventArgs e) {
145                                         try {
146                                                 error = e.Error;
147                                                 result = e.Error == null ? e.Result : null;
148                                         } finally {
149                                                 wait.Set ();
150                                         }
151                                 };
152                                 dbClient.JSMGetDatabasesAsync();
153
154                                 Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#4 timeout");
155                                 Assert.IsNull (error, "#4.1, inner exception: {0}", error);
156                                 Assert.AreEqual ("databases", result, "#4.2");
157                         }
158                 }
159
160                 string ItemsToString (IEnumerable<DataType1> items)
161                 {
162                         return items.Aggregate ((string) null, (result, item) => result == null ? item.Id : result + "," + item.Id);
163                 }
164         }
165
166         public class Service1 : IService1
167         {
168                 public object GetData()
169                 {
170                         return new DataType1 { Id = "A" };
171                 }
172
173                 Func<object> gd;
174                 public IAsyncResult BeginGetData(AsyncCallback cb, object st)
175                 {
176                         gd = new Func<object> (GetData);
177                         return gd.BeginInvoke (cb, st);
178                 }
179
180                 public object EndGetData (IAsyncResult result)
181                 {
182                         return gd.EndInvoke (result);
183                 }
184
185                 public ObservableCollection<object> GetCollectionData()
186                 {
187                         return new ObservableCollection<object> { new DataType1 { Id = "B" }, new DataType1 { Id = "C" } };
188                 }
189
190                 Func<ObservableCollection<object>> gcd;
191                 public IAsyncResult BeginGetCollectionData(AsyncCallback cb, object st)
192                 {
193                         gcd = new Func<ObservableCollection<object>> (GetCollectionData);
194                         return gcd.BeginInvoke (cb, st);
195                 }
196
197                 public ObservableCollection<object> EndGetCollectionData (IAsyncResult result)
198                 {
199                         return gcd.EndInvoke (result);
200                 }
201
202                 public DataType2 GetNestedData()
203                 {
204                         return new DataType2 { Items = new ObservableCollection<object> { new DataType1 { Id = "D" }, new DataType1 { Id = "E" } } };
205                 }
206
207                 Func<DataType2> gnd;
208                 public IAsyncResult BeginGetNestedData(AsyncCallback cb, object st)
209                 {
210                         gnd = new Func<DataType2> (GetNestedData);
211                         return gnd.BeginInvoke (cb, st);
212                 }
213
214                 public DataType2 EndGetNestedData (IAsyncResult result)
215                 {
216                         return gnd.EndInvoke (result);
217                 }
218
219                 public JSMGetDatabasesResponse JSMGetDatabases(JSMGetDatabasesRequest request)
220                 {
221                         return new JSMGetDatabasesResponse { JSMGetDatabasesResult = "databases" };
222                 }
223
224                 Func<JSMGetDatabasesRequest, JSMGetDatabasesResponse> gjgdb;
225                 public IAsyncResult BeginJSMGetDatabases(JSMGetDatabasesRequest request, AsyncCallback callback, object asyncState)
226                 {
227                         gjgdb = JSMGetDatabases;
228                         return gjgdb.BeginInvoke (request, callback, asyncState);
229                 }
230
231                 public JSMGetDatabasesResponse EndJSMGetDatabases(IAsyncResult result)
232                 {
233                         return gjgdb.EndInvoke (result);
234                 }
235         }
236 }
237
238
239 //------------------------------------------------------------------------------
240 // <auto-generated>
241 //     This code was generated by a tool.
242 //     Runtime Version:4.0.30319.372
243 //
244 //     Changes to this file may cause incorrect behavior and will be lost if
245 //     the code is regenerated.
246 // </auto-generated>
247 //------------------------------------------------------------------------------
248
249 // 
250 // This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.50826.0
251 // 
252 namespace WebServiceMoonlightTest.ServiceReference2 {
253     using System.Runtime.Serialization;
254     
255     
256     [System.Diagnostics.DebuggerStepThroughAttribute()]
257     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
258     [System.Runtime.Serialization.DataContractAttribute(Name="DataType1", Namespace="http://mynamespace")]
259     public partial class DataType1 : object, System.ComponentModel.INotifyPropertyChanged {
260         
261         private string IdField;
262         
263         [System.Runtime.Serialization.DataMemberAttribute()]
264         public string Id {
265             get {
266                 return this.IdField;
267             }
268             set {
269                 if ((object.ReferenceEquals(this.IdField, value) != true)) {
270                     this.IdField = value;
271                     this.RaisePropertyChanged("Id");
272                 }
273             }
274         }
275         
276         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
277         
278         protected void RaisePropertyChanged(string propertyName) {
279             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
280             if ((propertyChanged != null)) {
281                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
282             }
283         }
284     }
285     
286     [System.Diagnostics.DebuggerStepThroughAttribute()]
287     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
288     [System.Runtime.Serialization.DataContractAttribute(Name="DataType2", Namespace="http://mynamespace")]
289     [System.Runtime.Serialization.KnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
290     [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
291     public partial class DataType2 : object, System.ComponentModel.INotifyPropertyChanged {
292         
293         private System.Collections.ObjectModel.ObservableCollection<object> ItemsField;
294         
295         [System.Runtime.Serialization.DataMemberAttribute()]
296         public System.Collections.ObjectModel.ObservableCollection<object> Items {
297             get {
298                 return this.ItemsField;
299             }
300             set {
301                 if ((object.ReferenceEquals(this.ItemsField, value) != true)) {
302                     this.ItemsField = value;
303                     this.RaisePropertyChanged("Items");
304                 }
305             }
306         }
307         
308         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
309         
310         protected void RaisePropertyChanged(string propertyName) {
311             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
312             if ((propertyChanged != null)) {
313                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
314             }
315         }
316     }
317     
318     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
319     [System.ServiceModel.ServiceContractAttribute(Namespace="http://mynamespace", ConfigurationName="ServiceReference1.IService1")]
320     public interface IService1 {
321         
322         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetData", ReplyAction="http://mynamespace/IService1/GetDataResponse")]
323         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
324         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
325         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
326         System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState);
327         
328         object EndGetData(System.IAsyncResult result);
329         
330         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetCollectionData", ReplyAction="http://mynamespace/IService1/GetCollectionDataResponse")]
331         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
332         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
333         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
334         System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState);
335         
336         System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result);
337         
338         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetNestedData", ReplyAction="http://mynamespace/IService1/GetNestedDataResponse")]
339         System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState);
340         
341         WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result);
342
343         [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://mynamespace/IService1/JSMGetDatabases", ReplyAction = "http://mynamespace/IService1/JSMGetDatabasesResponse")]
344         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(object[]))]
345         System.IAsyncResult BeginJSMGetDatabases(JSMGetDatabasesRequest request, System.AsyncCallback callback, object asyncState);
346
347         JSMGetDatabasesResponse EndJSMGetDatabases(System.IAsyncResult result);
348     }
349
350 #region JSMGetDatabases
351     [System.Diagnostics.DebuggerStepThroughAttribute()]
352     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
353     [System.ServiceModel.MessageContractAttribute(WrapperName = "JSMGetDatabases", WrapperNamespace = "", IsWrapped = true)]
354     public partial class JSMGetDatabasesRequest
355     {
356
357         public JSMGetDatabasesRequest()
358         {
359         }
360     }
361
362     [System.Diagnostics.DebuggerStepThroughAttribute()]
363     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
364     [System.ServiceModel.MessageContractAttribute(WrapperName = "JSMGetDatabasesResponse", WrapperNamespace = "", IsWrapped = true)]
365     public partial class JSMGetDatabasesResponse
366     {
367
368         [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 0)]
369         [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
370         public string JSMGetDatabasesResult;
371
372         public JSMGetDatabasesResponse()
373         {
374         }
375
376         public JSMGetDatabasesResponse(string JSMGetDatabasesResult)
377         {
378             this.JSMGetDatabasesResult = JSMGetDatabasesResult;
379         }
380     }
381 #endregion
382
383     
384     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
385     public interface IService1Channel : WebServiceMoonlightTest.ServiceReference2.IService1, System.ServiceModel.IClientChannel {
386     }
387     
388     [System.Diagnostics.DebuggerStepThroughAttribute()]
389     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
390     public partial class GetDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
391         
392         private object[] results;
393         
394         public GetDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
395                 base(exception, cancelled, userState) {
396             this.results = results;
397         }
398         
399         public object Result {
400             get {
401                 base.RaiseExceptionIfNecessary();
402                 return ((object)(this.results[0]));
403             }
404         }
405     }
406     
407     [System.Diagnostics.DebuggerStepThroughAttribute()]
408     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
409     public partial class GetCollectionDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
410         
411         private object[] results;
412         
413         public GetCollectionDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
414                 base(exception, cancelled, userState) {
415             this.results = results;
416         }
417         
418         public System.Collections.ObjectModel.ObservableCollection<object> Result {
419             get {
420                 base.RaiseExceptionIfNecessary();
421                 return ((System.Collections.ObjectModel.ObservableCollection<object>)(this.results[0]));
422             }
423         }
424     }
425     
426     [System.Diagnostics.DebuggerStepThroughAttribute()]
427     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
428     public partial class GetNestedDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
429         
430         private object[] results;
431         
432         public GetNestedDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
433                 base(exception, cancelled, userState) {
434             this.results = results;
435         }
436         
437         public WebServiceMoonlightTest.ServiceReference2.DataType2 Result {
438             get {
439                 base.RaiseExceptionIfNecessary();
440                 return ((WebServiceMoonlightTest.ServiceReference2.DataType2)(this.results[0]));
441             }
442         }
443     }
444
445     [System.Diagnostics.DebuggerStepThroughAttribute()]
446     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
447     public partial class JSMGetDatabasesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
448     {
449
450         private object[] results;
451
452         public JSMGetDatabasesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
453             base(exception, cancelled, userState)
454         {
455             this.results = results;
456         }
457
458         public string Result
459         {
460             get
461             {
462                 base.RaiseExceptionIfNecessary();
463                 return ((string)(this.results[0]));
464             }
465         }
466     }
467     
468     [System.Diagnostics.DebuggerStepThroughAttribute()]
469     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
470     public partial class Service1Client : System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
471         
472         private BeginOperationDelegate onBeginGetDataDelegate;
473         
474         private EndOperationDelegate onEndGetDataDelegate;
475         
476         private System.Threading.SendOrPostCallback onGetDataCompletedDelegate;
477         
478         private BeginOperationDelegate onBeginGetCollectionDataDelegate;
479         
480         private EndOperationDelegate onEndGetCollectionDataDelegate;
481         
482         private System.Threading.SendOrPostCallback onGetCollectionDataCompletedDelegate;
483         
484         private BeginOperationDelegate onBeginGetNestedDataDelegate;
485         
486         private EndOperationDelegate onEndGetNestedDataDelegate;
487         
488         private System.Threading.SendOrPostCallback onGetNestedDataCompletedDelegate;
489         
490         private BeginOperationDelegate onBeginOpenDelegate;
491         
492         private EndOperationDelegate onEndOpenDelegate;
493         
494         private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
495         
496         private BeginOperationDelegate onBeginCloseDelegate;
497         
498         private EndOperationDelegate onEndCloseDelegate;
499         
500         private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
501         
502 #region JSMGetDatabasesDelegates
503         private BeginOperationDelegate onBeginJSMGetDatabasesDelegate;
504
505         private EndOperationDelegate onEndJSMGetDatabasesDelegate;
506
507         private System.Threading.SendOrPostCallback onJSMGetDatabasesCompletedDelegate;
508 #endregion
509
510         public Service1Client() {
511         }
512         
513         public Service1Client(string endpointConfigurationName) : 
514                 base(endpointConfigurationName) {
515         }
516         
517         public Service1Client(string endpointConfigurationName, string remoteAddress) : 
518                 base(endpointConfigurationName, remoteAddress) {
519         }
520         
521         public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
522                 base(endpointConfigurationName, remoteAddress) {
523         }
524         
525         public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
526                 base(binding, remoteAddress) {
527         }
528         
529 /*
530         public System.Net.CookieContainer CookieContainer {
531             get {
532                 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
533                 if ((httpCookieContainerManager != null)) {
534                     return httpCookieContainerManager.CookieContainer;
535                 }
536                 else {
537                     return null;
538                 }
539             }
540             set {
541                 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
542                 if ((httpCookieContainerManager != null)) {
543                     httpCookieContainerManager.CookieContainer = value;
544                 }
545                 else {
546                     throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
547                             "ookieContainerBindingElement.");
548                 }
549             }
550         }
551 */
552         
553         public event System.EventHandler<GetDataCompletedEventArgs> GetDataCompleted;
554         
555         public event System.EventHandler<GetCollectionDataCompletedEventArgs> GetCollectionDataCompleted;
556         
557         public event System.EventHandler<GetNestedDataCompletedEventArgs> GetNestedDataCompleted;
558         
559         public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
560         
561         public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
562
563         public event System.EventHandler<JSMGetDatabasesCompletedEventArgs> JSMGetDatabasesCompleted;
564
565         
566         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
567         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetData(System.AsyncCallback callback, object asyncState) {
568             return base.Channel.BeginGetData(callback, asyncState);
569         }
570         
571         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
572         object WebServiceMoonlightTest.ServiceReference2.IService1.EndGetData(System.IAsyncResult result) {
573             return base.Channel.EndGetData(result);
574         }
575         
576         private System.IAsyncResult OnBeginGetData(object[] inValues, System.AsyncCallback callback, object asyncState) {
577             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetData(callback, asyncState);
578         }
579         
580         private object[] OnEndGetData(System.IAsyncResult result) {
581             object retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetData(result);
582             return new object[] {
583                     retVal};
584         }
585         
586         private void OnGetDataCompleted(object state) {
587             if ((this.GetDataCompleted != null)) {
588                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
589                 this.GetDataCompleted(this, new GetDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
590             }
591         }
592         
593         public void GetDataAsync() {
594             this.GetDataAsync(null);
595         }
596         
597         public void GetDataAsync(object userState) {
598             if ((this.onBeginGetDataDelegate == null)) {
599                 this.onBeginGetDataDelegate = new BeginOperationDelegate(this.OnBeginGetData);
600             }
601             if ((this.onEndGetDataDelegate == null)) {
602                 this.onEndGetDataDelegate = new EndOperationDelegate(this.OnEndGetData);
603             }
604             if ((this.onGetDataCompletedDelegate == null)) {
605                 this.onGetDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetDataCompleted);
606             }
607             base.InvokeAsync(this.onBeginGetDataDelegate, null, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState);
608         }
609         
610         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
611         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
612             return base.Channel.BeginGetCollectionData(callback, asyncState);
613         }
614         
615         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
616         System.Collections.ObjectModel.ObservableCollection<object> WebServiceMoonlightTest.ServiceReference2.IService1.EndGetCollectionData(System.IAsyncResult result) {
617             return base.Channel.EndGetCollectionData(result);
618         }
619         
620         private System.IAsyncResult OnBeginGetCollectionData(object[] inValues, System.AsyncCallback callback, object asyncState) {
621             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetCollectionData(callback, asyncState);
622         }
623         
624         private object[] OnEndGetCollectionData(System.IAsyncResult result) {
625             System.Collections.ObjectModel.ObservableCollection<object> retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetCollectionData(result);
626             return new object[] {
627                     retVal};
628         }
629         
630         private void OnGetCollectionDataCompleted(object state) {
631             if ((this.GetCollectionDataCompleted != null)) {
632                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
633                 this.GetCollectionDataCompleted(this, new GetCollectionDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
634             }
635         }
636         
637         public void GetCollectionDataAsync() {
638             this.GetCollectionDataAsync(null);
639         }
640         
641         public void GetCollectionDataAsync(object userState) {
642             if ((this.onBeginGetCollectionDataDelegate == null)) {
643                 this.onBeginGetCollectionDataDelegate = new BeginOperationDelegate(this.OnBeginGetCollectionData);
644             }
645             if ((this.onEndGetCollectionDataDelegate == null)) {
646                 this.onEndGetCollectionDataDelegate = new EndOperationDelegate(this.OnEndGetCollectionData);
647             }
648             if ((this.onGetCollectionDataCompletedDelegate == null)) {
649                 this.onGetCollectionDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCollectionDataCompleted);
650             }
651             base.InvokeAsync(this.onBeginGetCollectionDataDelegate, null, this.onEndGetCollectionDataDelegate, this.onGetCollectionDataCompletedDelegate, userState);
652         }
653         
654         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
655         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
656             return base.Channel.BeginGetNestedData(callback, asyncState);
657         }
658         
659         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
660         WebServiceMoonlightTest.ServiceReference2.DataType2 WebServiceMoonlightTest.ServiceReference2.IService1.EndGetNestedData(System.IAsyncResult result) {
661             return base.Channel.EndGetNestedData(result);
662         }
663         
664         private System.IAsyncResult OnBeginGetNestedData(object[] inValues, System.AsyncCallback callback, object asyncState) {
665             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetNestedData(callback, asyncState);
666         }
667         
668         private object[] OnEndGetNestedData(System.IAsyncResult result) {
669             WebServiceMoonlightTest.ServiceReference2.DataType2 retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetNestedData(result);
670             return new object[] {
671                     retVal};
672         }
673         
674         private void OnGetNestedDataCompleted(object state) {
675             if ((this.GetNestedDataCompleted != null)) {
676                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
677                 this.GetNestedDataCompleted(this, new GetNestedDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
678             }
679         }
680         
681         public void GetNestedDataAsync() {
682             this.GetNestedDataAsync(null);
683         }
684         
685         public void GetNestedDataAsync(object userState) {
686             if ((this.onBeginGetNestedDataDelegate == null)) {
687                 this.onBeginGetNestedDataDelegate = new BeginOperationDelegate(this.OnBeginGetNestedData);
688             }
689             if ((this.onEndGetNestedDataDelegate == null)) {
690                 this.onEndGetNestedDataDelegate = new EndOperationDelegate(this.OnEndGetNestedData);
691             }
692             if ((this.onGetNestedDataCompletedDelegate == null)) {
693                 this.onGetNestedDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetNestedDataCompleted);
694             }
695             base.InvokeAsync(this.onBeginGetNestedDataDelegate, null, this.onEndGetNestedDataDelegate, this.onGetNestedDataCompletedDelegate, userState);
696         }
697         
698         private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
699             return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
700         }
701         
702         private object[] OnEndOpen(System.IAsyncResult result) {
703             ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
704             return null;
705         }
706         
707         private void OnOpenCompleted(object state) {
708             if ((this.OpenCompleted != null)) {
709                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
710                 this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
711             }
712         }
713         
714         public void OpenAsync() {
715             this.OpenAsync(null);
716         }
717         
718         public void OpenAsync(object userState) {
719             if ((this.onBeginOpenDelegate == null)) {
720                 this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
721             }
722             if ((this.onEndOpenDelegate == null)) {
723                 this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
724             }
725             if ((this.onOpenCompletedDelegate == null)) {
726                 this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
727             }
728             base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
729         }
730         
731         private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
732             return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
733         }
734         
735         private object[] OnEndClose(System.IAsyncResult result) {
736             ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
737             return null;
738         }
739         
740         private void OnCloseCompleted(object state) {
741             if ((this.CloseCompleted != null)) {
742                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
743                 this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
744             }
745         }
746
747 #region JSMGetDatabases
748         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
749         System.IAsyncResult IService1.BeginJSMGetDatabases(JSMGetDatabasesRequest request, System.AsyncCallback callback, object asyncState)
750         {
751             return base.Channel.BeginJSMGetDatabases(request, callback, asyncState);
752         }
753
754         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
755         private System.IAsyncResult BeginJSMGetDatabases(System.AsyncCallback callback, object asyncState)
756         {
757             JSMGetDatabasesRequest inValue = new JSMGetDatabasesRequest();
758             return ((IService1)(this)).BeginJSMGetDatabases(inValue, callback, asyncState);
759         }
760
761         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
762         JSMGetDatabasesResponse IService1.EndJSMGetDatabases(System.IAsyncResult result)
763         {
764             return base.Channel.EndJSMGetDatabases(result);
765         }
766
767         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
768         private string EndJSMGetDatabases(System.IAsyncResult result)
769         {
770             JSMGetDatabasesResponse retVal = ((IService1)(this)).EndJSMGetDatabases(result);
771             return retVal.JSMGetDatabasesResult;
772         }
773
774         private System.IAsyncResult OnBeginJSMGetDatabases(object[] inValues, System.AsyncCallback callback, object asyncState)
775         {
776             return this.BeginJSMGetDatabases(callback, asyncState);
777         }
778
779         private object[] OnEndJSMGetDatabases(System.IAsyncResult result)
780         {
781             string retVal = this.EndJSMGetDatabases(result);
782             return new object[] {
783                 retVal};
784         }
785
786         private void OnJSMGetDatabasesCompleted(object state)
787         {
788             if ((this.JSMGetDatabasesCompleted != null))
789             {
790                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
791                 this.JSMGetDatabasesCompleted(this, new JSMGetDatabasesCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
792             }
793         }
794
795         public void JSMGetDatabasesAsync()
796         {
797             this.JSMGetDatabasesAsync(null);
798         }
799
800         public void JSMGetDatabasesAsync(object userState)
801         {
802             if ((this.onBeginJSMGetDatabasesDelegate == null))
803             {
804                 this.onBeginJSMGetDatabasesDelegate = new BeginOperationDelegate(this.OnBeginJSMGetDatabases);
805             }
806             if ((this.onEndJSMGetDatabasesDelegate == null))
807             {
808                 this.onEndJSMGetDatabasesDelegate = new EndOperationDelegate(this.OnEndJSMGetDatabases);
809             }
810             if ((this.onJSMGetDatabasesCompletedDelegate == null))
811             {
812                 this.onJSMGetDatabasesCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnJSMGetDatabasesCompleted);
813             }
814             base.InvokeAsync(this.onBeginJSMGetDatabasesDelegate, null, this.onEndJSMGetDatabasesDelegate, this.onJSMGetDatabasesCompletedDelegate, userState);
815         }
816 #endregion
817         
818         public void CloseAsync() {
819             this.CloseAsync(null);
820         }
821         
822         public void CloseAsync(object userState) {
823             if ((this.onBeginCloseDelegate == null)) {
824                 this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
825             }
826             if ((this.onEndCloseDelegate == null)) {
827                 this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
828             }
829             if ((this.onCloseCompletedDelegate == null)) {
830                 this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
831             }
832             base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
833         }
834         
835 /*
836         protected override WebServiceMoonlightTest.ServiceReference2.IService1 CreateChannel() {
837             return new Service1ClientChannel(this);
838         }
839         
840         private class Service1ClientChannel : ChannelBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
841             
842             public Service1ClientChannel(System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1> client) : 
843                     base(client) {
844             }
845             
846             public System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState) {
847                 object[] _args = new object[0];
848                 System.IAsyncResult _result = base.BeginInvoke("GetData", _args, callback, asyncState);
849                 return _result;
850             }
851             
852             public object EndGetData(System.IAsyncResult result) {
853                 object[] _args = new object[0];
854                 object _result = ((object)(base.EndInvoke("GetData", _args, result)));
855                 return _result;
856             }
857             
858             public System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
859                 object[] _args = new object[0];
860                 System.IAsyncResult _result = base.BeginInvoke("GetCollectionData", _args, callback, asyncState);
861                 return _result;
862             }
863             
864             public System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result) {
865                 object[] _args = new object[0];
866                 System.Collections.ObjectModel.ObservableCollection<object> _result = ((System.Collections.ObjectModel.ObservableCollection<object>)(base.EndInvoke("GetCollectionData", _args, result)));
867                 return _result;
868             }
869             
870             public System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
871                 object[] _args = new object[0];
872                 System.IAsyncResult _result = base.BeginInvoke("GetNestedData", _args, callback, asyncState);
873                 return _result;
874             }
875             
876             public WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result) {
877                 object[] _args = new object[0];
878                 WebServiceMoonlightTest.ServiceReference2.DataType2 _result = ((WebServiceMoonlightTest.ServiceReference2.DataType2)(base.EndInvoke("GetNestedData", _args, result)));
879                 return _result;
880             }
881         }
882 */
883     }
884 }
885