【问题标题】:Soap service header <s:mustUnderstand in C#C# 中的肥皂服务标头 <s:mustUnderstand
【发布时间】:2018-07-02 11:46:22
【问题描述】:

我创建了网络服务来接受这个肥皂请求。 我测试过,没有标题它工作正常 如果我添加标题仍然适用于 s:mustUnderstand="0" 但是 如果我把它改成 1 它就坏了

动作 s:mustUnderstand="1"

为了接受标头,我需要对我的 Web 服务进行哪些更改? 在此先感谢

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">   <s:Header>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.xxxx-ccc.co.uk/Integration/SaveApplication</Action> </s:Header>  

<s:Body>  applicant>
          <title>Mr</title>
          <forename>dd</forename>
          <surname>ee</surname>
          <address>
            <street1>ppp</street1>
            <town>dd</town>
            <county>cc</county>
            <postcode>rtrtr</postcode>
          </address>
        </applicant> 
</s:Body> </s:Envelope>

这是我的网络服务代码

 [WebService(Namespace = "http://www.xxxx-ccc.co.uk/Integration/")]
 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
 [System.ComponentModel.ToolboxItem(false)]
    public class CG_ADNContact : System.Web.Services.WebService
    {

        [WebMethod(Description = "")]
        public XmlDocument SaveApplication()
        { //Do some thing }

}

【问题讨论】:

  • 您好,您知道了吗?我有确切的问题。你在 wcf 服务中做了什么更改为接受 musunderstand =1
  • 2020 年 11 月,这仍然是一个问题。我可以确认 WCF 代理将自动生成您所说的 soap:header,并且它实际上是通过网络提交的(如果相信 Microsoft 提供的 MessageInspectors 基础结构)。我在客户端(就在 POST 之前)和服务器端(就在收到 POST 消息之后)都创建了 MessageInspectors。奇怪的是,如果使用标准 HTTP 发布,服务总是返回 400 错误,除非 SOAP:Header with Action MustUnderstand=1 被删除!

标签: c# xml soap


【解决方案1】:

http://schemas.microsoft.com/ws/2005/05/addressing/none 命名空间对于 Action 元素无效。它不应该出现在肥皂信息中。你从哪里得到消息的?您是否从 wcf 跟踪日志中复制了它?

如果mustUnderstand 属性设置为true(或1),这基本上意味着有问题的元素必须是服务合同的一部分。您可以使用MessageHeader 属性的MustUnderstand 属性来控制它。

有关使用此属性的示例服务合同,请参阅 here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多