可以在管道组件中使用 WCF 适配器设置自定义 SOAP 标头。 使用上下文属性名称、 OutboundCustomHeaders 和目标命名空间 http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties的组合。 使用 OutboundCustomHeaders 属性时,该属性必须将 <标头> 元素作为根元素。 所有自定义 SOAP 标头都必须放在<标头>元素内。 如果自定义 SOAP 标头值为空字符串,则必须将<标头></标头>或<标头/>分配给OutboundCustomHeaders属性。 有关如何将 SOAP 标头与 WCF 适配器配合使用的详细信息,请参阅 SDK 示例,在 WCF 适配器 https://go.microsoft.com/fwlink/?LinkId=79960中使用自定义 SOAP 标头。
下面的代码示例在名为 OutboundCustomHeaders 的属性的发送管道组件中设置自定义 SOAP 标头:
public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
{
   try
      {
       string stringVar = "<headers>
             <Origination>Home</Origination>
             <Destination>Work</Destination>
          </headers>";
inmsg.Context.Write("OutboundCustomHeaders","http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties", stringVar);
      }
   catch (Exception ex)
      {
   throw new Exception("Pipeline component exception - " + ex.Message);
      }
return inmsg;
}
有关管道组件的详细信息,请参阅 开发自定义管道组件。
注释
不得设置 WCF 基础结构用于 Web 服务标准的标准 SOAP 标头,例如 WS-Addressing、WS-Security 和 WS-AtomicTransaction。
另请参阅
在 WCF 消息中使用 SOAP 标头与业务流程与已消费的 WCF 服务的 SOAP 标头WCF 适配器属性架构及其属性与已发布 WCF 服务的 SOAP 标头