Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

HTTPRelayBinding ContractFilter mismatch at the EndpointDispatcher issue

$
0
0

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 = "https://psappservicenamespace.servicebus.windows.net")]
    interface IProblemSolver
    {
        [OperationContract]
        [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("http://psappservicenamespace.servicebus.windows.net/solver"));
            sh.Description.Behaviors.Add(
                 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**"));

            se.Behaviors.Add(endpointBehavior);
            sh.Open();
            Console.WriteLine("Service is up. Press any key to close the service.");
            Console.ReadLine();
            sh.Close();     
        }
    }
}

Windows Phone App:

 private void GetDataUsingAcsSecurity()
        {
             var webClient = new WebClient(); 
             string acsUri =
             "https://psappservicenamespace-sb.accesscontrol.windows.net/WRAPv0.9/"; 

             string data = 
             string.Format("wrap_name={0}&wrap_password={1}&wrap_scope={2}", 
             HttpUtility.UrlEncode("owner"), 
             HttpUtility.UrlEncode("
**ACCESS*KEY**"),
             HttpUtility.UrlEncode("http://psappservicenamespace.servicebus.windows.net"));

             webClient.Headers["Content-Type"] = 
             "application/x-www-form-urlencoded"; 

             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=",
            StringComparison.OrdinalIgnoreCase)).Split('=')[1];
            string decodedToken = HttpUtility.UrlDecode(token); 

            var uriBuilder = 
            new UriBuilder("https://psappservicenamespace.servicebus.windows.net/solver");

            uriBuilder.Path += 
            string.Format("/HelloWorld); 

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

            webClient.DownloadStringCompleted += 
            (s, args) => ParseAndShowResult(args);
            webClient.DownloadStringAsync(uriBuilder.Uri);
        }

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


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>