2 // SoapServerTypeTest.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2007 Novell, Inc.
10 using NUnit.Framework;
13 using System.Globalization;
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;
23 namespace MonoTests.System.Web.Services.Protocol
26 public class SoapServerTypeTest
29 public void NamedServiceBinding ()
31 SoapServerType sst = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
32 new ServerType (typeof (EdaInterface));
34 SoapServerMethod m = sst.GetMethod ("urn:localBinding:local:LocalBindingMethod");
35 Assert.IsNotNull (m, "#1");
36 m = sst.GetMethod ("somethingFoo");
37 Assert.IsNull (m, "#2");
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");
47 [ExpectedException (typeof (ArgumentNullException))]
48 public void GetMethodNullKey ()
50 SoapServerType sst = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
55 public void ConstructorHttpGet ()
57 SoapServerType st = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpGet);
58 // I wonder if this property makes sense here ...
59 Assert.IsTrue (st.ServiceRoutingOnSoapAction, "#1");
63 [ExpectedException (typeof (InvalidOperationException))]
64 [Category ("NotWorking")]
65 public void DuplicateBindingAttribute ()
67 new SoapServerType (typeof (DuplicateService), WebServiceProtocols.HttpSoap);
71 public void DuplicateBindingAttribute2 ()
73 // ServerType, not SoapServerType ... no failure.
74 new ServerType (typeof (DuplicateService));
78 public void DuplicateBindingAttributeButNotInUse ()
80 new SoapServerType (typeof (DuplicateButUnusedService), WebServiceProtocols.AnyHttpSoap);
84 [ExpectedException (typeof (SoapException))]
85 [Category ("NotWorking")]
86 public void DuplicateMethodsWithSoapAction ()
88 new SoapServerType (typeof (WebService1), WebServiceProtocols.HttpSoap);
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 ()
100 new SoapServerType (typeof (WebService2), WebServiceProtocols.HttpSoap);
104 [Category ("NotWorking")]
105 public void DuplicateMethodsWithRequestElement2 ()
107 new SoapServerType (typeof (WebService3), WebServiceProtocols.HttpSoap);
111 [ExpectedException (typeof (InvalidOperationException))]
112 public void WrongNamedServiceBinding ()
114 new SoapServerType (typeof (WrongBindingNameClass), WebServiceProtocols.HttpSoap);
118 public void SimpleRpcType ()
120 new SoapServerType (typeof (SimpleRpcService), WebServiceProtocols.HttpSoap);
125 public class SimpleRpcService : WebService
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
145 [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
146 RequestNamespace = "urn:localBinding:local",
148 Use = SoapBindingUse.Literal,
149 ParameterStyle = SoapParameterStyle.Bare)]
150 public void BindingMethod ()
155 [WebServiceBindingAttribute (Name = "Wrong", Namespace = "urn:localBinding:local")]
156 public class WrongBindingNameClass : WebService
164 [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
165 RequestNamespace = "urn:localBinding:local",
167 Use = SoapBindingUse.Literal,
168 ParameterStyle = SoapParameterStyle.Bare)]
169 public void BindingMethod ()
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
185 [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
186 RequestNamespace = "urn:localBinding:local",
187 Binding = "Duplicate",
188 Use = SoapBindingUse.Literal,
189 ParameterStyle = SoapParameterStyle.Bare)]
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
207 [SoapDocumentMethodAttribute ("urn:localBinding:local:LocalBindingMethod",
208 RequestNamespace = "urn:localBinding:local",
210 Use = SoapBindingUse.Literal,
211 ParameterStyle = SoapParameterStyle.Bare)]
218 public class WebService1 : WebService
226 [SoapDocumentMethodAttribute ("urn:foo:method1",
227 RequestNamespace = "urn:foo:method1",
228 Use = SoapBindingUse.Literal)]
229 public void BindingMethod ()
234 [SoapDocumentMethodAttribute ("urn:foo:method1",
235 RequestNamespace = "urn:foo:method1",
236 Use = SoapBindingUse.Literal)]
237 public void BindingMethod2 ()
243 [SoapDocumentService (RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
244 public class WebService2 : WebService
252 [SoapDocumentMethodAttribute ("urn:foo:method1",
253 RequestNamespace = "urn:foo:method1",
254 RequestElementName = "Element1",
255 Use = SoapBindingUse.Literal)]
256 public void BindingMethod ()
261 [SoapDocumentMethodAttribute ("urn:foo:method1",
262 RequestNamespace = "urn:foo:method1",
263 RequestElementName = "Element1",
264 Use = SoapBindingUse.Literal)]
265 public void BindingMethod2 ()
271 [SoapDocumentService (RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
272 public class WebService3 : WebService
280 [SoapDocumentMethodAttribute ("urn:foo:method1",
281 RequestNamespace = "urn:foo:method1",
282 RequestElementName = "Element1",
283 Use = SoapBindingUse.Literal)]
284 public void BindingMethod ()
289 [SoapDocumentMethodAttribute ("urn:foo:method1",
290 RequestNamespace = "urn:foo:method1",
291 RequestElementName = "Element2",
292 Use = SoapBindingUse.Literal)]
293 public void BindingMethod2 ()