Explorar o código

* DocumentableItem.cs MimeContentBinding.cs OperationMessage.cs
OperationMessageCollection.cs PortCollection.cs PortType.cs
PortTypeCollection.cs ServiceCollection.cs ServiceDescriptionCollection.cs
SoapBodyBinding.cs SoapOperationBinding.cs: Several fixes by Erik LeBel
* ServiceDescriptionImporter.cs:
* ServiceDescriptionSerializerBase.cs: regenerated after the changes in
the service description changes.
* ServiceDescriptionReflector.cs: Fixed generation of message parts in
bare format.

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

Lluis Sanchez %!s(int64=22) %!d(string=hai) anos
pai
achega
4a01835603

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

@@ -1,3 +1,15 @@
+2003-09-14  Lluis Sanchez Gual  <[email protected]>
+
+	* DocumentableItem.cs MimeContentBinding.cs OperationMessage.cs 
+	  OperationMessageCollection.cs PortCollection.cs PortType.cs 
+	  PortTypeCollection.cs ServiceCollection.cs ServiceDescriptionCollection.cs 
+	  SoapBodyBinding.cs SoapOperationBinding.cs: Several fixes by Erik LeBel
+	* ServiceDescriptionImporter.cs:
+	* ServiceDescriptionSerializerBase.cs: regenerated after the changes in
+	  the service description changes.
+	* ServiceDescriptionReflector.cs: Fixed generation of message parts in
+	  bare format.
+
 2003-09-11  Lluis Sanchez Gual  <[email protected]>
 
 	* ServiceDescriptionImporter.cs, ServiceDescriptionReflector.cs: Added

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

@@ -34,7 +34,12 @@ namespace System.Web.Services.Description {
 		[DefaultValue ("")]
 		public string Documentation {
 			get { return documentation; }
-			set { documentation = value; }
+			set {
+				if (value == null)
+					documentation = String.Empty;
+				else
+					documentation = value;
+			}
 		}
 	
 		#endregion // Properties

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

@@ -7,6 +7,7 @@
 // Copyright (C) Tim Coleman, 2002
 //
 
+using System.ComponentModel;
 using System.Web.Services.Configuration;
 using System.Xml.Serialization;
 
@@ -35,6 +36,7 @@ namespace System.Web.Services.Description {
 
 		#region Properties
 
+		[DefaultValue ("")]
 		[XmlAttribute ("part", DataType = "NMTOKEN")]	
 		public string Part {
 			get { return part; }

+ 3 - 5
mcs/class/System.Web.Services/System.Web.Services.Description/OperationMessage.cs

@@ -10,7 +10,6 @@
 using System.Web.Services;
 using System.Xml;
 using System.Xml.Serialization;
-using System.ComponentModel;
 
 namespace System.Web.Services.Description {
 	public abstract class OperationMessage : DocumentableItem {
@@ -27,8 +26,8 @@ namespace System.Web.Services.Description {
 		
 		protected OperationMessage ()
 		{
-			message = null;
-			name = String.Empty;
+			message = XmlQualifiedName.Empty;
+			name = null;
 			operation = null;
 		}
 		
@@ -42,7 +41,6 @@ namespace System.Web.Services.Description {
 			set { message = value; }
 		}
 
-		[DefaultValue ("")]
 		[XmlAttribute ("name", DataType = "NMTOKEN")]
 		public string Name {
 			get { return name; }
@@ -65,4 +63,4 @@ namespace System.Web.Services.Description {
 
 		#endregion // Methods
 	}
-}
+}

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

@@ -68,6 +68,13 @@ namespace System.Web.Services.Description {
 
 		#region Methods
 
+		protected override string GetKey (object value) 
+		{
+			if (!(value is OperationMessage))
+				throw new InvalidCastException ();
+			return ((OperationMessage) value).Name;
+		}
+
 		public int Add (OperationMessage operationMessage) 
 		{
 			Insert (Count, operationMessage);
@@ -96,7 +103,12 @@ namespace System.Web.Services.Description {
 
 		protected override void OnInsert (int index, object value)
 		{
-			if (Count > 2 || (Count > 1 && value.GetType () == this [0].GetType ()))
+			if (Count == 0)
+				return;
+			
+			if (Count == 1 && value.GetType() != this[0].GetType())
+				return;
+
 				throw new InvalidOperationException ("The operation object can only contain one input and one output message.");
 		}
 
@@ -110,7 +122,7 @@ namespace System.Web.Services.Description {
 		protected override void OnValidate (object value)
 		{
 			if (value == null)
-				throw new NullReferenceException ("The message object is a null reference.");
+				throw new ArgumentException("The message object is a null reference.");
 			if (!(value is OperationInput || value is OperationOutput))
 				throw new ArgumentException ("The message object is not an input or an output message.");
 		}

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

@@ -32,7 +32,12 @@ namespace System.Web.Services.Description {
 		}
 
 		public Port this [string name] {
-			get { return this [IndexOf ((Port) Table[name])]; }
+			get { 
+				int index = IndexOf ((Port) Table[name]);
+				if (index >= 0)
+					return this[index]; 
+				return null;
+			}
 		}
 
 		#endregion // Properties

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

@@ -24,7 +24,7 @@ namespace System.Web.Services.Description {
 		
 		public PortType ()
 		{
-			name = String.Empty;
+			name = null;
 			operations = new OperationCollection (this);
 			serviceDescription = null;
 		}

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

@@ -32,7 +32,12 @@ namespace System.Web.Services.Description {
 		}
 
 		public PortType this [string name] {
-			get { return this [IndexOf ((PortType) Table[name])]; }
+			get { 
+				int index = IndexOf ((PortType) Table[name]);
+				if (index >= 0)
+					return this[index]; 
+				return null;
+			}
 		}
 
 		#endregion // Properties

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

@@ -34,7 +34,12 @@ namespace System.Web.Services.Description {
 		}
 
 		public Service this [string name] {
-			get { return this [IndexOf ((Service) Table[name])]; }
+			get { 
+				int index = IndexOf ((Service) Table[name]);
+				if (index >= 0)
+					return this[index]; 
+				return null;
+			}
 		}
 
 		#endregion // Properties

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

@@ -35,7 +35,12 @@ namespace System.Web.Services.Description {
 		}
 
 		public ServiceDescription this [string ns] {
-			get { return this[IndexOf ((ServiceDescription) Table[ns])]; }
+			get { 
+				int index = IndexOf ((ServiceDescription) Table[ns]);
+				if (index >= 0)
+					return this[index]; 
+				return null;
+			}
 		}
 
 		#endregion // Properties

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

@@ -506,7 +506,7 @@ namespace System.Web.Services.Description {
 		
 		string GetOperMessageName (OperationMessage msg, string operName)
 		{
-			if (msg.Name == "") return operName;
+			if (msg.Name == null) return operName;
 			else return msg.Name;
 		}
 		

+ 10 - 3
mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescriptionReflector.cs

@@ -11,6 +11,7 @@
 using System.Web.Services;
 using System.Xml.Serialization;
 using System.Xml;
+using System.Xml.Schema;
 using System.Web.Services.Protocols;
 
 namespace System.Web.Services.Description {
@@ -217,9 +218,15 @@ namespace System.Web.Services.Description {
 				{
 					MessagePart part = new MessagePart ();
 					part.Name = members[n].MemberName;
-					XmlQualifiedName qname = new XmlQualifiedName (members.ElementName, members.Namespace);
-					if (method.Use == SoapBindingUse.Literal) part.Element = qname;
-					else part.Type = qname;
+					
+					if (method.Use == SoapBindingUse.Literal) {
+						part.Element = new XmlQualifiedName (members[n].MemberName, members[n].Namespace);
+					}
+					else {
+						string namesp = members[n].TypeNamespace;
+						if (namesp == "") namesp = XmlSchema.Namespace;
+						part.Type = new XmlQualifiedName (members[n].TypeName, namesp);
+					}
 					msg.Parts.Add (part);
 				}
 			}

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

@@ -1321,7 +1321,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("ServiceDescription", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("targetNamespace", "", ob.TargetNamespace);
 
 			ServiceDescription.WriteExtensions (Writer, ob);
@@ -1423,7 +1423,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("Message", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 
 			if (ob.Parts != null) {
 				for (int n65 = 0; n65 < ob.Parts.Count; n65++) {
@@ -1451,7 +1451,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("PortType", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 
 			if (ob.Operations != null) {
 				for (int n66 = 0; n66 < ob.Operations.Count; n66++) {
@@ -1479,7 +1479,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("Binding", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("type", "", FromXmlQualifiedName (ob.Type));
 
 			ServiceDescription.WriteExtensions (Writer, ob);
@@ -1509,7 +1509,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("Service", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 
 			if (ob.Ports != null) {
 				for (int n68 = 0; n68 < ob.Ports.Count; n68++) {
@@ -1542,7 +1542,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("MessagePart", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("element", "", FromXmlQualifiedName (ob.Element));
 			WriteAttribute ("type", "", FromXmlQualifiedName (ob.Type));
 
@@ -1567,7 +1567,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("Operation", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 			if (ob.ParameterOrderString != "") {
 				WriteAttribute ("parameterOrder", "", ob.ParameterOrderString);
 			}
@@ -1609,7 +1609,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("OperationBinding", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 
 			ServiceDescription.WriteExtensions (Writer, ob);
 			if (ob.Faults != null) {
@@ -1640,7 +1640,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("Port", "http://schemas.xmlsoap.org/wsdl/");
 
-			WriteAttribute ("name", "", ob.Name.ToString());
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("binding", "", FromXmlQualifiedName (ob.Binding));
 
 			ServiceDescription.WriteExtensions (Writer, ob);
@@ -1665,9 +1665,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("OperationFault", "http://schemas.xmlsoap.org/wsdl/");
 
-			if (ob.Name != "") {
-				WriteAttribute ("name", "", ob.Name.ToString());
-			}
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("message", "", FromXmlQualifiedName (ob.Message));
 
 			if (ob.Documentation != "") {
@@ -1691,9 +1689,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("OperationInput", "http://schemas.xmlsoap.org/wsdl/");
 
-			if (ob.Name != "") {
-				WriteAttribute ("name", "", ob.Name.ToString());
-			}
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("message", "", FromXmlQualifiedName (ob.Message));
 
 			if (ob.Documentation != "") {
@@ -1717,9 +1713,7 @@ namespace System.Web.Services.Description
 
 			if (needType) WriteXsiType("OperationOutput", "http://schemas.xmlsoap.org/wsdl/");
 
-			if (ob.Name != "") {
-				WriteAttribute ("name", "", ob.Name.ToString());
-			}
+			WriteAttribute ("name", "", ob.Name);
 			WriteAttribute ("message", "", FromXmlQualifiedName (ob.Message));
 
 			if (ob.Documentation != "") {
@@ -1744,7 +1738,7 @@ namespace System.Web.Services.Description
 			if (needType) WriteXsiType("FaultBinding", "http://schemas.xmlsoap.org/wsdl/");
 
 			if (ob.Name != "") {
-				WriteAttribute ("name", "", ob.Name.ToString());
+				WriteAttribute ("name", "", ob.Name);
 			}
 
 			ServiceDescription.WriteExtensions (Writer, ob);
@@ -1770,7 +1764,7 @@ namespace System.Web.Services.Description
 			if (needType) WriteXsiType("InputBinding", "http://schemas.xmlsoap.org/wsdl/");
 
 			if (ob.Name != "") {
-				WriteAttribute ("name", "", ob.Name.ToString());
+				WriteAttribute ("name", "", ob.Name);
 			}
 
 			ServiceDescription.WriteExtensions (Writer, ob);
@@ -1796,7 +1790,7 @@ namespace System.Web.Services.Description
 			if (needType) WriteXsiType("OutputBinding", "http://schemas.xmlsoap.org/wsdl/");
 
 			if (ob.Name != "") {
-				WriteAttribute ("name", "", ob.Name.ToString());
+				WriteAttribute ("name", "", ob.Name);
 			}
 
 			ServiceDescription.WriteExtensions (Writer, ob);

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

@@ -20,6 +20,7 @@ namespace System.Web.Services.Description {
 		string encoding;
 		string ns;
 		string[] parts;
+		string partsString;
 		SoapBindingUse use;
 
 		#endregion // Fields
@@ -31,6 +32,7 @@ namespace System.Web.Services.Description {
 			encoding = String.Empty;
 			ns = String.Empty;
 			parts = null;
+			partsString = null;
 			use = SoapBindingUse.Default;
 		}
 		
@@ -55,13 +57,25 @@ namespace System.Web.Services.Description {
 		[XmlIgnore]
 		public string[] Parts {
 			get { return parts; }
-			set { parts = value; }
+			set {
+				parts = value;
+				if (value == null)
+					partsString = null;
+				else
+					partsString = String.Join(" ", value);
+			}
 		}
 
 		[XmlAttribute ("parts", DataType = "NMTOKENS")]
 		public string PartsString {
-			get { return (Parts != null) ? String.Join (" ", Parts) : null; }
-			set { Parts = value.Split (' '); }
+			get { return partsString; }
+			set {
+				partsString = value;
+				if (value == null)
+					parts = null;
+				else
+					parts = value.Split(' ');
+			}
 		}
 
 		[DefaultValue (SoapBindingUse.Default)]

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

@@ -27,7 +27,7 @@ namespace System.Web.Services.Description {
 		public SoapOperationBinding ()
 		{
 			soapAction = String.Empty;
-			style = SoapBindingStyle.Document;
+			style = SoapBindingStyle.Default;
 		}
 		
 		#endregion // Constructors
@@ -53,4 +53,4 @@ namespace System.Web.Services.Description {
 
 		#endregion // Properties
 	}
-}
+}