0

我正在尝试在我的 WCF 服务中实现自定义端点/操作扩展。我已经在 websconfig 中连接了我的自定义扩展,以便我可以使用属性来装饰我的服务和操作。但是,这样做之后,我收到以下错误:

由于 EndpointDispatcher 的 AddressFilter 不匹配,接收方无法处理带有 To 'http://localhost:1605/Graph.svc/Triples/vbid/abk9185/0/en-us' 的消息。检查发送方和接收方的 EndpointAddresses 是否一致。

我做了很多搜索,但我无法弄清楚这个错误是什么意思或如何解决它。有人可以帮忙吗?

这是我将端点和操作行为“注入”到的服务:

<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>

这是我的端点和服务行为配置:

<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>

这是我的自定义端点/操作扩展配置:

<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>

最后,这是我的服务合同的示例:

 [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”是我的自定义属性,它实现了 IEndPointBehavior 和 IOperationBehavior。

4

1 回答 1

0

如果您希望该[WebInvoke]属性得到尊重,那么您还需要将 WebHttpBehavior ( <webHttp/>) 添加到您的端点行为中。将端点 (corsMessageInspection) 引用的行为更改为同时具有 webHttp 行为和自定义行为:

<endpointBehaviors>
  <behavior name="corsMessageInspection">
    <webHttp />
    <endpointMessageInspector />
  </behavior>
</endpointBehaviors>
于 2012-01-05T20:35:00.673 回答