从客户端请求中删除 Action (mustUnderstand)

Remove Action (mustUnderstand) from client request

我有一个不受我控制的远程端点,我没有 WSDL 但我有 SOAP 消息样本。由于我真的不想玩剪刀和手工制作肥皂信封,我的想法是创建 service/data 合同,它将(一旦在 WCF 客户端中使用)生成所需的 SOAP 请求并解析响应。我立即遇到第一种方法的问题,因为每个信封似乎都包含 header:

中的 Action 寻址
<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">urn:IService1/Auth</Action>
  </s:Header>
  <s:Body>
    <Auth>
      <login xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <Password i:nil="true" />
        <userName i:nil="true" />
      </login>
    </Auth>
  </s:Body>
</s:Envelope>

这会扰乱大量 objects 我的消息的被叫方。我尝试了不同的配置方法(我使用 web.config 来配置模拟服务和客户端),但似乎没有什么可以删除这个恼人的 Action 节点。有什么方法可以解决这个问题而不做我不想做的事情(手动玩 XML)

我的问题已解决,我移动 XML 序列化格式,如 Force parameter as Service contract attribute 中所述。当我切换到 XML 格式化程序时,操作 header 停止生成。但是,如果有人知道如何在 DataContract 类 中删除它,请随意展示,我相信它会有用。