[英]WCF - Addressing issue when using custom endpoint behavior
I am trying to implement a custom endpoint/operation extension in my WCF service. 我正在尝试在WCF服务中实现自定义终结点/操作扩展。 I have wired up my custom extension in the websconfig so that I can decorate my service & and operations with an attribute.
我已经在websconfig中连接了自定义扩展名,以便可以使用属性装饰服务和操作。 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.
由于EndpointDispatcher上的AddressFilter不匹配,因此无法在接收方处理带有To'http:// localhost:1605 / Graph.svc / Triples / vbid / abk9185 / 0 / zh-cn'的消息。 Check that the sender and receiver's EndpointAddresses agree.
检查发送方和接收方的EndpointAddresses是否一致。
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. “ CorsBehavior”是我的自定义属性,它同时实现了IEndPointBehavior和IOperationBehavior。
If you want the [WebInvoke]
attribute to be honored, then you need to add the WebHttpBehavior ( <webHttp/>
) to your endpoint behavior as well. 如果希望使用
[WebInvoke]
属性,则还需要将WebHttpBehavior( <webHttp/>
)添加到端点行为中。 Change your behavior referenced by the endpoint (corsMessageInspection) to have both the webHttp behavior and your custom one: 更改端点(corsMessageInspection)引用的行为,以同时具有webHttp行为和自定义行为:
<endpointBehaviors>
<behavior name="corsMessageInspection">
<webHttp />
<endpointMessageInspector />
</behavior>
</endpointBehaviors>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.