Browse Source

2009-09-04 Atsushi Enomoto <[email protected]>

	* ServiceHostBase.cs : URI trailing '/' can be added only when the
	  relative URI is non-empty. Do not make http://host/foo.svc as
	  http://host/foo.svc/ , it's not a directory.

	* SvcHttpHandler.cs : set Uri property based on baseAddresses and
	  path, to pick those endpoints that are added at custom factories.


svn path=/trunk/mcs/; revision=141307
Atsushi Eno 16 years ago
parent
commit
47dfe0a55e

+ 5 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog

@@ -1,3 +1,8 @@
+2009-09-04  Atsushi Enomoto  <[email protected]>
+
+	* SvcHttpHandler.cs : set Uri property based on baseAddresses and
+	  path, to pick those endpoints that are added at custom factories.
+
 2009-09-03  Atsushi Enomoto  <[email protected]>
 
 	* SvcHttpHandler.cs : apply configuration, and if there is still no

+ 11 - 6
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs

@@ -28,6 +28,7 @@
 //
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Web;
 using System.Threading;
 
@@ -112,11 +113,10 @@ namespace System.ServiceModel.Channels {
 			foreach (ServiceElement service in ConfigUtil.ServicesSection.Services) {
 				foreach (ServiceEndpointElement endpoint in service.Endpoints) {
 					// FIXME: consider BindingName as well
-					ServiceEndpoint se = host.AddServiceEndpoint (
+					host.AddServiceEndpoint (
 						endpoint.Contract,
 						ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration),
 						new Uri (path, UriKind.Relative));
-					this.Uri = se.Address.Uri;
 				}
 				// behaviors
 				ServiceBehaviorElement behavior = ConfigUtil.BehaviorsSection.ServiceBehaviors.Find (service.BehaviorConfiguration);
@@ -152,12 +152,17 @@ namespace System.ServiceModel.Channels {
 
 
 			ApplyConfiguration (host);
-			if (host.Description.Endpoints.Count == 0) {
+			if (host.Description.Endpoints.Count == 0)
 				//FIXME: Binding: Get from web.config.
-				var se = host.AddServiceEndpoint (ContractDescription.GetContract (type).Name,
+				host.AddServiceEndpoint (ContractDescription.GetContract (type).Name,
 					new BasicHttpBinding (), new Uri (path, UriKind.Relative));
-				this.Uri = se.Address.Uri;
-			}
+
+			var c = host.BaseAddresses;
+			var ba = c.FirstOrDefault (u => u.Scheme == Uri.UriSchemeHttp || u.Scheme == Uri.UriSchemeHttps);
+			if (ba != null)
+				this.Uri = new Uri (ba, path);
+			else
+				this.Uri = host.Description.Endpoints [0].Address.Uri;
 
 			host.Open ();
 

+ 6 - 0
mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog

@@ -1,3 +1,9 @@
+2009-09-04  Atsushi Enomoto  <[email protected]>
+
+	* ServiceHostBase.cs : URI trailing '/' can be added only when the
+	  relative URI is non-empty. Do not make http://host/foo.svc as
+	  http://host/foo.svc/ , it's not a directory.
+
 2009-09-04  Atsushi Enomoto  <[email protected]>
 
 	* ServiceHostBase.cs : add AddBaseAddress(). BaseAddresses must be

+ 1 - 1
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs

@@ -260,7 +260,7 @@ namespace System.ServiceModel
 
 				Uri baseaddr = base_addresses [binding.Scheme];
 
-				if (!baseaddr.AbsoluteUri.EndsWith ("/"))
+				if (!baseaddr.AbsoluteUri.EndsWith ("/") && address.OriginalString.Length > 0) // with empty URI it should not add '/' to possible file name of the absolute URI
 					baseaddr = new Uri (baseaddr.AbsoluteUri + "/");
 				address = new Uri (baseaddr, address);
 			}