[英]How to read, alter, and update back the item values inside <soapenv: Body> tag in AfterReceiveRequest() method
我現在正在實現IDispatchMessageInspector
接口的AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
方法來偵聽WCF
SOAP
消息。
System.ServiceModel.Channels.Message request
如下
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
<To soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:8993/TLS.svc/soap</To>
<Action soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/TLS/GetMerchant</Action>
</soapenv:Header>
<soapenv:Body>
<tem:GetMerchant>
<tem:item1>value1</tem:item1>
<tem:item2>value2</tem:item2>
</tem:GetMerchant>
</soapenv:Body>
</soapenv:Envelope>
我想讀取和更改<tem:item1></tem:item1>
<tem:item2></tem:item2>
並更新回System.ServiceModel.Channels.Message request
而不會損壞其他消息的原始屬性
<soapenv:Envelope ... >
<soapenv:Header>
<To soapenv:mustUnderstand="1" ... </To>
<Action soapenv:mustUnderstand="1" ... </Action>
</soapenv:Header>
<soapenv:Body>
<tem:GetMerchant>
<tem:item1>Updatedvalue1</tem:item1>
<tem:item2>Updatedvalue2</tem:item2>
</tem:GetMerchant>
</soapenv:Body>
</soapenv:Envelope>
這篇文章描述了您在分派器級別上處理它的方式,這將使您可以攔截所有傳入的消息。 您只需要仔細閱讀並閱讀。 https://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.