2006-12-15 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 15 Dec 2006 08:16:42 +0000 (08:16 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 15 Dec 2006 08:16:42 +0000 (08:16 -0000)
* SoapExtensionReflector.cs, SoapProtocolReflector.cs :
  Now SOAP bindings are reflected through extension reflectors.
  Added implementations for SOAP 1.1 and SOAP 1.2 (2.0 only).
  The common SoapBindingExtensionReflector implements reflector
  methods which used to be in SoapProtocolReflector. Also
  subclassed SoapProtocolReflector to switch SOAP 1.1 and 1.2.
* ServiceDescriptionReflector.cs : under 2.0, use
  Soap12ProtocolReflector and export soap12 bindings as well.
* ProtocolImporter.cs : under 2.0 profile, handle SOAP 1.2 encoding
  namespace (http://www.w3.org/2003/05/soap-encoding) as well.
* ProtocolReflector.cs : call ReflectDescription(). Added FIXME.

* ServerType.cs : added SOAP 1.2 protocol as a different one from
  SOAP 1.1.
* Methods.cs : added Soap12TypeStubInfo.

svn path=/branches/atsushi/mcs/; revision=69528

mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Description/ProtocolImporter.cs
mcs/class/System.Web.Services/System.Web.Services.Description/ProtocolReflector.cs
mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescriptionReflector.cs
mcs/class/System.Web.Services/System.Web.Services.Description/SoapExtensionReflector.cs
mcs/class/System.Web.Services/System.Web.Services.Description/SoapProtocolReflector.cs
mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Protocols/Methods.cs
mcs/class/System.Web.Services/System.Web.Services.Protocols/ServerType.cs

index 5e9771a58380d0fe76038e5c933d3a6be451c13d..0c1b5da543fcd3785ddf557679267ae36bc91204 100644 (file)
@@ -1,3 +1,17 @@
+2006-12-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SoapExtensionReflector.cs, SoapProtocolReflector.cs :
+         Now SOAP bindings are reflected through extension reflectors.
+         Added implementations for SOAP 1.1 and SOAP 1.2 (2.0 only).
+         The common SoapBindingExtensionReflector implements reflector
+         methods which used to be in SoapProtocolReflector. Also
+         subclassed SoapProtocolReflector to switch SOAP 1.1 and 1.2.
+       * ServiceDescriptionReflector.cs : under 2.0, use
+         Soap12ProtocolReflector and export soap12 bindings as well.
+       * ProtocolImporter.cs : under 2.0 profile, handle SOAP 1.2 encoding
+         namespace (http://www.w3.org/2003/05/soap-encoding) as well.
+       * ProtocolReflector.cs : call ReflectDescription(). Added FIXME.
+
 2006-12-15  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ProtocolReflector.cs, SoapExtensionReflector.cs : added
index 99da617b1921206147de115bb8ca42f9ff3f3a60..299eb30010dc2694d53717e4bc8ec91f1fb70ac3 100644 (file)
@@ -542,7 +542,15 @@ namespace System.Web.Services.Description {
                        foreach (XmlSchemaObject ob in sc.Includes)
                        {
                                XmlSchemaImport import = ob as XmlSchemaImport;
-                               if (import != null && import.Namespace == SoapProtocolReflector.EncodingNamespace) return true;
+                               if (import == null)
+                                       continue;
+#if NET_2_0
+                               if (import.Namespace == Soap11BindingExtensionReflector.EncodingNamespace
+                                   || import.Namespace == Soap12BindingExtensionReflector.EncodingNamespace)
+#else
+                               if (import.Namespace == Soap11BindingExtensionReflector.EncodingNamespace)
+#endif
+                                       return true;
                        }
                        return false;
                }
index 6abcd5d01a1b261965cb0e29351f3d5dc361b098..2475bfafdc0d587f0db6bb87c1190f788a467386 100644 (file)
@@ -306,13 +306,12 @@ namespace System.Web.Services.Description {
                        portType.Name = binding.Name;
 
                        BeginClass ();
-#if NET_2_0
+
                        foreach (SoapExtensionReflector reflector in extensionReflectors)
                        {
                                reflector.ReflectionContext = this;
                                reflector.ReflectDescription ();
                        }
-#endif
 
                        foreach (MethodStubInfo method in typeInfo.Methods)
                        {
@@ -324,7 +323,10 @@ namespace System.Web.Services.Description {
                                operation = new Operation ();
                                operation.Name = method.OperationName;
                                operation.Documentation = method.MethodAttribute.Description;
-                               
+
+                               // FIXME: SOAP 1.1 and SOAP 1.2 should share
+                               // the same message definitions.
+
                                inputMessage = new Message ();
                                inputMessage.Name = method.Name + ProtocolName + "In";
                                ServiceDescription.Messages.Add (inputMessage);
index 6be9daa627d716d52b37b31f11439dc2dc86a50d..8702af02a59c5eeea5ef035444efc5ac29169a70 100644 (file)
@@ -76,8 +76,10 @@ namespace System.Web.Services.Description {
                        XmlSchemaExporter schemaExporter = new XmlSchemaExporter (Schemas);
                        SoapSchemaExporter soapSchemaExporter = new SoapSchemaExporter (Schemas);
                        
-                       new SoapProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
-                       
+                       new Soap11ProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
+#if NET_2_0
+                       new Soap12ProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
+#endif
                        if (WSConfig.IsSupported (WSProtocol.HttpGet))
                                new HttpGetProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
                        
index 8d4df9bd1b6e44e9d3674e24cb6ba7d3a7d4307d..331ece57ec3f3505f6c50d0796af5ff5b178a03a 100644 (file)
@@ -28,6 +28,9 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.Web.Services.Protocols;
+using System.Xml;
+
 namespace System.Web.Services.Description {
        public abstract class SoapExtensionReflector {
 
@@ -57,13 +60,147 @@ namespace System.Web.Services.Description {
                #region Methods
 
 #if NET_2_0
-               public virtual void ReflectDescription ()
+               public
+#else
+               internal
+#endif
+               virtual void ReflectDescription ()
                {
                }
-#endif
 
                public abstract void ReflectMethod ();
 
                #endregion
        }
+
+       abstract class SoapBindingExtensionReflector : SoapExtensionReflector
+       {
+               public abstract SoapBinding CreateSoapBinding ();
+               public abstract SoapAddressBinding CreateSoapAddressBinding ();
+               public abstract SoapOperationBinding CreateSoapOperationBinding ();
+               public abstract SoapHeaderBinding CreateSoapHeaderBinding ();
+               public abstract SoapBodyBinding CreateSoapBodyBinding ();
+               public abstract string EncodingNS { get; }
+
+#if NET_2_0
+               public
+#else
+               internal
+#endif
+               override void ReflectDescription ()
+               {
+                       SoapBinding sb = CreateSoapBinding ();
+                       sb.Transport = SoapBinding.HttpTransport;
+                       sb.Style = ((SoapTypeStubInfo) ReflectionContext.TypeInfo).SoapBindingStyle;
+                       ReflectionContext.Binding.Extensions.Add (sb);
+
+                       SoapAddressBinding abind = CreateSoapAddressBinding ();
+                       abind.Location = ReflectionContext.ServiceUrl;
+                       ReflectionContext.Port.Extensions.Add (abind);
+               }
+
+               public override void ReflectMethod ()
+               {
+                       SoapMethodStubInfo method = (SoapMethodStubInfo) ReflectionContext.MethodStubInfo;
+
+                       SoapOperationBinding sob = CreateSoapOperationBinding ();
+                       
+                       sob.SoapAction = method.Action;
+                       sob.Style = method.SoapBindingStyle;
+                       ReflectionContext.OperationBinding.Extensions.Add (sob);
+                       
+                       AddOperationMsgBindings (method, ReflectionContext.OperationBinding.Input);
+                       AddOperationMsgBindings (method, ReflectionContext.OperationBinding.Output);
+
+                       foreach (SoapHeaderMapping hf in method.Headers) {
+                               if (hf.Custom) continue;
+                               
+                               SoapHeaderBinding hb = CreateSoapHeaderBinding ();
+                               hb.Message = new XmlQualifiedName (ReflectionContext.Operation.Name + hf.HeaderType.Name, ReflectionContext.ServiceDescription.TargetNamespace);
+                               hb.Part = hf.HeaderType.Name;
+                               hb.Use = method.Use;
+                               
+                               if (method.Use != SoapBindingUse.Literal)
+                                       hb.Encoding = EncodingNS;
+
+                               if ((hf.Direction & SoapHeaderDirection.Out) != 0)
+                                       ReflectionContext.OperationBinding.Output.Extensions.Add (hb);
+                               if ((hf.Direction & SoapHeaderDirection.In) != 0)
+                                       ReflectionContext.OperationBinding.Input.Extensions.Add (hb);
+                       }
+               }
+
+               void AddOperationMsgBindings (SoapMethodStubInfo method, MessageBinding msg)
+               {
+                       SoapBodyBinding sbbo = CreateSoapBodyBinding ();
+                       msg.Extensions.Add (sbbo);
+                       sbbo.Use = method.Use;
+                       if (method.Use == SoapBindingUse.Encoded) {
+                               sbbo.Namespace = ReflectionContext.ServiceDescription.TargetNamespace;
+                               sbbo.Encoding = EncodingNS;
+                       }
+               }
+       }
+
+       class Soap11BindingExtensionReflector : SoapBindingExtensionReflector
+       {
+               public override SoapBinding CreateSoapBinding ()
+               {
+                       return new SoapBinding ();
+               }
+               public override SoapAddressBinding CreateSoapAddressBinding ()
+               {
+                       return new SoapAddressBinding ();
+               }
+               public override SoapOperationBinding CreateSoapOperationBinding ()
+               {
+                       return new SoapOperationBinding ();
+               }
+               public override SoapHeaderBinding CreateSoapHeaderBinding ()
+               {
+                       return new SoapHeaderBinding ();
+               }
+               public override SoapBodyBinding CreateSoapBodyBinding ()
+               {
+                       return new SoapBodyBinding ();
+               }
+
+               public override string EncodingNS {
+                       get { return EncodingNamespace; }
+               }
+
+               public const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
+       }
+
+#if NET_2_0
+       class Soap12BindingExtensionReflector : SoapBindingExtensionReflector
+       {
+               public override SoapBinding CreateSoapBinding ()
+               {
+                       return new Soap12Binding ();
+               }
+               public override SoapAddressBinding CreateSoapAddressBinding ()
+               {
+                       return new Soap12AddressBinding ();
+               }
+               public override SoapOperationBinding CreateSoapOperationBinding ()
+               {
+                       return new Soap12OperationBinding ();
+               }
+               public override SoapHeaderBinding CreateSoapHeaderBinding ()
+               {
+                       return new Soap12HeaderBinding ();
+               }
+               public override SoapBodyBinding CreateSoapBodyBinding ()
+               {
+                       return new Soap12BodyBinding ();
+               }
+
+               public override string EncodingNS {
+                       get { return EncodingNamespace; }
+               }
+
+               public const string EncodingNamespace = "http://www.w3.org/2003/05/soap-encoding";
+       }
+#endif
 }
index 1d3e4766ef2db6da7b986f9b53445b45b9d991a5..84f0956b4542abdbd76c028afedf11b7d70ae9f9 100644 (file)
@@ -37,11 +37,10 @@ using System.Xml;
 
 namespace System.Web.Services.Description {
 
-       internal class SoapProtocolReflector : ProtocolReflector 
+       internal abstract class SoapProtocolReflector : ProtocolReflector 
        {
                #region Fields
 
-               internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
                SoapBinding soapBinding;
 
                #endregion // Fields
@@ -56,24 +55,15 @@ namespace System.Web.Services.Description {
 
                #region Properties
 
-               public override string ProtocolName {
-                       get { return "Soap"; }
-               }
+               public abstract SoapExtensionReflector ExtensionReflector { get; }
 
-               #endregion // Properties
+               #endregion
 
                #region Methods
 
                protected override void BeginClass ()
                {
-                       SoapBinding sb = new SoapBinding ();
-                       sb.Transport = SoapBinding.HttpTransport;
-                       sb.Style = ((SoapTypeStubInfo)TypeInfo).SoapBindingStyle;
-                       Binding.Extensions.Add (sb);
-
-                       SoapAddressBinding abind = new SoapAddressBinding ();
-                       abind.Location = ServiceUrl;
-                       Port.Extensions.Add (abind);
+                       ExtensionReflector.ReflectDescription ();
                }
 
                protected override void EndClass ()
@@ -82,18 +72,10 @@ namespace System.Web.Services.Description {
 
                protected override bool ReflectMethod ()
                {
-                       SoapOperationBinding sob = new SoapOperationBinding();
                        SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
-                       
-                       sob.SoapAction = method.Action;
-                       sob.Style = method.SoapBindingStyle;
-                       OperationBinding.Extensions.Add (sob);
-                       
                        ImportMessage (method.InputMembersMapping, InputMessage);
                        ImportMessage (method.OutputMembersMapping, OutputMessage);
                                
-                       AddOperationMsgBindings (method, OperationBinding.Input);
-                       AddOperationMsgBindings (method, OperationBinding.Output);
 
                        foreach (SoapHeaderMapping hf in method.Headers)
                        {
@@ -106,11 +88,6 @@ namespace System.Web.Services.Description {
                                msg.Parts.Add (part);
                                ServiceDescription.Messages.Add (msg);
 
-                               SoapHeaderBinding hb = new SoapHeaderBinding ();
-                               hb.Message = new XmlQualifiedName (msg.Name, ServiceDescription.TargetNamespace);
-                               hb.Part = part.Name;
-                               hb.Use = method.Use;
-                               
                                if (method.Use == SoapBindingUse.Literal)
                                {
                                        // MS.NET reflects header classes in a weird way. The root element
@@ -134,28 +111,12 @@ namespace System.Web.Services.Description {
                                        XmlTypeMapping mapping = SoapReflectionImporter.ImportTypeMapping (hf.HeaderType, TypeInfo.LogicalType.GetWebServiceEncodedNamespace (ServiceDescription.TargetNamespace));
                                        part.Type = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
                                        SoapSchemaExporter.ExportTypeMapping (mapping);
-                                       hb.Encoding = EncodingNamespace;
                                }
-
-                               if ((hf.Direction & SoapHeaderDirection.Out) != 0)
-                                       OperationBinding.Output.Extensions.Add (hb);
-                               if ((hf.Direction & SoapHeaderDirection.In) != 0)
-                                       OperationBinding.Input.Extensions.Add (hb);
                        }
                        
-                       return true;
-               }
+                       ExtensionReflector.ReflectMethod ();
 
-               void AddOperationMsgBindings (SoapMethodStubInfo method, MessageBinding msg)
-               {
-                       SoapBodyBinding sbbo = new SoapBodyBinding();
-                       msg.Extensions.Add (sbbo);
-                       sbbo.Use = method.Use;
-                       if (method.Use == SoapBindingUse.Encoded)
-                       {
-                               sbbo.Namespace = ServiceDescription.TargetNamespace;
-                               sbbo.Encoding = EncodingNamespace;
-                       }
+                       return true;
                }
                
                void ImportMessage (XmlMembersMapping members, Message msg)
@@ -210,4 +171,44 @@ namespace System.Web.Services.Description {
 
                #endregion
        }
+
+       internal class Soap11ProtocolReflector : SoapProtocolReflector
+       {
+               SoapExtensionReflector reflector;
+               
+               public Soap11ProtocolReflector ()
+               {
+                       reflector = new Soap11BindingExtensionReflector ();
+                       reflector.ReflectionContext = this;
+               }
+
+               public override string ProtocolName {
+                       get { return "Soap"; }
+               }
+
+               public override SoapExtensionReflector ExtensionReflector {
+                       get { return reflector; }
+               }
+       }
+
+#if NET_2_0
+       internal class Soap12ProtocolReflector : SoapProtocolReflector
+       {
+               SoapExtensionReflector reflector;
+               
+               public Soap12ProtocolReflector ()
+               {
+                       reflector = new Soap12BindingExtensionReflector ();
+                       reflector.ReflectionContext = this;
+               }
+
+               public override string ProtocolName {
+                       get { return "Soap12"; }
+               }
+
+               public override SoapExtensionReflector ExtensionReflector {
+                       get { return reflector; }
+               }
+       }
+#endif
 }
index 1fc9721394bf72ca16c504a810db15b2c0b6a5f9..d35b46621b5f66051995f34e25d47435607254d6 100644 (file)
@@ -1,3 +1,9 @@
+2006-12-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServerType.cs : added SOAP 1.2 protocol as a different one from
+         SOAP 1.1.
+       * Methods.cs : added Soap12TypeStubInfo.
+
 2006-12-15  Atsushi Enomoto  <atsushi@ximian.com>
 
        * HttpSoapWebServiceHandler.cs,
index 2e0639d3f097226e12b7c0a39fee62fdfdab8697..0e5c976e7e820d76a00afe3630e07aec34d13af3 100644 (file)
@@ -544,4 +544,17 @@ namespace System.Web.Services.Protocols {
                        return (SoapMethodStubInfo) methods_byaction [name.Trim ('"',' ')];
                }
        }
+
+       internal class Soap12TypeStubInfo : SoapTypeStubInfo
+       {
+               public Soap12TypeStubInfo (ServerType logicalTypeInfo)
+               : base (logicalTypeInfo)
+               {
+               }
+
+               public override string ProtocolName
+               {
+                       get { return "Soap12"; }
+               }
+       }
 }
index 6e638a69db51747e11a54e85c16e0cf699d5469b..e0da258d4c1e8f80dfe377558f160b0d8cdc78ae 100644 (file)
@@ -54,6 +54,9 @@ namespace System.Web.Services.Protocols
                bool useEncoded;
 
                TypeStubInfo soapProtocol;
+#if NET_2_0
+               TypeStubInfo soap12Protocol;
+#endif
                TypeStubInfo httpGetProtocol;
                TypeStubInfo httpPostProtocol;
                
@@ -110,6 +113,11 @@ namespace System.Web.Services.Protocols
                                        case "Soap": 
                                                if (soapProtocol == null) soapProtocol = CreateTypeStubInfo (typeof(SoapTypeStubInfo));
                                                return soapProtocol;
+#if NET_2_0
+                                       case "Soap12": 
+                                               if (soap12Protocol == null) soap12Protocol = CreateTypeStubInfo (typeof(Soap12TypeStubInfo));
+                                               return soap12Protocol;
+#endif
                                        case "HttpGet":
                                                if (httpGetProtocol == null) httpGetProtocol = CreateTypeStubInfo (typeof(HttpGetTypeStubInfo));
                                                return httpGetProtocol;