* HttpSimpleProtocolReflector.cs, ProtocolReflector.cs:
authorLluis Sanchez <lluis@novell.com>
Wed, 15 Oct 2003 08:16:44 +0000 (08:16 -0000)
committerLluis Sanchez <lluis@novell.com>
Wed, 15 Oct 2003 08:16:44 +0000 (08:16 -0000)
  Fixed naming of messages.
* ProtocolImporter.cs: It now iterates through all bindings. It creates
  a namespace for all bindings.
* ServiceDescriptionImporter.cs: Some code moved to ProtocolImporter.
* SoapProtocolImporter.cs: Improved support for RPC format. It now is working.

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

mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Description/HttpSimpleProtocolReflector.cs
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/ServiceDescriptionImporter.cs
mcs/class/System.Web.Services/System.Web.Services.Description/SoapProtocolImporter.cs

index 3c7c2d3525d9e0d2b2a92b5c68401670bb122a05..4e7eade79f04689d5cade454da6df62e6ec8d943 100644 (file)
@@ -1,3 +1,12 @@
+2003-10-15  Lluis Sanchez Gual <lluis@ximian.com>
+
+       * HttpSimpleProtocolReflector.cs, ProtocolReflector.cs: 
+         Fixed naming of messages.
+       * ProtocolImporter.cs: It now iterates through all bindings. It creates
+         a namespace for all bindings.
+       * ServiceDescriptionImporter.cs: Some code moved to ProtocolImporter.
+       * SoapProtocolImporter.cs: Improved support for RPC format. It now is working.
+
 2003-10-13  Lluis Sanchez Gual <lluis@ximian.com>
 
        * HttpSimpleProtocolReflector.cs, SoapProtocolReflector.cs: 
index c9d9887a7801a597f77878f273e9348db7196f33..de2b3bf2922cfa64a8bd5d159236b12021901188 100644 (file)
@@ -49,7 +49,7 @@ namespace System.Web.Services.Description {
                {
                        LogicalTypeInfo ti = TypeStubManager.GetLogicalTypeInfo (ServiceType);
                        HttpOperationBinding sob = new HttpOperationBinding();
-                       sob.Location = "/" + OperationBinding.Name;
+                       sob.Location = "/" + MethodStubInfo.Name;
                        OperationBinding.Extensions.Add (sob);
                        
                        if (!Method.IsVoid)
index 13dd673d5d1c701b580f7c938f100577cc4364f0..a016cce0425ad9d47d7b5fc13b4bf051af8831d5 100644 (file)
@@ -145,24 +145,37 @@ namespace System.Web.Services.Description {
 
                #region Methods
                
-               internal bool Import (ServiceDescriptionImporter descriptionImporter, CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, ImportInfo info, Service service, Port port, CodeIdentifiers classNames)
+               internal bool Import (ServiceDescriptionImporter descriptionImporter, CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, ArrayList importInfo)
                {
                        this.descriptionImporter = descriptionImporter;
-                       this.service = service;
-                       this.iinfo = info;
-                       this.port = port;
-                       binding = ServiceDescriptions.GetBinding (port.Binding);
-                       
-                       if (!IsBindingSupported ()) return false;
+                       this.classNames = new CodeIdentifiers();;
+                       this.codeNamespace = codeNamespace;
+                       this.codeCompileUnit = codeCompileUnit;
                        
-                       this.classNames = classNames;
                        warnings = (ServiceDescriptionImportWarnings) 0;
                        
-                       this.codeNamespace = codeNamespace;
-                       this.codeCompileUnit = codeCompileUnit;
+                       bool found = false;
 
                        BeginNamespace ();
-                       ImportPortBinding ();
+                       
+                       foreach (ImportInfo info in importInfo)
+                       {
+                               foreach (Service service in info.ServiceDescription.Services)
+                               {
+                                       this.service = service;
+                                       foreach (Port port in service.Ports)
+                                       {
+                                               this.iinfo = info;
+                                               this.port = port;
+                                               binding = ServiceDescriptions.GetBinding (port.Binding);
+                                               if (!IsBindingSupported ()) continue;
+                                               
+                                               found = true;
+                                               ImportPortBinding ();
+                                       }
+                               }
+                       }
+
                        EndNamespace ();
                        
                        return true;
index 4110e0ae03734316ba86def28fc5e9a017d8595f..dd0e93b510a6d91ba7ae321de59ddaac9b940c65 100644 (file)
@@ -267,22 +267,24 @@ namespace System.Web.Services.Description {
                                if (metBinding != null && (metBinding != binding.Name)) continue;
                                
                                operation = new Operation ();
-                               operation.Name = method.Name;
+                               operation.Name = method.OperationName;
                                operation.Documentation = method.MethodAttribute.Description;
                                
                                inputMessage = new Message ();
-                               inputMessage.Name = operation.Name + ProtocolName + "In";
+                               inputMessage.Name = method.Name + ProtocolName + "In";
                                ServiceDescription.Messages.Add (inputMessage);
                                
                                outputMessage = new Message ();
-                               outputMessage.Name = operation.Name + ProtocolName + "Out";
+                               outputMessage.Name = method.Name + ProtocolName + "Out";
                                ServiceDescription.Messages.Add (outputMessage);
 
                                OperationInput inOp = new OperationInput ();
+                               if (method.Name != method.OperationName) inOp.Name = method.Name;
                                Operation.Messages.Add (inOp);
                                inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace);
                                
                                OperationOutput outOp = new OperationOutput ();
+                               if (method.Name != method.OperationName) outOp.Name = method.Name;
                                Operation.Messages.Add (outOp);
                                outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace);
                        
@@ -304,7 +306,7 @@ namespace System.Web.Services.Description {
                void ImportOperationBinding ()
                {
                        operationBinding = new OperationBinding ();
-                       operationBinding.Name = methodStubInfo.Name;
+                       operationBinding.Name = methodStubInfo.OperationName;
                        
                        InputBinding inOp = new InputBinding ();
                        operationBinding.Input = inOp;
@@ -312,6 +314,9 @@ namespace System.Web.Services.Description {
                        OutputBinding outOp = new OutputBinding ();
                        operationBinding.Output = outOp;
                        
+                       if (methodStubInfo.OperationName != methodStubInfo.Name)
+                               inOp.Name = outOp.Name = methodStubInfo.Name;
+                       
                        binding.Operations.Add (operationBinding);
                }
                
index bef325eae3d0d1b2a33d6b111119e8efb499d456..b2fa982536e10590eb16c22ce95cf45bcb5f008d 100644 (file)
@@ -88,22 +88,12 @@ namespace System.Web.Services.Description {
                public ServiceDescriptionImportWarnings Import (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit)\r
                {\r
                        ServiceDescriptionImportWarnings warns = 0;\r
-                       CodeIdentifiers classNames = new CodeIdentifiers();\r
                        ProtocolImporter importer = GetImporter ();\r
-                       bool found = false;\r
                        \r
-                       foreach (ImportInfo info in importInfo)\r
-                               foreach (Service service in info.ServiceDescription.Services)\r
-                                       foreach (Port port in service.Ports)\r
-                                       {\r
-                                               if (importer.Import (this, codeNamespace, codeCompileUnit, info, service, port, classNames)) {\r
-                                                       found = true;\r
-                                                       warns |= importer.Warnings;\r
-                                               }\r
-                                       }\r
+                       if (!importer.Import (this, codeNamespace, codeCompileUnit, importInfo))\r
+                               throw new Exception ("None of the supported bindings was found");\r
                                \r
-                       if (!found) throw new Exception ("None of the supported bindings was found");\r
-                       return warns;\r
+                       return importer.Warnings;\r
                }\r
                \r
                ProtocolImporter GetImporter ()\r
index dbcdbfc6de69868344ca95557b1ff3df1009954e..dca73abf811eea2c3c764e347b9b80f7a0a38da0 100644 (file)
@@ -110,8 +110,8 @@ namespace System.Web.Services.Description {
 
                protected override void BeginNamespace ()
                {
-                       xmlImporter = new XmlSchemaImporter (Schemas);
-                       soapImporter = new SoapSchemaImporter (Schemas);
+                       xmlImporter = new XmlSchemaImporter (Schemas, ClassNames);
+                       soapImporter = new SoapSchemaImporter (Schemas, ClassNames);
                        xmlExporter = new XmlCodeExporter (CodeNamespace, null);
                        soapExporter = new SoapCodeExporter (CodeNamespace, null);
                }
@@ -152,16 +152,25 @@ namespace System.Web.Services.Description {
                                SoapBodyBinding osbb = OperationBinding.Output.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
                                if (osbb == null) throw new Exception ("Soap body binding not found");
                                
-                               XmlMembersMapping inputMembers = ImportMembersMapping (InputMessage, isbb, soapOper);
+                               SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
+                       
+                               XmlMembersMapping inputMembers = ImportMembersMapping (InputMessage, isbb, style, false);
                                if (inputMembers == null) throw new Exception ("Input message not declared");
 
-                               XmlMembersMapping outputMembers = ImportMembersMapping (OutputMessage, osbb, soapOper);
+                               XmlMembersMapping outputMembers = ImportMembersMapping (OutputMessage, osbb, style, true);
                                if (outputMembers == null) throw new Exception ("Output message not declared");
                                
                                CodeMemberMethod met = GenerateMethod (memberIds, soapOper, isbb, inputMembers, outputMembers);
                                
-                               xmlExporter.ExportMembersMapping (inputMembers);
-                               xmlExporter.ExportMembersMapping (outputMembers);
+                               if (isbb.Use == SoapBindingUse.Literal)
+                                       xmlExporter.ExportMembersMapping (inputMembers);
+                               else
+                                       soapExporter.ExportMembersMapping (inputMembers);
+                               
+                               if (osbb.Use == SoapBindingUse.Literal)
+                                       xmlExporter.ExportMembersMapping (outputMembers);
+                               else
+                                       soapExporter.ExportMembersMapping (outputMembers);
 
                                foreach (SoapExtensionImporter eximporter in extensionImporters)
                                {
@@ -178,9 +187,12 @@ namespace System.Web.Services.Description {
                        }
                }
                
-               XmlMembersMapping ImportMembersMapping (Message msg, SoapBodyBinding sbb, SoapOperationBinding soapOper)
+               XmlMembersMapping ImportMembersMapping (Message msg, SoapBodyBinding sbb, SoapBindingStyle style, bool output)
                {
                        XmlQualifiedName elem = null;
+                       string elemName = Operation.Name;
+                       if (output) elemName += "Response";
+
                        if (msg.Parts.Count == 1 && msg.Parts[0].Name == "parameters")
                        {
                                // Wrapped parameter style
@@ -191,7 +203,7 @@ namespace System.Web.Services.Description {
                                        SoapSchemaMember ssm = new SoapSchemaMember ();
                                        ssm.MemberName = part.Name;
                                        ssm.MemberType = part.Type;
-                                       return soapImporter.ImportMembersMapping (Operation.Name, part.Type.Namespace, ssm);
+                                       return soapImporter.ImportMembersMapping (elemName, part.Type.Namespace, ssm);
                                }
                                else
                                        return xmlImporter.ImportMembersMapping (part.Element);                         
@@ -210,10 +222,10 @@ namespace System.Web.Services.Description {
                                        }
                                        
                                        // Rpc messages always have a wrapping element
-                                       if (soapOper.Style == SoapBindingStyle.Rpc)
-                                               return soapImporter.ImportMembersMapping (Operation.Name, sbb.Namespace, mems, true);
+                                       if (style == SoapBindingStyle.Rpc)
+                                               return soapImporter.ImportMembersMapping (elemName, sbb.Namespace, mems, true);
                                        else
-                                               return soapImporter.ImportMembersMapping (Operation.Name, "", mems, false);
+                                               return soapImporter.ImportMembersMapping ("", "", mems, false);
                                }
                                else
                                {
@@ -235,6 +247,8 @@ namespace System.Web.Services.Description {
                        methodBegin.Attributes = MemberAttributes.Public;
                        methodEnd.Attributes = MemberAttributes.Public;
                        
+                       SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
+                       
                        // Find unique names for temporary variables
                        
                        for (int n=0; n<inputMembers.Count; n++)
@@ -288,7 +302,9 @@ namespace System.Web.Services.Description {
                                
                                if (found) continue;
 
-                               if ((outputMembers [n].ElementName == Operation.Name + "Result") || (inputMembers.Count==0 && outputMembers.Count==1)) {
+                               if ((outputMembers [n].ElementName == Operation.Name + "Result") || 
+                                       (outputMembers.Count==1)) 
+                               {
                                        method.ReturnType = cpd.Type;
                                        methodEnd.ReturnType = cpd.Type;
                                        GenerateReturnAttributes (outputMembers, outputMembers[n], bodyBinding.Use, method);
@@ -338,11 +354,17 @@ namespace System.Web.Services.Description {
                        CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
                        CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
                        CodeMethodInvokeExpression inv;
+                       CodeVariableDeclarationStatement dec;
 
                        inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, methodParams);
-                       CodeVariableDeclarationStatement dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
-                       method.Statements.Add (dec);
-                       method.Statements.AddRange (outAssign);
+                       if (outputMembers.Count > 0)
+                       {
+                               dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
+                               method.Statements.Add (dec);
+                               method.Statements.AddRange (outAssign);
+                       }
+                       else
+                               method.Statements.Add (inv);
                        
                        // Begin Invoke Call
                        
@@ -355,20 +377,29 @@ namespace System.Web.Services.Description {
                        
                        CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
                        inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
-                       dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
-                       methodEnd.Statements.Add (dec);
-                       methodEnd.Statements.AddRange (outAssign);
+                       if (outputMembers.Count > 0)
+                       {
+                               dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
+                               methodEnd.Statements.Add (dec);
+                               methodEnd.Statements.AddRange (outAssign);
+                       }
+                       else
+                               methodEnd.Statements.Add (inv);
                        
                        // Attributes
                        
-                       CodeAttributeDeclaration att = null;
+                       ImportHeaders (method);
+                       
+                       CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebMethodAttribute");
+                       if (messageName != method.Name) att.Arguments.Add (GetArg ("MessageName",messageName));
+                       AddCustomAttribute (method, att, false);
                        
-                       if (soapOper.Style == SoapBindingStyle.Rpc)
+                       if (style == SoapBindingStyle.Rpc)
                        {
                                att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapRpcMethodAttribute");
                                att.Arguments.Add (GetArg (soapOper.SoapAction));
                                if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
-                               if (outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("RequestElementName", outputMembers.ElementName));
+                               if (outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
                                att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
                                att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
                        }
@@ -382,7 +413,7 @@ namespace System.Web.Services.Description {
                                att.Arguments.Add (GetArg (soapOper.SoapAction));
                                if (inputMembers.ElementName != "") {
                                        if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
-                                       if (outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("RequestElementName", outputMembers.ElementName));
+                                       if (outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
                                        att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
                                        att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
                                        att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Wrapped"));
@@ -394,12 +425,6 @@ namespace System.Web.Services.Description {
                        }
                        
                        AddCustomAttribute (method, att, true);
-                               
-                       att = new CodeAttributeDeclaration ("System.Web.Services.WebMethodAttribute");
-                       if (messageName != method.Name) att.Arguments.Add (GetArg ("MessageName",messageName));
-                       AddCustomAttribute (method, att, false);
-                       
-                       ImportHeaders (method);
                        
                        CodeTypeDeclaration.Members.Add (method);
                        CodeTypeDeclaration.Members.Add (methodBegin);
@@ -472,17 +497,22 @@ namespace System.Web.Services.Description {
 
                        XmlTypeMapping map;
                        if (hb.Use == SoapBindingUse.Literal)
+                       {
                                map = xmlImporter.ImportDerivedTypeMapping (part.Element, typeof (SoapHeader));
+                               xmlExporter.ExportTypeMapping (map);
+                       }
                        else
+                       {
                                map = soapImporter.ImportDerivedTypeMapping (part.Type, typeof (SoapHeader), true);
+                               soapExporter.ExportTypeMapping (map);
+                       }
 
-                       xmlExporter.ExportTypeMapping (map);
                        bool required = false;
 
                        string varName = headerVariables [map] as string;
                        if (varName == null) 
                        {
-                               varName = memberIds.AddUnique(CodeIdentifier.MakeValid (map.TypeName + "Value"),hb);
+                               varName = memberIds.AddUnique(CodeIdentifier.MakeValid (hb.Part + "Value"),hb);
                                headerVariables.Add (map, varName);
                                CodeMemberField codeField = new CodeMemberField (map.TypeFullName, varName);
                                codeField.Attributes = MemberAttributes.Public;