aschehal on Thu, 15 Nov 2012 11:27:03

Q1:> How to check the service can receive messages from the client?

Q2:> How to debug and ratify "ContractFilter mismatch at the EndpointDispatcher" error message?

We have created a simple windows console service application using Azure Service bus relay, hosted it in azure service bus namespace. We want WP app to access this service. When we try to access this service using WP, we get "ContractFilter mismatch" error message. Complete error message listed below.

"The message with Action 'GET' 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)."

We can access this service using normal desktop client application by using service bus namespace. But since, service bus namespace is not there for WP, we are using REST api's for WP app.

I am sharing the code for both Service and WP app. It would be great if you could have a look at it and help me to move forward.

Service side code:

namespace ConsoleApplication1
    [ServiceContract(Namespace = "")]
    interface IProblemSolver
        [WebGet(UriTemplate = "/HelloWorld")]
        string HelloWorld();

    [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
    class ProblemSolver : IProblemSolver
        public string HelloWorld()
            return "Hello World!";

    class Program
       static void Main(string[] args)
            var sh = new ServiceHost(typeof(ProblemSolver),
                    new Uri(""));
                 new ServiceMetadataBehavior
                     HttpGetEnabled = true,
                     HttpGetUrl = new Uri("http://localhost:8088/solver")

            var se = sh.AddServiceEndpoint(typeof(IProblemSolver),
                 new BasicHttpRelayBinding(EndToEndBasicHttpSecurityMode.None,
                                           RelayClientAuthenticationType.None), String.Empty);

            var endpointBehavior = new TransportClientEndpointBehavior(
                   TokenProvider.CreateSharedSecretTokenProvider("owner", "**ACCESS*KEY**"));

            Console.WriteLine("Service is up. Press any key to close the service.");

Windows Phone App:

 private void GetDataUsingAcsSecurity()
             var webClient = new WebClient(); 
             string acsUri =

             string data = 

             webClient.Headers["Content-Type"] = 

             webClient.UploadStringCompleted += webClient_UploadStringCompleted;
             webClient.UploadStringAsync(new Uri(acsUri), "POST", data); 

        void webClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
            string token = 
            e.Result .Split('&').Single(x => x.StartsWith("wrap_access_token=",
            string decodedToken = HttpUtility.UrlDecode(token); 

            var uriBuilder = 
            new UriBuilder("");

            uriBuilder.Path += 

            var webClient = new WebClient(); 
            webClient.Headers["Authorization"] = 
            string.Format("WRAP access_token=\"{0}\"", decodedToken);

            webClient.DownloadStringCompleted += 
            (s, args) => ParseAndShowResult(args);

        public void ParseAndShowResult(DownloadStringCompletedEventArgs args)
            string result = args.Result;



Ramiro Berrelleza on Tue, 20 Nov 2012 01:43:21


On the Service, you're configuring the endpoint to not use any type of security, an to run on http, while on the client, you're calling an address with https. Can you see if using the http address instead makes any difference?

Now, from your client code, it seems like your intentions are to consume the service as a REST service instead of a WCF/SOAP service. If that's the case, have you consider using WebHttpRelayBinding instead? This post might be a good way to get started:

Hope it helps!