前面的博客提到过SOAP Adapter与WSE Adapter对SOAPHeader的处理。最近使用WCF Adapter,感觉处理方法略有不同。
首先,与SoapHeader有关的Message Type.
定义一个Property Schema,添加一个属性节点,属性节点的名称必须与wsdl导出的SoapHeader部分的节点名称完全一致。而且,设置Property Schema的"Target NameSpace"属性值为“http://schemas.microsoft.com/BizTalk/2003/SOAPHeader”
。设置节点的"Property Schema Base"属性值为“MessageContextPropertyBase"
在Orchestration中,
InboundSOAPHeaderXML = WSActivateMsg(CustomSOAPHeaderClass);
CustomSOAPHeaderClass是Property Schema中的属性名,InboundSOAPHeaderXML是string类型的变量。
添加CustomSOAPHeaderCls xsd类型的消息。通过如下方法,
public XmlDocument PrepareSOAPHeaderClass(string sSOAPHeaderXML)
{
XmlDocument soapHeaderOut = null;
if (sSOAPHeaderXML != "")
{
XmlDocument soapHeaderIn = new XmlDocument();
try
{
soapHeaderIn.LoadXml(sSOAPHeaderXML);
通过map由CustomSOAPHeaderCls消息构造Multi-part Message。
把SoapHeader信息attach到SoapIn中:
CommonCallRequest(WCF.OutboundCustomHeaders)="<headers>"+IntegrationUtil.ExtractXMLString(OutboundSOAPHeader)+"</headers>";
其中,OutboundSOAPHeader是Multi-part Message.
public string ExtractXMLString(XmlDocument xmlDoc )
{
string sXML = "";
if (xmlDoc != null)
{
sXML = xmlDoc.DocumentElement.OuterXml;
}
return sXML;
}
首先,与SoapHeader有关的Message Type.
定义一个Property Schema,添加一个属性节点,属性节点的名称必须与wsdl导出的SoapHeader部分的节点名称完全一致。而且,设置Property Schema的"Target NameSpace"属性值为“http://schemas.microsoft.com/BizTalk/2003/SOAPHeader”
。设置节点的"Property Schema Base"属性值为“MessageContextPropertyBase"
在Orchestration中,
InboundSOAPHeaderXML = WSActivateMsg(CustomSOAPHeaderClass);
CustomSOAPHeaderClass是Property Schema中的属性名,InboundSOAPHeaderXML是string类型的变量。
添加CustomSOAPHeaderCls xsd类型的消息。通过如下方法,
public XmlDocument PrepareSOAPHeaderClass(string sSOAPHeaderXML)
{
XmlDocument soapHeaderOut = null;
if (sSOAPHeaderXML != "")
{
XmlDocument soapHeaderIn = new XmlDocument();
try
{
soapHeaderIn.LoadXml(sSOAPHeaderXML);
string sXML = soapHeaderIn.DocumentElement.OuterXml;
soapHeaderOut = new XmlDocument();
soapHeaderOut.LoadXml(sXML);
}
catch(Exception ex)
{
soapHeaderOut = null;
}
}
return soapHeaderOut;
}
通过map由CustomSOAPHeaderCls消息构造Multi-part Message。
把SoapHeader信息attach到SoapIn中:
CommonCallRequest(WCF.OutboundCustomHeaders)="<headers>"+IntegrationUtil.ExtractXMLString(OutboundSOAPHeader)+"</headers>";
其中,OutboundSOAPHeader是Multi-part Message.
public string ExtractXMLString(XmlDocument xmlDoc )
{
string sXML = "";
if (xmlDoc != null)
{
sXML = xmlDoc.DocumentElement.OuterXml;
}
return sXML;
}