如何在WCF请求和响应的soap标头中添加MessageID? [英] How to add MessageID in the soap headers of WCF request and response?

查看:47
本文介绍了如何在WCF请求和响应的soap标头中添加MessageID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

企业移动设备管理协议在HTTP POST请求中显示以下soap xml.如何定义我的Web服务以使标头包含在请求和响应中的 Action,MessageID,ReplyTo和To .我尝试在MessageCOntract中定义MessageHeader,但这会导致自定义名称空间前缀.为此,我找不到更好的文档链接.如何在客户端和Web服务端设置这些标头?

The enterprise mobile device management protocol shows the below soap xml in HTTP POST Request. How can I define my web service to soap headers to include Action , MessageID, ReplyTo and To in request and response. I have tried defining the MessageHeader in MessageCOntract, but this results in custom namespace prefixes. I could not find a better documentation links for this. How to set the these headers in client side and web service side?

 <?xml version="1.0"?>
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> 
    <a:Action s:mustUnderstand="1"> http://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/Discover 
    </a:Action> 
    <a:MessageID>
    urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478
    </a:MessageID>
    <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo> 
    <a:To s:mustUnderstand="1"> https://ENROLLTEST.CONTOSO.COM/EnrollmentServer/Discovery.svc </a:To> 
    </s:Header> 
    <s:Body> 
    <Discover
    xmlns="http://schemas.microsoft.com/windows/management/2012/01/enrollment/"> 
    <request xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <RequestVersion>1.0</RequestVersion> 
    </request> 
    </Discover> 
    </s:Body> 
    </s:Envelope>

推荐答案

使用自定义绑定,以使这些标头包含在请求中并被服务器接受:

Use a custom binding such that these headers are included in the request and accepted by the server:

  <binding name="NewBinding0">
    <textMessageEncoding messageVersion="Soap12WSAddressing10" />
    <httpTransport />
  </binding>

通常,没有理由在响应中包括这些标头,这不是ws-addressing所必需的.如果需要,请使用邮件检查器将其推送到邮件.

In general there is no reason to include these headers in the response, this is not mandatory by ws-addressing. If you need then push them to the message using a message inspector.

这篇关于如何在WCF请求和响应的soap标头中添加MessageID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆