Home » .Net FrameworkRSS

ContractFilter mismatch

If I call a WCF via
EndpointAddress epa = new EndpointAddress("net.tcp://myserver/Service.svc");

                        NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
                        binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                        binding.Security.Mode = SecurityMode.None;
                        binding.MaxBufferPoolSize = 500000000;
                        binding.MaxBufferSize = 500000000;
                        binding.MaxReceivedMessageSize = 500000000;
                        binding.MaxConnections = 10;
                        binding.ReaderQuotas.MaxDepth = 32;
                        binding.ReaderQuotas.MaxStringContentLength = 2147483647;
                        binding.ReaderQuotas.MaxArrayLength = 2147483647;
                        binding.ReaderQuotas.MaxBytesPerRead = 4096;
                        binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;

                        ServiceChannel proxy;

                        ChannelFactory<ServiceChannel> cf =
                            new ChannelFactory<IEDIServiceChannel>(binding, epa);

                        proxy = cf.CreateChannel();
 proxy.MyMethod();

I get the following error. I have verified that my Service is implementing the MyMethod !!!!!

System.ServiceModel.ActionNotSupportedException was unhandled
  Message="The message with Action 'Svc/IService/MyMethod' 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)."
  Source="mscorlib"
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at IEDIService.Route2TPFolder(Byte[] fileContent, String transID, String srcFileName)
 

3 Answers Found

 

Answer 1

Can you verify that the binding  configurations on both sides are absolutely the same? It would be easier (if you don't have any experience with WCF) to create a proxy using the "Add service reference" feature in VS - have you considered doing so?

Regards,

Stipe Ivan

 

Answer 2

Hi SV,

The error message indicate that the error is raised by ContractFilter, therefore I think we need to verify whether the Contract type( ServiceContract type) used at client and service sides matchs with each other. Based on your code, the Contract type is "IEDIServiceChannel"

ChannelFactory<ServiceChannel> cf =
              new ChannelFactory<IEDIServiceChannel>(binding, epa);
Also, for testing, suggest you use "Add ServiceRefernce" to generate a proxy class and call  the service to see whether it works. If so works, you can compare the generated proxy code(and Contract type) with the one you currently used to find any difference.


 

Answer 3

My guess is you have the service contracts defined with different namespaces (Namespace property of the service contract) on client and service
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter