Saturday, August 8, 2009

WCF load balance error: HTTP 405 Method Not Allowed

---------------------------------------------------------
Server configuration:
---------------------------------------------------------
  1. Two windows 2003 SP2 servers
  2. WCF service is hosted on each service by Windows Service
---------------------------------------------------------
Bindings Info for WCF service:
---------------------------------------------------------<bindings><basicHttpBinding><binding hostNameComparisonMode="Exact" name="basicHttpBindingSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /><security mode="None"><transport clientCredentialType="None" proxyCredentialType="None" realm="" /><message clientCredentialType="UserName" algorithmSuite="Default" /></security></binding></basicHttpBinding><netTcpBinding><binding hostNameComparisonMode="Exact" name="netTcpBindingSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Buffered" maxBufferPoolSize="52428800" maxBufferSize="6553600" maxConnections="10000" maxReceivedMessageSize="6553600"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /><security mode="None"><transport clientCredentialType="None" protectionLevel="EncryptAndSign" /><message clientCredentialType="UserName" algorithmSuite="Default" /></security></binding></netTcpBinding><mexTcpBinding><binding name="mexTcpBindingSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" /></mexTcpBinding></bindings>

---------------------------------------------------------
Service configuration on server 1:
---------------------------------------------------------
<service name="ArielBPM.Services.ServiceBroker.RegisterEventManagement"behaviorConfiguration="ArielBPM.Services.ServiceBrokerBehavior"><host><baseAddresses><add baseAddress="http://192.168.6.84:8001/ArielBPM/Services/ServiceBroker/RegisterEventManagement/" /><add baseAddress="net.tcp://192.168.6.84:9001/ArielBPM/Services/ServiceBroker/RegisterEventManagement/" /></baseAddresses></host><endpoint address="" binding="basicHttpBinding"bindingNamespace="http://ArielBPM.Services.ServiceBroker.RegisterEventManagement/binding"contract="ArielBPM.Services.ServiceBroker.RegisterEventManagement.IRegisterEventManagement"bindingConfiguration="basicHttpBindingSettings"><identity><dns value="192.168.6.84" /></identity></endpoint><endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBindingSettings"contract="ArielBPM.Services.ServiceBroker.RegisterEventManagement.IRegisterEventManagement" /></service>

---------------------------------------------------------
Here is the service configuration on server 2:
---------------------------------------------------------
<service name="ArielBPM.Services.ServiceBroker.RegisterEventManagement"behaviorConfiguration="ArielBPM.Services.ServiceBrokerBehavior"><host><baseAddresses><add baseAddress="http://192.168.6.154:8001/ArielBPM/Services/ServiceBroker/RegisterEventManagement/" /><add baseAddress="net.tcp://192.168.6.154:9001/ArielBPM/Services/ServiceBroker/RegisterEventManagement/" /></baseAddresses></host><endpoint address="" binding="basicHttpBinding"bindingNamespace="http://ArielBPM.Services.ServiceBroker.RegisterEventManagement/binding"contract="ArielBPM.Services.ServiceBroker.RegisterEventManagement.IRegisterEventManagement"bindingConfiguration="basicHttpBindingSettings"><identity><dns value="192.168.6.154" /></identity></endpoint><endpoint address="" binding="netTcpBinding"
bindingConfiguration="netTcpBindingSettings"contract="ArielBPM.Services.ServiceBroker.RegisterEventManagement.IRegisterEventManagement" /></service>

---------------------------------------------------------
WCF service behavior configuration:
---------------------------------------------------------
<serviceBehaviors><behavior name="ArielBPM.Services.ServiceBrokerBehavior"><serviceMetadata httpGetEnabled="True" /><serviceDebug includeExceptionDetailInFaults="True" /><serviceThrottling maxConcurrentCalls="10000" maxConcurrentInstances="10000" maxConcurrentSessions="10000" /></behavior></serviceBehaviors>

---------------------------------------------------------
Load balancer information:
---------------------------------------------------------
DNS name: arielbpm.load.services.msoclient.com

---------------------------------------------------------
Error information:
---------------------------------------------------------
Got "HTTP 405 Method Not Allowed" error when trying to open the following URL in the browser: http://arielbpm.load.services.msoclient.com:8001/ArielBPM/Services/ServiceBroker/RegisterEventManagement/

---------------------------------------------------------
Solution: Update bindings Info for WCF service:
---------------------------------------------------------
<bindings><basicHttpBinding><binding hostNameComparisonMode="WeakWildcard" name="basicHttpBindingSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /><security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /></security></binding></basicHttpBinding><netTcpBinding><binding hostNameComparisonMode="WeakWildcard" name="netTcpBindingSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Buffered" maxBufferPoolSize="52428800" maxBufferSize="6553600" maxConnections="10000" maxReceivedMessageSize="6553600"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /><security mode="None"> <transport clientCredentialType="None" protectionLevel="EncryptAndSign" /> <message clientCredentialType="UserName" algorithmSuite="Default" /></security></binding></netTcpBinding><mexTcpBinding><binding name="mexTcpBindingSettings" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" /></mexTcpBinding></bindings>


Monday, July 20, 2009

"ActionNotSupported" error when accessing WCF HTTP metadata end point

I have a WCF service installed in a Windows 2003 machines, hosted by a Windows service. Everything was working fine after the installation, until one day SI team decided to move the service to a different box. They copy all the DLL's and install the Windows service with the same configuration (different IP/HostNames of course) onto the new machines.

Ever since then, we start getting the following error whenever we try to access the HTTP metadata endpoint address (i.e. http://server/ArielBPM/Services/ServiceBroker/RequestManagement/):
  • faultcode: a:ActionNotSupported
  • faultstring: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

The first thing that I check and confirm that the httpGetEnabled flag is set to true for the servie behavior. After some mindless wandering in all the Google search result that doesn't seem to resolve my issue, I decide to enable the application trace log for my service.

As soon as the application trace log is enabled, I find the following error in the log, which suggests to me that the error is thrown by DotNet FrameWork 3.0 (see ExceptionType below). However, since my DLL's are compiled targetted for DotNet FrameWork 3.5, it shouldn't work under 3.0. Base on these facts, I want to confirm if my assumption is correct. Hence I check under C:\Windows\Microsoft.Net\Framework and C:\Windows\Microsoft.Net\Framework64 and find no trace of v3.5 folder. If the v3.5 folder is not present, that means the DotNet FrameWork 3.5 is not installed at all. Therefore, I go to the Microsoft download site, and download and install the DotNet FrameWork 3.5. Then I re-install the WCF service. And guess what, everything starts working again, and I am able to view the WSDL in the browser again.
  • ExceptionType: System.ServiceModel.FaultException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • Message: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
  • ExceptionString: System.ServiceModel.FaultException: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
  • Stacktrace:
    at System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message)
    at System.ServiceModel.Dispatcher.ChannelHandler.ReplyFailure(RequestContext request, Message fault, String action, String reason, FaultCode code)
    at System.ServiceModel.Dispatcher.ChannelHandler.ReplyContractFilterDidNotMatch(RequestContext request)
    at System.ServiceModel.Dispatcher.ChannelHandler.EnsureChannelAndEndpoint(RequestContext request)
    at System.ServiceModel.Dispatcher.ChannelHandler.TryRetrievingInstanceContext(RequestContext request)
    at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
    at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
    at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
    at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
    at System.ServiceModel.Channels.InputQueue`1.AsyncQueueReader.Set(Item item)
    at System.ServiceModel.Channels.InputQueue`1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread)
    at System.ServiceModel.Channels.InputQueue`1.EnqueueAndDispatch(T item, ItemDequeuedCallback dequeuedCallback, Boolean canDispatchOnThisThread)
    at System.ServiceModel.Channels.InputQueueChannel`1.EnqueueAndDispatch(TDisposable item, ItemDequeuedCallback dequeuedCallback, Boolean canDispatchOnThisThread)
    at System.ServiceModel.Channels.SingletonChannelAcceptor`3.Enqueue(QueueItemType item, ItemDequeuedCallback dequeuedCallback, Boolean canDispatchOnThisThread)
    at System.ServiceModel.Channels.SingletonChannelAcceptor`3.Enqueue(QueueItemType item, ItemDequeuedCallback dequeuedCallback)
    at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, ItemDequeuedCallback callback)
    at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult result)
    at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    at System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)