3. Implementation/WCF

Address filter mismatch

SSKK 2014. 10. 11. 08:36

After setting the URL Rewriter on IIS I got the following error from WCF services which were set as  polling duplex or net.tcp protocols.



 The message with To 'http://localhost/WCFService.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver's EndpointAddresses agree.



The reason is that by default, WCF ensures that the To of each Message matches the intended address.


It's simple to resolve this. Set the AddressFilterMode as Any!


[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]


Here's sample code:



    [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
    public class CalculatorService : ICalculator
    {
        public double Add(double n1, double n2)
        {
            return n1 + n2;
        }

        public double Subtract(double n1, double n2)
        {
            return n1 - n2;
        }

        public double Multiply(double n1, double n2)
        {
            return n1 * n2;
        }

        public double Divide(double n1, double n2)
        {
            return n1 / n2;
        }
    }

References:

http://msdn.microsoft.com/en-us/library/system.servicemodel.addressfiltermode(v=vs.110).aspx 

https://social.msdn.microsoft.com/Forums/vstudio/en-US/b5ae495b-f5fb-4eed-ae21-2b2280d4fec3/address-filter-mismatch-wcf-addressing