1
嗨如果操作是裝飾的,我需要在消息中注入自定義標頭。WCF:通過裝飾爲操作注入自定義標頭
到目前爲止我做了什麼? 1)創建屬性通過繼承屬性和IOperationBehavior 2)添加與操作
屬性定製OperationInvoker:
public class RankAttribute : Attribute, IOperationBehavior
{
public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
{
dispatchOperation.Invoker = new PublishMessageInvoker(dispatchOperation.Invoker);
}
//rest of the methods
}
接口:
public interface INullableService
{
[OperationContract]
[FaultContract(typeof(BusinessServiceException))]
[Rank]
NullableResponse NullChecking(NullableRequest request);
[OperationContract]
[FaultContract(typeof(BusinessServiceException))]
NullableResponse NullChecking2(NullableRequest request);
}
現在的問題是,我不知道在哪裏修改消息頭,我可以通過operationDiscription.Messages []獲得消息,但文檔說任何修改都會產生意想不到的結果。
感謝, 阿維納什