我想在我的WCF服務中實現自定義端點/操作擴展。我已經在websconfig中連接了我的自定義擴展,這樣我就可以裝飾我的服務&和具有屬性的操作。但是這樣做後,我得到以下錯誤:WCF - 使用自定義端點行爲時的尋址問題
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.
我已經做了很多搜索,但我想不出這是什麼錯誤意味着或如何解決它。有人可以幫忙嗎?
這是我「注入」我的端點和操作行爲到服務:
<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>
最後這裏是一個e xample的什麼我的服務合同是這樣的:
[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我的自定義屬性。
Dude ..你是男人。非常感謝。 – Nick 2012-01-05 20:51:09
那個錯誤消息讓我在一個非常不同的地方尋找。包括你的博客:) – Nick 2012-01-05 20:52:44
很高興幫助:) – carlosfigueira 2012-01-06 01:40:52