Question

I am trying to implement a custom endpoint/operation extension in my WCF service. I have wired up my custom extension in the websconfig so that I can decorate my service & and operations with an attribute. However after doing so I get the following error:

The message with To 'http://localhost:1605/Graph.svc/Triples/vbid/abk9185/0/en-us' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.

I have done a lot of searching but I cannot figure out what this error means or how to fix it. Can someone help?

This is the service that I am 'injecting' my endpoint and operation behaviors onto:

<service name="Services.Graph" behaviorConfiguration="Services.DefaultBehavior">
    <endpoint address="" binding="webHttpBinding" contract="Services.IGraphService" behaviorConfiguration="corsMessageInspection"
 bindingConfiguration="LargeMessageBinding" bindingNamespace="http://icp.myorg.org">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>

Here is my endpoint and service behavior configuration:

<endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>        
    <behavior name="corsMessageInspection">
      <endpointMessageInspector />
    </behavior>        
  </endpointBehaviors>

  <serviceBehaviors>
    <behavior name="Services.DefaultBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />          
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>

Here is my custom endpoint/operation extension configuration:

<extensions>
  <behaviorExtensions>
    <add name="endpointMessageInspector" type="org.myorg.wcf.cors.CorsEndPointExtensionElement, org.myorg.wcf.cors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </behaviorExtensions>
</extensions>

and finally here is an example of what my service contract looks like:

 [ServiceContract(Namespace = "http://icp.myorg.org")]
[CorsBehavior]
public interface IGraphService
{
    [OperationContract]
    [CorsBehavior]
    [WebInvoke(Method = "*", UriTemplate = "Triples/{library}/{subjectLocalPart}/{depth}/{languageCode}")]
    GraphNode ReadTriple(string library, string subjectLocalPart, string depth, string languageCode);

"CorsBehavior" is my custom attribute which implements both IEndPointBehavior and IOperationBehavior.

Was it helpful?

Solution

If you want the [WebInvoke] attribute to be honored, then you need to add the WebHttpBehavior (<webHttp/>) to your endpoint behavior as well. Change your behavior referenced by the endpoint (corsMessageInspection) to have both the webHttp behavior and your custom one:

<endpointBehaviors>
  <behavior name="corsMessageInspection">
    <webHttp />
    <endpointMessageInspector />
  </behavior>
</endpointBehaviors>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top