Exportar (0) Imprimir
Expandir Tudo

Tutorial: Using BizTalk Service Bridges to Send and Receive Messages from Service Bus Relay Service

Atualizado: novembro de 2013

This tutorial provides instructions on how to send XML messages with different schemas to a single ponte endpoint deployed using Serviços BizTalk do Microsoft Azure. The ponte processes the message and routes them to more than one relay services based on the business logic defined as part of the solution. Using this scenario, the tutorial also showcases other capabilities of Serviços do BizTalk such as:

  • Route Filters: The ponte enables you to route messages to the intended recipient based on filters. The filters are set on certain values that are passed as part of the message. For example, if the value in the element <Recipient> in the XML message is set to Finance, send the message to Service A. Otherwise, send the message to Service B. For more information, see The Routing Condition.

  • Route Action: Route actions help in bridging protocol mismatch. For example, consider two applications, App A and App B. App A sends messages by using the REST protocol while App B receives only SOAP messages. If App A sends the message to the ponte instead, the ponte includes SOAP headers on the message as part of Route Action. The ponte then sends the message over to App B. For more information, see The Routing Action.

  • Reply Action: Reply Action provides the same capability while sending a response back to the client, that Route action provides while sending a message to the receiver. So, if App B sends a response to App A, pontes use the Reply Action capabilities to stamp the response with headers that the client requires. For more information, see the Reply Action.

This tutorial demonstrates these capabilities of the ponte, in addition to other, using a business scenario.

Business Scenario

Northwind Traders is an automobile insurance company. Northwind Traders receive request for new policy quotes in an XML format compliant with the standard ACORD schema, an industry standard for insurance messages. The incoming messages can be in any ACORD-compliant format. So, Northwind Traders must configure a solution that can process XML messages that conform to more than one XML schema. After Northwind Traders receive the message, it is validated against the provided ACORD message schemas and transformed into a schema internal to Northwind. Northwind then sends the message to a backend service that processes the message further. However, there are certain routing conditions before the message is sent to the service.

  • If the quote amount in the message is less than $10000, it must be sent to a relay service, say RelayReceiverServiceA. Before sending the message to the relay service, a SOAP header called QuoteType must be added to the message header. The value of this header must be set to SmallAmounts.

  • If the quote amount in the message is greater than $10000, it is treated as a high-risk claim and is sent to another relay service, say RelayReceiverServiceB. Before sending the message to the service, a SOAP header called QuoteType must be added to the message header. The value of the header must be set to LargeAmounts.

After receiving the message the services generate a response, add headers, and send a response back to the ponte. The services add the following headers:

 

Response from service Headers added

RelayServiceA

 

Header name Header value

MsgStatus

Success

Eligibility

ApprovedForSmallAmounts

RelayServiceB

 

Header name Header value

MsgStatus

Success

Eligibility

ApprovedForLargeAmounts

The response from the service is in the same format as the Northwind’s internal request format. After the ponte receives the response, it transforms it to the response message schema compliant with ACORD standards. The ponte also extracts the value from the MsgStatus header and assigns it to an element in the response schema. Finally, before sending the message back to the client, the ponte adds another header called ProcessingStatus and sets its value to Complete. The following illustration represents this scenario.

Usando pontes com serviços de retransmissão

How to Achieve the Scenario Using Serviços BizTalk do Microsoft Azure

Northwind Traders use Serviços do BizTalk to set up this scenario on Azure. Here’s what Northwind Traders do at their end for this scenario to work end-to-end:

  • Northwind creates two relay services, RelayReceiverServiceA and RelayReceiverServiceB. RelayReceiverServiceA receives messages with quote amount less than $10000. RelayServiceB receives messages with quote amount greater than $10000. After receiving the message, both the services generate a response message and stamp it with the headers, as described in the business scenario.

  • Northwind creates a Projeto do Serviço BizTalk and adds a Ponte de solicitação-resposta XML to process the incoming XML messages and send a response. Northwind also adds two-way relay service components, one each for RelayReceiverServiceA and RelayReceiverServiceB.

  • Northwind adds all the required artifacts (schemas and transforms) to the Projeto do Serviço BizTalk.

  • Northwind configures the request path of the Ponte de solicitação-resposta XML to do the following:

    • Configures the Validate stage to validate the XML messages against the ACORD schemas.

    • Configures the Enrich stage to promote properties based on which the messages are routed to the backend services.

    • Configures The Transform stage to transform messages from the ACORD schema to Northwind’s internal schema.

  • Northwind configures the response path of the Ponte de solicitação-resposta XML to do the following:

    • Configures the Enrich stage to extract the MsgStatus header that the relay services added to the response message.

    • Configures the Transformação stage to transform the response from the relay services into a message schema compliant with ACORD standards. In this stage, the ponte also assigns the value from the MsgStatus header into an element in the response schema.

    • Configures the Reply Action to include the ProcessingStatus header in the response message that is sent to the client.

  • Northwind adds two external relay endpoints to the Projeto do Serviço BizTalk representing the two relay services and connects them to the Ponte de solicitação-resposta XML bridge. As part of these routing connectors, Northwind does the following:

    • Connects all the components on the Configuração da ponte design surface and sets the filter conditions based on the quote amount.

    • Stamps the QuoteType header on the message and sets its value to either SmallAmounts or LargeAmounts depending on which service the message is being routed to.

  • Finally, Northwind deploys the two relay service on Service Bus and the Projeto do Serviço BizTalk to Serviços do BizTalk and sends a message to the ponte endpoint.

How to Use This Tutorial

This tutorial is written around a sample, Bridges_RelayServices.zip, which is available as part of the download from the MSDN Code Gallery. You could use the sample and go through this tutorial to understand how the sample was built. Or, you could use this tutorial to create your own application. This tutorial is targeted towards the second approach so that you understand how this application was built. Also, as much as possible, the tutorial is consistent with the sample and uses the same names for artifacts (for example, schemas, transforms) as used in the sample.

Even though Microsoft recommends that you follow the tutorial to understand the concepts and procedures, do the following if you wish to use the sample:

  • Download the Bridges_RelayServices sample and make relevant changes like providing your Service Bus namespace, issuer name, issuer key. After making the required changes, build and deploy the application.

  • Build and host the two relay services to accept request messages received via the ponte.

  • Use the MessageSender tool provided with the package to send request messages to the ponte. Look at the command prompts for the services as well as the MessageSender tool to see if the messages were processed successfully. If the messages are successfully processed, the request and response schemas are saved under the project’s \bin\Debug folder. The location and name of the message files are also displayed on the respective command prompts.

Set Up Your Computer

From the Serviços do BizTalk download location (http://go.microsoft.com/fwlink/?LinkId=235057), download and install the Serviços do BizTalk SDK. For instructions, see Install Azure BizTalk Services SDK. Installing the SDK installs the Projeto do Serviço BizTalk template in Visual Studio. This project template is used to create pontes that validate, Transformação, and route messages to different endpoints as described in the business scenario.

In This Section

Consulte também

Contribuições da comunidade

ADICIONAR
Mostrar:
© 2014 Microsoft