【发布时间】:2018-06-30 19:53:03
【问题描述】:
我现在正在实现IDispatchMessageInspector接口的AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)方法来拦截WCFSOAP消息。
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>
【问题讨论】:
-
如果你想调整soap XML消息的结构,你需要使用MessageContract。
-
您有什么问题?阅读或更改信息。
-
阅读和更新
-
显示你目前拥有的代码。
标签: c# wcf soap interceptor idispatchmessageinspector