Просмотр исходного кода

2007-05-08 Atsushi Enomoto <[email protected]>

	* SoapServerMethod.cs : Some refactoring. simply use GetMethod() in
	  type stub. WsiClaims could be retrieved from type stub.
	* SoapServerType.cs : store server methods and implement GetMethod().

	* SoapServerTypeTest.cs : added some more tests related to server
	  methods.


svn path=/trunk/mcs/; revision=76986
Atsushi Eno 18 лет назад
Родитель
Сommit
a175ad4f30

+ 6 - 0
mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog

@@ -1,3 +1,9 @@
+2007-05-08  Atsushi Enomoto  <[email protected]>
+
+	* SoapServerMethod.cs : Some refactoring. simply use GetMethod() in
+	  type stub. WsiClaims could be retrieved from type stub.
+	* SoapServerType.cs : store server methods and implement GetMethod().
+
 2007-05-08  Atsushi Enomoto  <[email protected]>
 
 	* SoapServerType.cs

+ 2 - 14
mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapServerMethod.cs

@@ -40,7 +40,6 @@ namespace System.Web.Services.Protocols
 	public sealed class SoapServerMethod
 	{
 		SoapMethodStubInfo info;
-		WsiProfiles wsi_claims;
 
 		[MonoTODO] // what to do here?
 		public SoapServerMethod ()
@@ -51,18 +50,7 @@ namespace System.Web.Services.Protocols
 		public SoapServerMethod (Type serverType, LogicalMethodInfo methodInfo)
 		{
 			TypeStubInfo type = TypeStubManager.GetTypeStub (serverType, "Soap");
-			wsi_claims = type.WsiClaims;
-			foreach (SoapMethodStubInfo m in type.Methods) {
-				bool match = false;
-				if (m.MethodInfo.MethodInfo == null)
-					match = m.MethodInfo.EndMethodInfo == methodInfo.EndMethodInfo;
-				else 
-					match = m.MethodInfo.MethodInfo == methodInfo.MethodInfo;
-				if (!match)
-					continue;
-				info = m;
-				break;
-			}
+			info = type.GetMethod (methodInfo.Name) as SoapMethodStubInfo;
 			if (info == null)
 				throw new InvalidOperationException ("Argument methodInfo does not seem to be a member of the server type.");
 		}
@@ -116,7 +104,7 @@ namespace System.Web.Services.Protocols
 		}
 
 		public WsiProfiles WsiClaims {
-			get { return wsi_claims; }
+			get { return info.TypeStub.WsiClaims; }
 		}
 	}
 }

+ 11 - 3
mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapServerType.cs

@@ -30,6 +30,7 @@
 
 #if NET_2_0
 
+using System.Collections;
 using System.Web.Services.Description;
 using System.Web.Services.Configuration;
 
@@ -37,7 +38,8 @@ namespace System.Web.Services.Protocols
 {
 	public sealed class SoapServerType : ServerType
 	{
-		[MonoTODO]
+		Hashtable serverMethods = new Hashtable ();
+
 		public SoapServerType (Type type, WebServiceProtocols protocolsSupported)
 			: base (type)
 		{
@@ -47,6 +49,11 @@ namespace System.Web.Services.Protocols
 				LogicalType.GetTypeStub ("Soap");
 			if ((protocolsSupported & WebServiceProtocols.HttpSoap12) != 0)
 				LogicalType.GetTypeStub ("Soap12");
+
+			foreach (LogicalMethodInfo m in LogicalType.LogicalMethods) {
+				SoapServerMethod sm = new SoapServerMethod (type, m);
+				serverMethods.Add (sm.Action, sm);
+			}
 		}
 
 		[MonoTODO]
@@ -55,10 +62,11 @@ namespace System.Web.Services.Protocols
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
 		public SoapServerMethod GetMethod (object key)
 		{
-			throw new NotImplementedException ();
+			if (key == null)
+				throw new ArgumentNullException ("key");
+			return serverMethods [key] as SoapServerMethod;
 		}
 
 		public bool ServiceDefaultIsEncoded {

+ 5 - 0
mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/ChangeLog

@@ -1,3 +1,8 @@
+2007-05-08  Atsushi Enomoto  <[email protected]>
+
+	* SoapServerTypeTest.cs : added some more tests related to server
+	  methods.
+
 2007-05-08  Atsushi Enomoto  <[email protected]>
 
 	* SoapServerTypeTest.cs : added some .ctor() tests to verify

+ 22 - 2
mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SoapServerTypeTest.cs

@@ -12,6 +12,7 @@ using NUnit.Framework;
 using System;
 using System.Globalization;
 using System.IO;
+using System.Reflection;
 using System.Web.Services;
 using System.Web.Services.Configuration;
 using System.Web.Services.Description;
@@ -27,8 +28,27 @@ namespace MonoTests.System.Web.Services.Description
 		[Test]
 		public void NamedServiceBinding ()
 		{
-			new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
+			SoapServerType sst = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
 			new ServerType (typeof (EdaInterface));
+
+			SoapServerMethod m = sst.GetMethod ("urn:localBinding:local:LocalBindingMethod");
+			Assert.IsNotNull (m, "#1");
+			m = sst.GetMethod ("somethingFoo");
+			Assert.IsNull (m, "#2");
+
+			MethodInfo mi = typeof (EdaInterface).GetMethod ("BindingMethod");
+			Assert.IsNotNull ("#3-1");
+			m = sst.GetMethod (mi);
+			// ... so, MethodInfo does not work as a key here.
+			Assert.IsNull (m, "#3-2");
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentNullException))]
+		public void GetMethodNullKey ()
+		{
+			SoapServerType sst = new SoapServerType (typeof (EdaInterface), WebServiceProtocols.HttpSoap);
+			sst.GetMethod (null);
 		}
 
 		[Test]
@@ -81,6 +101,7 @@ namespace MonoTests.System.Web.Services.Description
 		}
 
 		[Test]
+		[Category ("NotWorking")]
 		public void DuplicateMethodsWithRequestElement2 ()
 		{
 			new SoapServerType (typeof (WebService3), WebServiceProtocols.HttpSoap);
@@ -88,7 +109,6 @@ namespace MonoTests.System.Web.Services.Description
 
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]
-		[Category ("NotWorking")]
 		public void WrongNamedServiceBinding ()
 		{
 			new SoapServerType (typeof (WrongBindingNameClass), WebServiceProtocols.HttpSoap);