Fix XMM scanning on Mac x86.
[mono.git] / mcs / class / System.Web.Services / Test / System.Web.Services.Protocols / SoapServerTypeTest.cs
1 //
2 // SoapServerTypeTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //
7 // Copyright (C) 2007 Novell, Inc.
8 //
9 #if !MOBILE
10 using NUnit.Framework;
11
12 using System;
13 using System.Globalization;
14 using System.IO;
15 using System.Reflection;
16 using System.Web.Services;
17 using System.Web.Services.Configuration;
18 using System.Web.Services.Description;
19 using System.Web.Services.Protocols;
20 using System.Xml.Schema;
21 using System.Xml.Serialization;
22
23 namespace MonoTests.System.Web.Services.Protocol
24 {
25         [TestFixture]
26         public class SoapServerTypeTest
27         {
28                 [Test]
29                 public void NamedServiceBinding ()
30                 {
31                         SoapServerType sst = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
32                         new ServerType (typeof (EdaInterface));
33
34                         SoapServerMethod m = sst.GetMethod ("urn:localBinding:local:LocalBindingMethod");
35                         Assert.IsNotNull (m, "#1");
36                         m = sst.GetMethod ("somethingFoo");
37                         Assert.IsNull (m, "#2");
38
39                         MethodInfo mi = typeof (EdaInterface).GetMethod ("BindingMethod");
40                         Assert.IsNotNull ("#3-1");
41                         m = sst.GetMethod (mi);
42                         // ... so, MethodInfo does not work as a key here.
43                         Assert.IsNull (m, "#3-2");
44                 }
45
46                 [Test]
47                 [ExpectedException (typeof (ArgumentNullException))]
48                 public void GetMethodNullKey ()
49                 {
50                         SoapServerType sst = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
51                         sst.GetMethod (null);
52                 }
53
54                 [Test]
55                 public void ConstructorHttpGet ()
56                 {
57                         SoapServerType st = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpGet);
58                         // I wonder if this property makes sense here ...
59                         Assert.IsTrue (st.ServiceRoutingOnSoapAction, "#1");
60                 }
61
62                 [Test]
63                 [ExpectedException (typeof (InvalidOperationException))]
64                 [Category ("NotWorking")]
65                 public void DuplicateBindingAttribute ()
66                 {
67                         new SoapServerType (typeof (DuplicateService), WebServiceProtocols.HttpSoap);
68                 }
69
70                 [Test]
71                 public void DuplicateBindingAttribute2 ()
72                 {
73                         // ServerType, not SoapServerType ... no failure.
74                         new ServerType (typeof (DuplicateService));
75                 }
76
77                 [Test]
78                 public void DuplicateBindingAttributeButNotInUse ()
79                 {
80                         new SoapServerType (typeof (DuplicateButUnusedService), WebServiceProtocols.AnyHttpSoap);
81                 }
82
83                 [Test]
84                 [ExpectedException (typeof (SoapException))]
85                 [Category ("NotWorking")]
86                 public void DuplicateMethodsWithSoapAction ()
87                 {
88                         new SoapServerType (typeof (WebService1), WebServiceProtocols.HttpSoap);
89                 }
90
91                 [Test]
92                 // still error because both methods have the same name (though
93                 // the error message seems saying that the element name 
94                 // conflicts with other "type" which I guess is the one built
95                 // from another conflicting method).
96                 [ExpectedException (typeof (InvalidOperationException))]
97                 [Category ("NotWorking")]
98                 public void DuplicateMethodsWithRequestElement1 ()
99                 {
100                         new SoapServerType (typeof (WebService2), WebServiceProtocols.HttpSoap);
101                 }
102
103                 [Test]
104                 [Category ("NotWorking")]
105                 public void DuplicateMethodsWithRequestElement2 ()
106                 {
107                         new SoapServerType (typeof (WebService3), WebServiceProtocols.HttpSoap);
108                 }
109
110                 [Test]
111                 [ExpectedException (typeof (InvalidOperationException))]
112                 public void WrongNamedServiceBinding ()
113                 {
114                         new SoapServerType (typeof (WrongBindingNameClass), WebServiceProtocols.HttpSoap);
115                 }
116
117                 [Test]
118                 public void SimpleRpcType ()
119                 {
120                         new SoapServerType (typeof (SimpleRpcService), WebServiceProtocols.HttpSoap);
121                 }
122
123                 [WebService]
124                 [SoapRpcService]
125                 public class SimpleRpcService : WebService
126                 {
127                         [WebMethod]
128                         public void Hello ()
129                         {
130                         }
131                 }
132
133                 // bug #78953
134                 [WebServiceAttribute (Namespace = "www.DefaultNamespace.org")]
135                 [WebServiceBindingAttribute (Name = "Local", Namespace = "urn:localBinding:local")]
136                 [WebServiceBindingAttribute (Name = "Local2", Namespace = "urn:localBinding:local2")]
137                 public class EdaInterface : WebService
138                 {
139                         [WebMethod]
140                         public void Test ()
141                         {
142                         }
143
144                         [WebMethod]
145                         [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
146                                 RequestNamespace = "urn:localBinding:local",
147                                 Binding = "Local",
148                                 Use = SoapBindingUse.Literal, 
149                                 ParameterStyle = SoapParameterStyle.Bare)]
150                         public void BindingMethod ()
151                         {
152                         }
153                 }
154
155                 [WebServiceBindingAttribute (Name = "Wrong", Namespace = "urn:localBinding:local")]
156                 public class WrongBindingNameClass : WebService
157                 {
158                         [WebMethod]
159                         public void Test ()
160                         {
161                         }
162
163                         [WebMethod]
164                         [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
165                                 RequestNamespace = "urn:localBinding:local",
166                                 Binding = "Local",
167                                 Use = SoapBindingUse.Literal, 
168                                 ParameterStyle = SoapParameterStyle.Bare)]
169                         public void BindingMethod ()
170                         {
171                         }
172                 }
173
174                 [WebServiceAttribute (Namespace = "www.DefaultNamespace.org")]
175                 [WebServiceBindingAttribute (Name = "Duplicate", Namespace = "urn:localBinding:local")]
176                 [WebServiceBindingAttribute (Name = "Duplicate", Namespace = "urn:localBinding:local")]
177                 public class DuplicateService : WebService
178                 {
179                         [WebMethod]
180                         public void Test ()
181                         {
182                         }
183
184                         [WebMethod]
185                         [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
186                                 RequestNamespace = "urn:localBinding:local",
187                                 Binding = "Duplicate",
188                                 Use = SoapBindingUse.Literal, 
189                                 ParameterStyle = SoapParameterStyle.Bare)]
190                         public void Foo ()
191                         {
192                         }
193                 }
194
195                 [WebServiceAttribute (Namespace = "www.DefaultNamespace.org")]
196                 [WebServiceBindingAttribute (Name = "Duplicate", Namespace = "urn:localBinding:local")]
197                 [WebServiceBindingAttribute (Name = "Duplicate", Namespace = "urn:localBinding:local")]
198                 [WebServiceBindingAttribute (Name = "Local", Namespace = "urn:localBinding:local")]
199                 public class DuplicateButUnusedService : WebService
200                 {
201                         [WebMethod]
202                         public void Test ()
203                         {
204                         }
205
206                         [WebMethod]
207                         [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
208                                 RequestNamespace = "urn:localBinding:local",
209                                 Binding = "Local",
210                                 Use = SoapBindingUse.Literal, 
211                                 ParameterStyle = SoapParameterStyle.Bare)]
212                         public void Foo ()
213                         {
214                         }
215                 }
216
217                 [WebService]
218                 public class WebService1 : WebService
219                 {
220                         [WebMethod]
221                         public void Test ()
222                         {
223                         }
224
225                         [WebMethod]
226                         [SoapDocumentMethodAttribute ("urn:foo:method1",
227                                 RequestNamespace = "urn:foo:method1",
228                                 Use = SoapBindingUse.Literal)]
229                         public void BindingMethod ()
230                         {
231                         }
232
233                         [WebMethod]
234                         [SoapDocumentMethodAttribute ("urn:foo:method1",
235                                 RequestNamespace = "urn:foo:method1",
236                                 Use = SoapBindingUse.Literal)]
237                         public void BindingMethod2 ()
238                         {
239                         }
240                 }
241
242                 [WebService]
243                 [SoapDocumentService (RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
244                 public class WebService2 : WebService
245                 {
246                         [WebMethod]
247                         public void Test ()
248                         {
249                         }
250
251                         [WebMethod]
252                         [SoapDocumentMethodAttribute ("urn:foo:method1",
253                                 RequestNamespace = "urn:foo:method1",
254                                 RequestElementName = "Element1",
255                                 Use = SoapBindingUse.Literal)]
256                         public void BindingMethod ()
257                         {
258                         }
259
260                         [WebMethod]
261                         [SoapDocumentMethodAttribute ("urn:foo:method1",
262                                 RequestNamespace = "urn:foo:method1",
263                                 RequestElementName = "Element1",
264                                 Use = SoapBindingUse.Literal)]
265                         public void BindingMethod2 ()
266                         {
267                         }
268                 }
269
270                 [WebService]
271                 [SoapDocumentService (RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
272                 public class WebService3 : WebService
273                 {
274                         [WebMethod]
275                         public void Test ()
276                         {
277                         }
278
279                         [WebMethod]
280                         [SoapDocumentMethodAttribute ("urn:foo:method1",
281                                 RequestNamespace = "urn:foo:method1",
282                                 RequestElementName = "Element1",
283                                 Use = SoapBindingUse.Literal)]
284                         public void BindingMethod ()
285                         {
286                         }
287
288                         [WebMethod]
289                         [SoapDocumentMethodAttribute ("urn:foo:method1",
290                                 RequestNamespace = "urn:foo:method1",
291                                 RequestElementName = "Element2",
292                                 Use = SoapBindingUse.Literal)]
293                         public void BindingMethod2 ()
294                         {
295                         }
296                 }
297         }
298 }
299 #endif