Browse Source

* ProtocolImporter.cs: Use the binding name as class name for the
proxy.
* SoapProtocolImporter.cs: Use the element name as field name for soap
headers. In 2.0, generate a property for accessing the field.

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

Lluis Sanchez 18 years ago
parent
commit
363ca995f8

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

@@ -1,3 +1,10 @@
+2008-04-01  Lluis Sanchez Gual <[email protected]> 
+
+	* ProtocolImporter.cs: Use the binding name as class name for the
+	  proxy.
+	* SoapProtocolImporter.cs: Use the element name as field name for soap
+	  headers. In 2.0, generate a property for accessing the field.
+
 2008-02-22  Atsushi Enomoto  <[email protected]>
 
 	* ProtocolReflector.cs : reverted previous change, which caused

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

@@ -264,7 +264,7 @@ namespace System.Web.Services.Description {
 		void ImportPortBinding (bool multipleBindings)
 		{
 			if (port != null) {
-				if (multipleBindings) className = port.Name;
+				if (multipleBindings) className = binding.Name;
 				else className = service.Name;
 			}
 			else

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

@@ -627,25 +627,50 @@ namespace System.Web.Services.Description {
 			if (part == null) throw new InvalidOperationException ("Message part " + hb.Part + " not found in message " + hb.Message);
 
 			XmlTypeMapping map;
+			string hname;
 			if (hb.Use == SoapBindingUse.Literal)
 			{
 				map = xmlImporter.ImportDerivedTypeMapping (part.Element, typeof (SoapHeader));
+				hname = part.Element.Name;
 				xmlExporter.ExportTypeMapping (map);
 			}
 			else
 			{
 				map = soapImporter.ImportDerivedTypeMapping (part.Type, typeof (SoapHeader), true);
+				hname = part.Type.Name;
 				soapExporter.ExportTypeMapping (map);
 			}
 
 			string varName = headerVariables [map] as string;
 			if (varName == null) 
 			{
-				varName = memberIds.AddUnique(CodeIdentifier.MakeValid (map.TypeName + "Value"),hb);
+				if (hname == map.TypeName)
+					varName = memberIds.AddUnique(CodeIdentifier.MakeValid (hname + "Value"),hb);
+				else
+					varName = memberIds.AddUnique(CodeIdentifier.MakeValid (hname),hb);
+				
+#if NET_2_0
+				string propName = varName;
+				varName = varName + "Field";
+#endif
 				headerVariables.Add (map, varName);
 				CodeMemberField codeField = new CodeMemberField (map.TypeFullName, varName);
-				codeField.Attributes = MemberAttributes.Public;
 				CodeTypeDeclaration.Members.Add (codeField);
+				
+#if NET_2_0
+				codeField.Attributes = MemberAttributes.Private;
+				CodeMemberProperty codeProperty = new CodeMemberProperty ();
+				codeProperty.Name = propName;
+				codeProperty.Type = new CodeTypeReference (map.TypeFullName);
+				codeProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+				codeProperty.HasGet = codeProperty.HasSet = true;
+				CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), varName);
+				codeProperty.SetStatements.Add (new CodeAssignStatement (ce, new CodePropertySetValueReferenceExpression()));
+				codeProperty.GetStatements.Add (new CodeMethodReturnStatement (ce));
+				CodeTypeDeclaration.Members.Add (codeProperty);
+#else
+				codeField.Attributes = MemberAttributes.Public;
+#endif
 			}
 			
 			CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapHeaderAttribute");