Message with "..." could not be processed in the receiver due to an AddressFilter mismatch in the EndpointDispatcher

I am trying to implement WCF Rest service without modifying the App.config file .

My service interface looks like this:

[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebInvoke(Method = "POST",
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/teststr/?string={aStr}")]
    string TestString(string aStr);
}

      

The implementation of the Service is very simple:

public class TestService : IService
{
    public string TestString(string aStr = null)
    {
        Console.WriteLine("The Test() method was called at {0}"
            + "\n\rThe given string was {1}\n\r"
            , DateTime.Now.ToString("H:mm:ss")
            , aStr);

        return aStr;
    }
}

      

And my main program that runs everything:

// Step 1 Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8000/ServiceSample/");

// Step 2 Create a ServiceHost instance
ServiceHost selfHost = new ServiceHost(typeof(TestService), baseAddress);

try
{
    // Step 3 Add a service endpoint.
    selfHost.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), 
        "TestService");

    // Step 4 Enable metadata exchange.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    selfHost.Description.Behaviors.Add(smb);

    // Step 5 Start the service.
    selfHost.Open();
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.ReadLine();

    // Close the ServiceHostBase to shutdown the service.
    selfHost.Close();
}
catch (CommunicationException ce)
{
    Console.WriteLine("An exception occurred: {0}", ce.Message);
    selfHost.Abort();
}

      

When I run this and enter the following url:

http://localhost:8000/ServiceSample/TestService/teststr/?string=thisisatest

      

I am getting this message:

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

      

I've looked at similar SO questions suggesting I add a <webHttp/>

behavior
(but doesn't Step 4

it already?) Others said adding [ServiceBehavior ..] . None of these worked and I didn't find the related SO questions helpful.

Do I need to change the App.config file? What am I doing wrong here?

+3


source to share


1 answer


I realize there is an answer in the comments, but I will try to point out what I learned while trying to find a solution to my problem as this is the first page that comes up on Google by searching for the error message.

I was trying to call a third party SOAP web service from JavaScript (terrible I know) and I ran into this problem.

The SOAP 1.2 service I was calling required me to place the :To

SOAP Addressing header in <soap:Header>

<soap:Envelope>

. By doing this and also adding :Action

which I got from WSDL I was golden.

In the end, the SOAP header looked like this:



<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <wsa:To>(WebService URL)</wsa:To>
    <wsa:Action>(Action from WebService WSDL)</wsa:Action>
</soap:Header>

      

Useful sites:

+8


source







All Articles