소스 검색

* ExtensionManager.cs: Support more than one XmlFormatExtensionPrefixAttribute
un one soap extension.
* HttpSimpleProtocolImporter.cs: Made class internal.
* HttpSimpleProtocolReflector.cs.cs: ReflectMethodBinding(): GET and POST
do not use method bindings. Return null.
* ProtocolReflector.cs: Several fixes: do not generate binding if it doesn't
have any operation, avoid port and binding name colisions, and other minor
fixes.
* ServiceDescription.cs: Collect the namespaces to be added to the root
element of a serializaed wsdl document from the soap extensions.
* ServiceDescriptionSerializerBase.cs: Made classes internal.
* SoapAddressBinding.cs, SoapFaultBinding.cs, SoapOperationBinding.cs,
SoapProtocolImporter.cs: Class should not be sealed.
* SoapBodyBinding.cs: Set the correct class attributes.
* SoapHeaderBinding.cs: Class should not be sealed. Added missing method.
* SoapHeaderFaultBinding.cs: Fixed class attributes.

svn path=/trunk/mcs/; revision=22454

Lluis Sanchez 22 년 전
부모
커밋
efddffca82

+ 19 - 0
mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog

@@ -1,3 +1,22 @@
+2004-01-24  Lluis Sanchez Gual <[email protected]>
+
+	* ExtensionManager.cs: Support more than one XmlFormatExtensionPrefixAttribute
+	  un one soap extension.
+	* HttpSimpleProtocolImporter.cs: Made class internal.
+	* HttpSimpleProtocolReflector.cs.cs: ReflectMethodBinding(): GET and POST
+	  do not use method bindings. Return null.
+	* ProtocolReflector.cs: Several fixes: do not generate binding if it doesn't
+	  have any operation, avoid port and binding name colisions, and other minor
+	  fixes.
+	* ServiceDescription.cs: Collect the namespaces to be added to the root
+	  element of a serializaed wsdl document from the soap extensions.
+	* ServiceDescriptionSerializerBase.cs: Made classes internal.
+	* SoapAddressBinding.cs, SoapFaultBinding.cs, SoapOperationBinding.cs,
+	  SoapProtocolImporter.cs: Class should not be sealed.
+	* SoapBodyBinding.cs: Set the correct class attributes.
+	* SoapHeaderBinding.cs: Class should not be sealed. Added missing method.
+	* SoapHeaderFaultBinding.cs: Fixed class attributes.
+
 2004-01-21  Lluis Sanchez Gual <[email protected]>
 
 	* HttpSimpleProtocolImporter.cs: pass the web service class list to the xml 

+ 15 - 15
mcs/class/System.Web.Services/System.Web.Services.Description/ExtensionManager.cs

@@ -11,6 +11,7 @@ using System.Reflection;
 using System.Collections;
 using System.Web.Services.Configuration;
 using System.Xml.Serialization;
+using System.Xml;
 
 namespace System.Web.Services.Description 
 {
@@ -38,7 +39,7 @@ namespace System.Web.Services.Description
 			RegisterExtensionType (typeof (SoapBodyBinding));
 			RegisterExtensionType (typeof (SoapFaultBinding));
 			RegisterExtensionType (typeof (SoapHeaderBinding));
-			RegisterExtensionType (typeof (SoapHeaderFaultBinding));
+//			RegisterExtensionType (typeof (SoapHeaderFaultBinding));
 			RegisterExtensionType (typeof (SoapOperationBinding));
 			
 			foreach (Type type in WSConfig.Instance.FormatExtensionTypes)
@@ -51,12 +52,9 @@ namespace System.Web.Services.Description
 			ext.Type = type;
 			
 			object[] ats = type.GetCustomAttributes (typeof(XmlFormatExtensionPrefixAttribute), true);
-			if (ats.Length > 0)
-			{
-				XmlFormatExtensionPrefixAttribute at = (XmlFormatExtensionPrefixAttribute)ats[0];
-				ext.Prefix = at.Prefix;
-				ext.Namespace = at.Namespace;
-			}
+			
+			foreach (XmlFormatExtensionPrefixAttribute at in ats)
+				ext.NamespaceDeclarations.Add (new XmlQualifiedName (at.Prefix, at.Namespace));
 			
 			ats = type.GetCustomAttributes (typeof(XmlFormatExtensionAttribute), true);
 			if (ats.Length > 0)
@@ -158,16 +156,18 @@ namespace System.Web.Services.Description
 	
 	internal class ExtensionInfo
 	{
-		public string _prefix;
-		public string _namespace;
-		public string _elementName;
-		public Type _type;
-		public XmlSerializer _serializer;
+		ArrayList _namespaceDeclarations;
+		string _namespace;
+		string _elementName;
+		Type _type;
+		XmlSerializer _serializer;
 
-		public string Prefix
+		public ArrayList NamespaceDeclarations
 		{
-			get { return _prefix; }
-			set { _prefix = value; }
+			get { 
+				if (_namespaceDeclarations == null) _namespaceDeclarations = new ArrayList ();
+				return _namespaceDeclarations; 
+			}
 		}
 		
 		public string Namespace

+ 1 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/HttpSimpleProtocolImporter.cs

@@ -18,7 +18,7 @@ using System.Collections;
 
 namespace System.Web.Services.Description 
 {
-	public abstract class HttpSimpleProtocolImporter : ProtocolImporter 
+	internal abstract class HttpSimpleProtocolImporter : ProtocolImporter 
 	{
 
 		#region Fields

+ 1 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/HttpSimpleProtocolReflector.cs

@@ -114,7 +114,7 @@ namespace System.Web.Services.Description {
 
 		protected override string ReflectMethodBinding ()
 		{
-			return TypeInfo.DefaultBinding;
+			return null;
 		}
 
 		#endregion

+ 46 - 15
mcs/class/System.Web.Services/System.Web.Services.Description/ProtocolReflector.cs

@@ -143,7 +143,7 @@ namespace System.Web.Services.Description {
 			get { return schemaExporter; }
 		}
 
-		public SoapSchemaExporter SoapSchemaExporter {
+		internal SoapSchemaExporter SoapSchemaExporter {
 			get { return soapSchemaExporter; }
 		}
 
@@ -228,8 +228,7 @@ namespace System.Web.Services.Description {
 		{
 			port = new Port ();
 			port.Name = portNames.AddUnique (binfo.Name, port);
-			port.Binding = new XmlQualifiedName (binfo.Name, binfo.Namespace);
-			service.Ports.Add (port);
+			bool bindingFull = true;
 
 			if (binfo.Namespace != desc.TargetNamespace)
 			{
@@ -238,29 +237,52 @@ namespace System.Web.Services.Description {
 					ServiceDescription newDesc = new ServiceDescription();
 					newDesc.TargetNamespace = binfo.Namespace;
 					newDesc.Name = binfo.Name;
-					int id = ServiceDescriptions.Add (newDesc);
-					AddImport (desc, binfo.Namespace, GetWsdlUrl (url,id));
-					ImportBindingContent (newDesc, typeInfo, url, binfo);
+					bindingFull = ImportBindingContent (newDesc, typeInfo, url, binfo);
+					if (bindingFull) {
+						int id = ServiceDescriptions.Add (newDesc);
+						AddImport (desc, binfo.Namespace, GetWsdlUrl (url,id));
+					}
 				}
-				else
+				else {
 					AddImport (desc, binfo.Namespace, binfo.Location);
+					bindingFull = true;
+				}
 			}
 			else
-				ImportBindingContent (desc, typeInfo, url, binfo);
+				bindingFull = ImportBindingContent (desc, typeInfo, url, binfo);
+				
+			if (bindingFull)
+			{
+				port.Binding = new XmlQualifiedName (binding.Name, binfo.Namespace);
+				service.Ports.Add (port);
+			}
 		}
 
-		void ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo)
+		bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo)
 		{
 			serviceDescription = desc;
 			
+			// Look for an unused name
+			
+			int n=0;
+			string name = binfo.Name;
+			bool found;
+			do
+			{
+				found = false;
+				foreach (Binding bi in desc.Bindings)
+					if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; }
+			}
+			while (found);
+			
+			// Create the binding
+			
 			binding = new Binding ();
-			binding.Name = binfo.Name;
-			binding.Type = new XmlQualifiedName (binfo.Name, binfo.Namespace);
-			desc.Bindings.Add (binding);
+			binding.Name = name;
+			binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace);
 			
 			portType = new PortType ();
 			portType.Name = binding.Name;
-			desc.PortTypes.Add (portType);
 
 			BeginClass ();
 			
@@ -269,7 +291,7 @@ namespace System.Web.Services.Description {
 				methodStubInfo = method;
 				
 				string metBinding = ReflectMethodBinding ();
-				if (metBinding != null && (metBinding != binding.Name)) continue;
+				if (typeInfo.GetBinding (metBinding) != binfo) continue;
 				
 				operation = new Operation ();
 				operation.Name = method.OperationName;
@@ -304,8 +326,17 @@ namespace System.Web.Services.Description {
 					reflector.ReflectMethod ();
 				}
 			}
-
+			
 			EndClass ();
+			
+			if (portType.Operations.Count > 0)
+			{
+				desc.Bindings.Add (binding);
+				desc.PortTypes.Add (portType);
+				return true;
+			}
+			else
+				return false;
 		}
 
 		void ImportOperationBinding ()

+ 32 - 4
mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs

@@ -202,9 +202,38 @@ namespace System.Web.Services.Description {
 			ns.Add ("mime", MimeContentBinding.Namespace);
 			ns.Add ("tm", MimeTextBinding.Namespace);
 			ns.Add ("s0", TargetNamespace);
+			
+			AddExtensionNamespaces (ns, Extensions);
+			
+			if (Types != null) AddExtensionNamespaces (ns, Types.Extensions);
+			
+			foreach (Service ser in Services)
+				foreach (Port port in ser.Ports)
+					AddExtensionNamespaces (ns, port.Extensions);
+
+			foreach (Binding bin in Bindings)
+			{
+				AddExtensionNamespaces (ns, bin.Extensions);
+				foreach (OperationBinding op in bin.Operations)
+				{
+					AddExtensionNamespaces (ns, op.Extensions);
+					if (op.Input != null) AddExtensionNamespaces (ns, op.Input.Extensions);
+					if (op.Output != null) AddExtensionNamespaces (ns, op.Output.Extensions);
+				}
+			}
 			return ns;
 		}
 		
+		void AddExtensionNamespaces (XmlSerializerNamespaces ns, ServiceDescriptionFormatExtensionCollection extensions)
+		{
+			foreach (ServiceDescriptionFormatExtension ext in extensions)
+			{
+				ExtensionInfo einf = ExtensionManager.GetFormatExtensionInfo (ext.GetType ());
+				foreach (XmlQualifiedName qname in einf.NamespaceDeclarations)
+					ns.Add (qname.Name, qname.Namespace);
+			}
+		}
+		
 		internal static void WriteExtensions (XmlWriter writer, object ob)
 		{
 			ServiceDescriptionFormatExtensionCollection extensions = ExtensionManager.GetExtensionPoint (ob);
@@ -219,16 +248,15 @@ namespace System.Web.Services.Description {
 		{
 			Type type = ext.GetType ();
 			ExtensionInfo info = ExtensionManager.GetFormatExtensionInfo (type);
-			string prefix = info.Prefix;
-			
-			if (prefix == null || prefix == "") prefix = writer.LookupPrefix (info.Namespace);
 			
 //				if (prefix != null && prefix != "")
 //					Writer.WriteStartElement (prefix, info.ElementName, info.Namespace);
 //				else
 //					WriteStartElement (info.ElementName, info.Namespace, false);
 
-			info.Serializer.Serialize (writer, ext);
+			XmlSerializerNamespaces ns = new XmlSerializerNamespaces ();
+			ns.Add ("","");
+			info.Serializer.Serialize (writer, ext, ns);
 		}
 		
 		internal static void ReadExtension (XmlReader reader, object ob)

+ 2 - 2
mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescriptionSerializerBase.cs

@@ -7,7 +7,7 @@ using System.Globalization;
 
 namespace System.Web.Services.Description
 {
-	public class ServiceDescriptionReaderBase : XmlSerializationReader
+	internal class ServiceDescriptionReaderBase : XmlSerializationReader
 	{
 		public System.Web.Services.Description.ServiceDescription ReadTree ()
 		{
@@ -1297,7 +1297,7 @@ namespace System.Web.Services.Description
 
 	}
 
-	public class ServiceDescriptionWriterBase : XmlSerializationWriter
+	internal class ServiceDescriptionWriterBase : XmlSerializationWriter
 	{
 		public void WriteTree (System.Web.Services.Description.ServiceDescription ob)
 		{

+ 1 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/SoapAddressBinding.cs

@@ -12,7 +12,7 @@ using System.Xml.Serialization;
 
 namespace System.Web.Services.Description {
 	[XmlFormatExtension ("address", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (Port))]
-	public sealed class SoapAddressBinding : ServiceDescriptionFormatExtension {
+	public class SoapAddressBinding : ServiceDescriptionFormatExtension {
 
 		#region Fields
 

+ 3 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/SoapBodyBinding.cs

@@ -13,7 +13,9 @@ using System.Xml.Serialization;
 
 namespace System.Web.Services.Description {
 	[XmlFormatExtension ("body", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (InputBinding), typeof (OutputBinding), typeof (MimePart))]
-	public sealed class SoapBodyBinding : ServiceDescriptionFormatExtension {
+	[XmlFormatExtensionPrefixAttribute ("soap", "http://schemas.xmlsoap.org/wsdl/soap/")]
+	[XmlFormatExtensionPrefixAttribute ("soapenc", "http://schemas.xmlsoap.org/soap/encoding/")]
+	public class SoapBodyBinding : ServiceDescriptionFormatExtension {
 
 		#region Fields
 		

+ 1 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/SoapFaultBinding.cs

@@ -13,7 +13,7 @@ using System.Xml.Serialization;
 
 namespace System.Web.Services.Description {
 	[XmlFormatExtension ("fault", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (FaultBinding))]
-	public sealed class SoapFaultBinding : ServiceDescriptionFormatExtension {
+	public class SoapFaultBinding : ServiceDescriptionFormatExtension {
 
 		#region Fields
 

+ 10 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderBinding.cs

@@ -15,7 +15,7 @@ using System.Xml.Serialization;
 
 namespace System.Web.Services.Description {
 	[XmlFormatExtension ("header", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (InputBinding), typeof (OutputBinding))]
-	public sealed class SoapHeaderBinding : ServiceDescriptionFormatExtension {
+	public class SoapHeaderBinding : ServiceDescriptionFormatExtension {
 
 		#region Fields
 
@@ -83,6 +83,15 @@ namespace System.Web.Services.Description {
 			set { use = value; }
 		}
 
+#if NET_1_1
+		[MonoTODO]
+		public SoapHeaderFaultBinding Fault 
+		{
+			get { return null; }
+			set { ; }
+		}
+#endif
+
 		#endregion // Properties
 	}
 }

+ 2 - 2
mcs/class/System.Web.Services/System.Web.Services.Description/SoapHeaderFaultBinding.cs

@@ -13,8 +13,8 @@ using System.Xml;
 using System.Xml.Serialization;
 
 namespace System.Web.Services.Description {
-	[XmlFormatExtension ("headerfault", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (InputBinding), typeof (OutputBinding))]
-	public sealed class SoapHeaderFaultBinding : ServiceDescriptionFormatExtension {
+
+	public class SoapHeaderFaultBinding : ServiceDescriptionFormatExtension {
 
 		#region Fields
 

+ 1 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/SoapOperationBinding.cs

@@ -13,7 +13,7 @@ using System.Xml.Serialization;
 
 namespace System.Web.Services.Description {
 	[XmlFormatExtension ("operation", "http://schemas.xmlsoap.org/wsdl/soap/", typeof (OperationBinding))]
-	public sealed class SoapOperationBinding : ServiceDescriptionFormatExtension {
+	public class SoapOperationBinding : ServiceDescriptionFormatExtension {
 
 		#region Fields
 

+ 1 - 1
mcs/class/System.Web.Services/System.Web.Services.Description/SoapProtocolImporter.cs

@@ -18,7 +18,7 @@ using System.Configuration;
 using System.Collections;
 
 namespace System.Web.Services.Description {
-	public sealed class SoapProtocolImporter : ProtocolImporter {
+	public class SoapProtocolImporter : ProtocolImporter {
 
 		#region Fields