我正在尝试设置我的Biztalk业务流程发送给WCF的消息的MessageHeader。消息合同在WCF项目中如下所示。
[MessageContract(IsWrapped = true, WrapperName = "PerformTransformationRequestWrapper", WrapperNamespace="http://www.iasreo.com/integration/servicetypes")]
public class PerformTransformationRequest
{
[MessageHeader(Namespace = "http://www.iasreo.com/integration/servicetypes")]
public string Version { get; set; }
/// <summary>
///
/// </summary>
[MessageHeader(Namespace = "http://www.iasreo.com/integration/servicetypes", MustUnderstand = true)]
public TransformType TransformType { get; set; }
/// <summary>
///
/// </summary>
[MessageBodyMember(Namespace = "http://www.iasreo.com/integration/servicetypes")]
public System.IO.Stream Payload { get; set; }
}
TransformType.cs
[DataContract(Namespace = "http://www.iasreo.com/integration/servicetypes")]
public enum TransformType
{
/// <summary>
/// Transform to Excel
/// </summary>
[EnumMember]
ExcelTransform = 1,
/// <summary>
/// Transform to PDF
/// </summary>
[EnumMember]
PDFTransform = 2
}
我正在创建要以消息分配形状发送给Biztalk的消息,该代码如下所示:
xmlDoc = new System.Xml.XmlDocument();
xmlDoc.LoadXml(@"<ns0:PerformTransformationRequestWrapper xmlns:ns0=""http://www.iasreo.com/integration/servicetypes""><ns0:Payload>GpM7</ns0:Payload></ns0:PerformTransformationRequestWrapper>");
PerformTransformationRequest = xmlDoc;
xpath(PerformTransformationRequest, "/*[local-name()='PerformTransformationRequestWrapper' and namespace-uri()='http://www.iasreo.com/integration/servicetypes']/*[local-name()='Payload']") = System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(Input.OuterXml));
如何在WCF MessageContract中设置MessageHeaders的Version和TransformType?
答案 0 :(得分:1)
您可以设置外发邮件的提升WCF.OutboundCustomHeaders属性
OutboundMessage(WCF.OuboundCustomHeaders) = "...";
您需要提供完整的WCF标头字符串作为参数。