将Biztalk消息上下文发送到WCF服务 [英] Send Biztalk message context to WCF service

查看:80
本文介绍了将Biztalk消息上下文发送到WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用WCF适配器时,我将消息主体部分作为WCF消息的主体发送,但是我可以做为使Biztalk消息上下文也要发送(希望在WCF消息头中)吗?

When using the WCF adapter, I have the message body part being send as the body of the WCF message, but can I do to get the Biztalk message context to be sent as well (hopefully within the WCF message header)?

推荐答案

MSDN中的后续页面简要说明了使用WCF适配器在BizTalk外部发送消息时如何使用自定义SOAP标头.

The following page in MSDN succinctly explains how you can use custom SOAP headers when sending messages outside BizTalk with the WCF adapters.

基本上,您不能直接在BizTalk外部发送BizTalk消息的上下文.这是没有意义的.相反,您可以在BizTalk消息的上下文中选择属性的子集,以通过自定义SOAP标头发送到WCF适配器.

Basically, you cannot directly send the context of your BizTalk messages outside BizTalk. This would be meaningless. Rather, you can select a subset of the properties in the context of your BizTalk messages to be sent to the WCF adapter through custom SOAP headers.

处理来自WCF请求的自定义SOAP标头

与传出请求关联的SOAP标头必须明确地写入到传出消息的上下文中.

SOAP headers associated with an outgoing request must explicitly be written to the context of the outgoing message.

使用WCF适配器时,使用内置的

When using the WCF Adapters, SOAP Headers are defined with the built-in WCF.OutboundCustomHeaders context property. This property holds all custom SOAP headers, wrapped inside an additional <headers> tag.

可以在业务流程中使用Expression形状中的以下语法指定标头:

Headers can be specified from within an orchestration with the following syntax in an Expression shape:

OutboundMessage(WCF.OutboundCustomHeaders) = "" +
  "<headers>"
  "<tns1:Header1 xmlns:tns1='http://tns1'>" +
  "</tns1:Header1>" +
  "<tns2:Header2 xmlns:tns2='http://tns2'>" +
  "</tns2:Header2>" +
  "</headers>" +
  "";

请注意,自定义SOAP标头< tns1:Header1>和< tns2:Header2>以上用于说明目的的内容必须是WCF服务合同的一部分.当为使用的WCF服务创建服务引用时,这些自定义SOAP标头将在业务流程中用作生成的架构.

Please, note that the custom SOAP Headers <tns1:Header1> and <tns2:Header2> used for illustration purposes above must be part of your WCF service contract. When you create a service reference for the consumed WCF service, those custom SOAP headers will be available as generated schemas in your orchestration.

如何在自定义SOAP标头中发送特定的上下文属性

现在,您知道如何指定自定义SOAP标头,您可以使用此语法将消息上下文中的特定属性发送到自定义SOAP标头,如下所示:

Now that you know how to specify custom SOAP Headers, you can use this syntax to send specific properties from the context of your messages to the custom SOAP headers like so:

OutboundMessage(WCF.OutboundCustomHeaders) =
  System.String.Format(
    "" +
    "<headers>"
    "<tns1:Header1 xmlns:tns1='http://tns1'>" +
    "  <tns1:Property1>{0}</tns1:Property1>" +
    "  <tns1:Property2>{1}</tns1:Property2>" +
    "</tns1:Header1>" +
    "</headers>" +
    ""
  , InboundMessage(FILE.ReceivedFileName)
  , InboundMessage(BTS.MessageType)
  ));

在上面的示例中,已选择两个内置上下文属性FILE.ReceivedFileName和BTS.MessageType并将其写入自定义SOAP标头中.在现实世界中,您需要在使用属性之前先检查属性是否存在于上下文中.

In the example above, the two builtin context properties FILE.ReceivedFileName and BTS.MessageType have been selected and written inside the custom SOAP header. In a real world scenario, you would want to check whether the properties exist in the context before using them.

您还可以使用任何自定义上下文属性,只要已在适当的属性模式中对其进行了声明.

You can also use any custom context property, provided they have been declared in an appropriate Property Schema.

这篇关于将Biztalk消息上下文发送到WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆