使用 WCF / .NET Compact Framework 的 Soap 标头中缺少 WS-Addressing 元素

发布于 2024-12-11 13:48:26 字数 1171 浏览 0 评论 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>

有什么建议吗?

I'm required to use WS-Addressing/WS-Security in our WCF services. The services are called by a mobile device, Windows Mobile 6 / .NET Compact Frameowk 3.5.

I have just about everything working, but for some reason MessageID isn't getting included in my header, and it's listed as a requirement. The binding and client have Soap12WSAddressing10 specified. I'm getting this from transport level logging:

<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>

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空宴 2024-12-18 13:48:26

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

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

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

I do not know if the question is already answered. I am assuming you want to add the ws addressing header MessageId in your response. You could implement an IDispatchMessageInspector and in the beforesendreply function you could add a MessageId in the reply( I used VB.NET but C# should be equivalent):

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

In my case both the MessageId and the To-header were missing in my response while using messageversion Soap11WSAddressing10 or Soap12WSAddressing10. I managed to add the MessageId with the above code, but if I try to add the To header in the same way, the To header is never included when the response arrives at the client.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文