Browse Source

[wcf] make /js and /jsdebug dispatchers work.

There were several issues here:

- The IChannelDispatcherBoundListener was defined twice, in two different namespaces, and it caused code in
  ChannelDispatcher.Attach not to set its associated listener's ChannelDispatcher property to the correct value.
  This, in turn, caused incorrect HttpListenerManagerTable operation, where it would put the "/js" and "/jsdebug"
  dispatchers in separate HttpListenerManagers, instead of in the main (base) service's one.
- After fixing the above, it turned out that SvcHttpHandler selected the manager based on the host's base address,
  when it should first try to find one whose URL matches the current request exactly.
Marek Habersack 15 years ago
parent
commit
d4bb1c86b7

+ 1 - 1
mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebScriptEnablingBehavior.cs

@@ -107,8 +107,8 @@ namespace System.ServiceModel.Description
 			var uri = new Uri (String.Concat (baseUriString, baseUriString [baseUriString.Length - 1] == '/' ? String.Empty : "/", subPath));
 			var listener = endpoint.Binding.BuildChannelListener<IReplyChannel> (uri);
 			var cd = new ChannelDispatcher (listener, String.Empty);
-			cd.MessageVersion = MessageVersion.None;
 
+			cd.MessageVersion = MessageVersion.None;
 			cd.Endpoints.Add (new EndpointDispatcher (new EndpointAddress (uri), "InteropScriptService", String.Empty)
 				{ ContractFilter = new MatchAllMessageFilter () });
 

+ 0 - 5
mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpChannelListener.cs

@@ -40,11 +40,6 @@ using System.Threading;
 
 namespace System.ServiceModel.Channels.Http
 {
-	internal interface IChannelDispatcherBoundListener
-	{
-		ChannelDispatcher ChannelDispatcher { get; set; }
-	}
-
 	internal class HttpChannelListener<TChannel> : InternalChannelListenerBase<TChannel>, IChannelDispatcherBoundListener
 		where TChannel : class, IChannel
 	{

+ 3 - 1
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs

@@ -75,7 +75,9 @@ namespace System.ServiceModel.Channels
 			EnsureServiceHost ();
 
 			var table = HttpListenerManagerTable.GetOrCreate (host);
-			var manager = table.GetOrCreateManager (host.BaseAddresses [0]);
+			var manager = table.GetOrCreateManager (context.Request.Url);
+			if (manager == null)
+				manager = table.GetOrCreateManager (host.BaseAddresses [0]);
 			var wait = new ManualResetEvent (false);
 			wcf_wait_handles [context] = wait;
 			manager.ProcessNewContext (new System.ServiceModel.Channels.Http.AspNetHttpContextInfo (this, context));

+ 0 - 5
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs

@@ -37,11 +37,6 @@ using System.ServiceModel.Description;
 
 namespace System.ServiceModel.Dispatcher
 {
-	internal interface IChannelDispatcherBoundListener
-	{
-		ChannelDispatcher ChannelDispatcher { get; set; }
-	}
-
 	public class ChannelDispatcher : ChannelDispatcherBase
 	{
 		class EndpointDispatcherCollection : SynchronizedCollection<EndpointDispatcher>

+ 36 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IChannelDispatcherBoundListener.cs

@@ -0,0 +1,36 @@
+//
+// ChannelDispatcher.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2005-2010 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Dispatcher
+{
+	internal interface IChannelDispatcherBoundListener
+	{
+		ChannelDispatcher ChannelDispatcher { get; set; }
+	}
+}

+ 1 - 0
mcs/class/System.ServiceModel/System.ServiceModel.dll.sources

@@ -651,6 +651,7 @@ System.ServiceModel.Dispatcher/FaultContractInfo.cs
 System.ServiceModel.Dispatcher/FilterInvalidBodyAccessException.cs
 System.ServiceModel.Dispatcher/FinalizeProcessingHandler.cs
 System.ServiceModel.Dispatcher/ICallContextInitializer.cs
+System.ServiceModel.Dispatcher/IChannelDispatcherBoundListener.cs
 System.ServiceModel.Dispatcher/IChannelInitializer.cs
 System.ServiceModel.Dispatcher/IClientMessageFormatter.cs
 System.ServiceModel.Dispatcher/IClientMessageInspector.cs