0

我需要在我们的 WCF 服务中使用 WS-Addressing/WS-Security。这些服务由移动设备 Windows Mobile 6 / .NET Compact Frameowk 3.5 调用。

我几乎一切正常,但由于某种原因 MessageID 没有包含在我的标题中,它被列为要求。绑定和客户端已指定 Soap12WSAddressing10。我从传输级日志中得到这个:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <a:Action s:mustUnderstand="1" u:Id="_3">http://tempuri.org/ISyncService/GetSchemaResponse</a:Action>
    <ActivityId CorrelationId="28815cbc-7d07-45ea-9ce6-ce0a68a375f2" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">7a63c3ec-5955-47fd-9af2-45211b839783</ActivityId>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <u:Timestamp u:Id="uuid-4fb4f460-8485-492b-9865-1b4b49c5c187-16">
      <u:Created>2011-10-24T22:09:53.182Z</u:Created>
      <u:Expires>2011-10-24T22:14:53.182Z</u:Expires>
    </u:Timestamp>

有什么建议么?

4

1 回答 1

0

我不知道问题是否已经回答。我假设您想MessageId在响应中添加 ws 寻址标头。您可以在函数中实现一个IDispatchMessageInspector和,您可以在回复中添加一个(我使用的是 VB.NET,但 C# 应该是等效的):beforesendreplyMessageId

Public Sub BeforeSendReply(ByRef reply As System.ServiceModel.Channels.Message, ByVal correlationState As Object) Implements IDispatchMessageInspector.BeforeSendReply
   reply.Headers.MessageId = New UniqueId(Guid.NewGuid())
End sub

就我而言MessageIdTo使用messageversion Soap11WSAddressing10 or Soap12WSAddressing10. 我设法MessageId使用上面的代码添加了,但是如果我尝试以To相同的方式添加标头,To则当响应到达客户端时,标头永远不会包含在内。

于 2012-02-17T15:12:37.580 回答