* BasicProfileChecker.cs: Some small fixes.
authorLluis Sanchez <lluis@novell.com>
Wed, 1 Sep 2004 14:09:56 +0000 (14:09 -0000)
committerLluis Sanchez <lluis@novell.com>
Wed, 1 Sep 2004 14:09:56 +0000 (14:09 -0000)
* FaultBinding.cs: Removed useless code.
* HttpSimpleProtocolImporter.cs, SoapProtocolImporter.cs: Take into account
  that now we may be generating code for a binding which is not referenced
  by any port. In this case Port is null.
* MessageBinding.cs: Properly set the parent operation binding.
* OperationBinding.cs: When adding messages, set its parent property.
* ProtocolImporter.cs: Support generation of proxies for wsdl documents
  that do not have any Service entry. In this case, it now generates
  a proxy for every binding.

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

mcs/class/System.Web.Services/System.Web.Services.Description/BasicProfileChecker.cs
mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Description/FaultBinding.cs
mcs/class/System.Web.Services/System.Web.Services.Description/HttpSimpleProtocolImporter.cs
mcs/class/System.Web.Services/System.Web.Services.Description/MessageBinding.cs
mcs/class/System.Web.Services/System.Web.Services.Description/OperationBinding.cs
mcs/class/System.Web.Services/System.Web.Services.Description/ProtocolImporter.cs
mcs/class/System.Web.Services/System.Web.Services.Description/SoapProtocolImporter.cs

index 3cab0597004a77e776d0e49c5454c0ff34519c94..a499bf592840a8095d786c341088748c3573966d 100644 (file)
@@ -158,13 +158,19 @@ namespace System.Web.Services.Description
                                        if (sbb.Parts == null) {
                                                if (msg.Parts != null && msg.Parts.Count > 1)
                                                        ctx.ReportRuleViolation (value, BasicProfileRules.R2210);
+                                               if (msg.Parts.Count == 1)
+                                                       portParts.Remove (msg.Parts[0]);
                                        }
                                        else {
-                                               foreach (string part in sbb.Parts) {
-                                                       MessagePart mp = msg.FindPartByName (part);
-                                                       portParts.Remove (mp);
-                                                       if (!mp.DefinedByElement)
-                                                               ctx.ReportRuleViolation (value, BasicProfileRules.R2204);
+                                               if (sbb.Parts.Length == 0 && msg.Parts.Count == 1) {
+                                                       portParts.Remove (msg.Parts[0]);
+                                               } else {
+                                                       foreach (string part in sbb.Parts) {
+                                                               MessagePart mp = msg.FindPartByName (part);
+                                                               portParts.Remove (mp);
+                                                               if (!mp.DefinedByElement)
+                                                                       ctx.ReportRuleViolation (value, BasicProfileRules.R2204);
+                                                       }
                                                }
                                        }
                                }
index 834961c6f3e642ec286fb8ca7408c6b1c0aa5a9b..b1b118039ca30cb62ba7c10e55c8ca2039a58c52 100644 (file)
@@ -1,3 +1,16 @@
+2004-09-01  Lluis Sanchez Gual  <lluis@novell.com>
+
+       * BasicProfileChecker.cs: Some small fixes.
+       * FaultBinding.cs: Removed useless code.
+       * HttpSimpleProtocolImporter.cs, SoapProtocolImporter.cs: Take into account 
+         that now we may be generating code for a binding which is not referenced
+         by any port. In this case Port is null.
+       * MessageBinding.cs: Properly set the parent operation binding.
+       * OperationBinding.cs: When adding messages, set its parent property.
+       * ProtocolImporter.cs: Support generation of proxies for wsdl documents
+         that do not have any Service entry. In this case, it now generates
+         a proxy for every binding.
+
 2004-08-24  Lluis Sanchez Gual  <lluis@ximian.com>
 
        * BasicProfileChecker.cs: Implemented more rules.
index 2d622c4311240d88e7e9d1b499bf6df6b7102834..c0459b7cdea6283ee2a42c1b5a85841f9d21cf7d 100644 (file)
@@ -38,7 +38,6 @@ namespace System.Web.Services.Description {
                #region Fields\r
 \r
                ServiceDescriptionFormatExtensionCollection extensions;\r
-               OperationBinding operationBinding;\r
 \r
                #endregion // Fields\r
 \r
@@ -47,7 +46,6 @@ namespace System.Web.Services.Description {
                public FaultBinding ()\r
                {\r
                        extensions = new ServiceDescriptionFormatExtensionCollection (this);\r
-                       operationBinding = null;\r
                }\r
                \r
                #endregion // Constructors\r
@@ -60,14 +58,5 @@ namespace System.Web.Services.Description {
                }\r
        \r
                #endregion // Properties\r
-\r
-               #region Methods\r
-\r
-               internal void SetParent (OperationBinding operationBinding)\r
-               {\r
-                       this.operationBinding = operationBinding;\r
-               }\r
-\r
-               #endregion\r
        }\r
 }\r
index 1bcf62ed2d83b2e0ee460e69054438fd417245a0..6a9c99a608423ffd90e6f28708dc9bef86312dce 100644 (file)
@@ -72,15 +72,20 @@ namespace System.Web.Services.Description
                        CodeTypeDeclaration codeClass = new CodeTypeDeclaration (ClassName);
 
                        string location = null;
-                       HttpAddressBinding sab = (HttpAddressBinding) Port.Extensions.Find (typeof(HttpAddressBinding));
-                       if (sab != null) location = sab.Location;
-                       string url = GetServiceUrl (location); 
+                       string url = null;
+                       if (Port != null) {
+                               HttpAddressBinding sab = (HttpAddressBinding) Port.Extensions.Find (typeof(HttpAddressBinding));
+                               if (sab != null) location = sab.Location;
+                               url = GetServiceUrl (location); 
+                       }
                        
                        CodeConstructor cc = new CodeConstructor ();
                        cc.Attributes = MemberAttributes.Public;
-                       CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
-                       CodeAssignStatement cas = new CodeAssignStatement (ce, new CodePrimitiveExpression (url));
-                       cc.Statements.Add (cas);
+                       if (url != null) {
+                               CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
+                               CodeAssignStatement cas = new CodeAssignStatement (ce, new CodePrimitiveExpression (url));
+                               cc.Statements.Add (cas);
+                       }
                        codeClass.Members.Add (cc);
                        
                        memberIds = new CodeIdentifiers ();
index a55e4ad91dbd06ac4f4732cf226294ff159a901d..e1e7747967bb9319ca2a6b91b78d72fe8bd63f0c 100644 (file)
@@ -54,7 +54,6 @@ namespace System.Web.Services.Description
                \r
                protected MessageBinding ()\r
                {\r
-                       operationBinding = new OperationBinding ();\r
                }\r
                \r
                #endregion // Constructors\r
@@ -79,6 +78,11 @@ namespace System.Web.Services.Description
                public OperationBinding OperationBinding {\r
                        get { return operationBinding; }\r
                }\r
+               \r
+               internal void SetParent (OperationBinding ob)\r
+               {\r
+                       operationBinding = ob;\r
+               }\r
 \r
                #endregion // Properties\r
        }\r
index c447d3aaae37a9711385ed6d71b6d79e3d40c408..3ac29b28043e4897bb43bc37605ed735c435a3e4 100644 (file)
@@ -88,7 +88,11 @@ namespace System.Web.Services.Description {
                [XmlElement ("input")]\r
                public InputBinding Input {\r
                        get { return input; }\r
-                       set { input = value; }\r
+                       set {\r
+                               input = value; \r
+                               if (input != null)\r
+                                       input.SetParent (this);\r
+                       }\r
                }\r
 \r
 #if !NET_2_0\r
@@ -102,7 +106,11 @@ namespace System.Web.Services.Description {
                [XmlElement ("output")]\r
                public OutputBinding Output {\r
                        get { return output; }\r
-                       set { output= value; }\r
+                       set {\r
+                               output = value; \r
+                               if (output != null)\r
+                                       output.SetParent (this);\r
+                       }\r
                }\r
 \r
                #endregion // Properties\r
index 824d9b2943d2d0a7af79ec428cfd6035d97e6537..6b37b9d75afd538f994ea575dd371a708b8acdc6 100644 (file)
@@ -237,6 +237,26 @@ namespace System.Web.Services.Description {
                                        }
                                }
                        }
+                       
+                       if (!found)
+                       {
+                               // Looks like MS.NET generates classes for all bindings if
+                               // no services are present
+                               
+                               foreach (ImportInfo info in importInfo)
+                               {
+                                       this.iinfo = info;
+                                       foreach (Binding b in info.ServiceDescription.Bindings)
+                                       {
+                                               this.binding = b;
+                                               this.service = null;
+                                               this.port = null;
+                                               if (!IsBindingSupported ()) continue;
+                                               found = true;
+                                               ImportPortBinding (true);
+                                       }
+                               }
+                       }
 
                        EndNamespace ();
                        
@@ -246,8 +266,12 @@ namespace System.Web.Services.Description {
 
                void ImportPortBinding (bool multipleBindings)
                {
-                       if (multipleBindings) className = port.Name;
-                       else className = service.Name;
+                       if (port != null) {
+                               if (multipleBindings) className = port.Name;
+                               else className = service.Name;
+                       }
+                       else
+                               className = binding.Name;
                        
                        className = classNames.AddUnique (CodeIdentifier.MakeValid (className), port);
                        className = className.Replace ("_x0020_", "");  // MS.NET seems to do this
@@ -259,10 +283,11 @@ namespace System.Web.Services.Description {
 
                                CodeTypeDeclaration codeClass = BeginClass ();
                                codeTypeDeclaration = codeClass;
-                               AddCodeType (codeClass, port.Documentation);
+                               if (port != null)
+                                       AddCodeType (codeClass, port.Documentation);
                                codeClass.Attributes = MemberAttributes.Public;
-                               
-                               if (service.Documentation != null && service.Documentation != "")
+                       
+                               if (service != null && service.Documentation != null && service.Documentation != "")
                                        AddComments (codeClass, service.Documentation);
 
                                if (Style == ServiceDescriptionImportStyle.Client) {
index ea2c090d21ed4ad4e141085477737a3aca4b8c1f..a0adb8d1a5bddb8381a6bc1a4cc9a004330f1543 100644 (file)
@@ -107,10 +107,17 @@ namespace System.Web.Services.Description {
                        
                        CodeTypeDeclaration codeClass = new CodeTypeDeclaration (ClassName);
                        
-                       string location = null;                 
-                       SoapAddressBinding sab = (SoapAddressBinding) Port.Extensions.Find (typeof(SoapAddressBinding));
-                       if (sab != null) location = sab.Location;
-                       string url = GetServiceUrl (location); 
+                       string location = null;
+                       string url = null;
+                       
+                       if (Port != null) {
+                               SoapAddressBinding sab = (SoapAddressBinding) Port.Extensions.Find (typeof(SoapAddressBinding));
+                               if (sab != null) location = sab.Location;
+                               url = GetServiceUrl (location); 
+                       }
+                       
+                       string namspace = (Port != null ? Port.Binding.Namespace : Binding.ServiceDescription.TargetNamespace);
+                       string name = (Port != null ? Port.Name : Binding.Name);
 
                        if (Style == ServiceDescriptionImportStyle.Client) {
                                CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.Protocols.SoapHttpClientProtocol");
@@ -120,21 +127,23 @@ namespace System.Web.Services.Description {
                                CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.WebService");
                                codeClass.BaseTypes.Add (ctr);
                                CodeAttributeDeclaration attws = new CodeAttributeDeclaration ("System.Web.Services.WebServiceAttribute");
-                               attws.Arguments.Add (GetArg ("Namespace", Port.Binding.Namespace));
+                               attws.Arguments.Add (GetArg ("Namespace", namspace));
                                AddCustomAttribute (codeClass, attws, true);
                        }
                        
                        CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebServiceBinding");
-                       att.Arguments.Add (GetArg ("Name", Port.Name));
-                       att.Arguments.Add (GetArg ("Namespace", Port.Binding.Namespace));
+                       att.Arguments.Add (GetArg ("Name", name));
+                       att.Arguments.Add (GetArg ("Namespace", namspace));
                        AddCustomAttribute (codeClass, att, true);
        
                        if (Style == ServiceDescriptionImportStyle.Client) {
                                CodeConstructor cc = new CodeConstructor ();
                                cc.Attributes = MemberAttributes.Public;
-                               CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
-                               CodeAssignStatement cas = new CodeAssignStatement (ce, new CodePrimitiveExpression (url));
-                               cc.Statements.Add (cas);
+                               if (url != null) {
+                                       CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
+                                       CodeAssignStatement cas = new CodeAssignStatement (ce, new CodePrimitiveExpression (url));
+                                       cc.Statements.Add (cas);
+                               }
                                codeClass.Members.Add (cc);
                        }