SALES: 1-800-867-1380

Step 5: Connect Bridge and Services

Updated: November 9, 2014

The previous topics in the tutorial demonstrated how to create the two relay services and how to configure the XML Request-Reply Bridge. This topic demonstrates how to connect the bridge to the two services so that the message that comes to the bridge is routed to the right relay service. And then finally, according to the Business Scenario, this tutorial demonstrates how to stamp the messages routed to the relay services with the QuoteType message header. To achieve these goals, perform the following three tasks:

  • Add the two-way relay endpoint components to the itinerary designer to represent the two-way relay services that receive the message from the bridge.

  • Connect the bridge to the two-way relay endpoints on the bridge and set the routing condition.

  • Stamp the messages sent to the relay services with the QuoteType message header.

Represent Relay Services in the BizTalk Service Project

As mentioned earlier, the tutorial already has two relay receiver services defined and one XML Request-Reply Bridge configured to process the messages. While the bridge is part of the BizTalk Service project, the relay receiver services are two separate projects in themselves. The bridge and the relay receiver services must be connected together so that the messages processed by the bridge can be routed to the services, and vice versa, the response from the relay services can be routed back to the bridge and then to the client. To enable this scenario, the Bridge Configuration design surface provides a Two-Way Relay Endpoint component that you can include in the BizTalk Service project to represent two-way relay services, RelayReceiverServiceA and RelayReceiverServiceB.

To represent RelayReceiverServiceA in the project

  1. From the Toolbox, drag and drop the Two-Way Relay Endpoint component to the BizTalk Service project design surface.

  2. When you drop the component on the itinerary designer, it adds a configuration file to the project. This configuration file must be updated to provide information about the endpoint for the relay service. Perform the following steps to update the configuration file.

    1. From the Solution Explorer, right-click the .config file for the Two-Way Relay Endpoint component and then select Edit WCF Configuration to open the Service Configuration Editor.

    2. Expand the Endpoints node under the Client node in the tree view pane, and then select the existing endpoint TwoWayRelayServiceReference1. In the Client Endpoint details pane, in the General tab, enter the following properties.

       

      Property Name Description

      Name

      Enter the endpoint name, for example, RelayService_SmallAmounts, to represent the relay receiver service that will process messages with quotation amount less than $10000.

      ImportantImportant
      Whatever value you enter here, enter the same value for the Endpoint Configuration Name property.

      Address

      The complete address where the relay endpoint is hosted on the Service Bus. For this tutorial, set the address to the URL where the RelayReceiverServiceA is hosted. You can get the address from the command prompt that represents the RelayReceiverServiceA. Typically, the address should be https://<your_servicebus_namespace>.servicebus.windows.net/RelayReceiverServiceA.

    3. In the Service Configuration Editor, from the Tree View pane, expand Advanced, right-click Endpoint Behaviors, and then select New Endpoint Behavior Configuration.

    4. In the Behavior details pane, enter a name for the behavior, for example, ServiceCredentialBehavior.

    5. In the Behavior element extension position area, select Add, from the Available Elements box, select transportClientEndpointBehavior, and then select Add again. You must add this element to enter the Service Bus credentials for a particular endpoint.

    6. In the Tree View pane, go back to the service endpoint (RelayService_SmallAmounts) that you created, and select the newly created endpoint behavior configuration from the BehaviorConfiguration drop-down list. Accept the default values for all the other properties and from the File menu, select Save. Close the dialog box.

    7. Open the config file (available under the MessageFlowItinerary.bcs in the Solution Explorer) in an XML editor. You will notice that the following has been added to the service configuration file:

      
      <behaviors>
        <endpointBehaviors>
          <behavior name="ServiceCredentialBehavior">
            <transportClientEndpointBehavior>
              <clientCredentials>
                <sharedSecret issuerName="" issuerSecret="" />
              </clientCredentials>
              <tokenProvider>
                <sharedSecret issuerName="" issuerSecret="" />
              </tokenProvider>
            </transportClientEndpointBehavior>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      
      

      For a Service Bus relay endpoint, you only need to include the token credentials. So, you must remove the clientCredentials element and add the value for the Service Bus Issuer Name and Issuer Secret for the tokenProvider credentials. The section of the configuration file would now resemble the following:

      
      <behaviors>
        <endpointBehaviors>
          <behavior name="ServiceCredentialBehavior">
            <transportClientEndpointBehavior>
              <tokenProvider>
                <sharedSecret issuerName="owner" issuerSecret="**********************" />
              </tokenProvider>
            </transportClientEndpointBehavior>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      
      

      Save changes and close the configuration file.

    8. On the Bridge Configuration design surface, right-click the component, and then select Properties. The following table provides information about the properties:

       

      Property Name Description

      Associated Project Item

      A read-only field that provides the name of the associated .config file. If you change the name of the component on the BizTalk Service project design surface by changing the Entity Name property, the name of the .config also changes.

      Endpoint Configuration Name

      Name of the client endpoint configuration in the .config file that defines the address, the binding, and the contract for the WCF relay service that you are representing on the BizTalk Service project design surface. For this tutorial, set this property to RelayService_SmallAmounts. You specified the same value for the Name property in the previous step.

      Because the service configuration file can have any number of endpoints defined, the endpoint name you enter for this property is matched with the endpoint configuration name in the .config file. When a match happens, the corresponding address, binding, and contract for that endpoint are considered.

      Entity Name

      The name of the relay endpoint component on the BizTalk Service project design surface. This name must be unique for an BizTalk Service project. For this tutorial, name it SmallAmounts_Service.

      Runtime Address

      The public runtime endpoint URL where the relay service is deployed.

  3. Save changes to the BizTalk Service project.

To represent RelayReceiverServiceB in the project

  1. From the Toolbox, drag and drop the Two-Way Relay Endpoint component to the BizTalk Service project design surface.

  2. When you drop the component on the design surface, it adds a configuration file to the project. This configuration file must be updated to provide information about the endpoint for the relay service. Perform the following steps to update the configuration file.

    1. From the Solution Explorer, right-click the .config file for the Two-Way Relay Endpoint component and then select Edit WCF Configuration to open the Service Configuration Editor.

    2. Expand the Endpoints node under the Client node in the tree view pane, and then select the existing endpoint TwoWayRelayServiceReference1. In the Client Endpoint details pane, in the General tab, enter the following properties.

       

      Property Name Description

      Name

      Enter the endpoint name, for example, RelayService_LargeAmounts, to represent the relay receiver service that will process messages with quotation amount greater than $10000.

      ImportantImportant
      Whatever value you enter here, enter the same value for the Endpoint Configuration Name property.

      Address

      The complete address where the relay endpoint is hosted on the Service Bus. For this tutorial, set the address to the URL where the RelayReceiverServiceB is hosted. You can get the address from the command prompt that represents the RelayReceiverServiceB. Typically, the address should be https://<your_servicebus_namespace>.servicebus.windows.net/RelayReceiverServiceB.

    3. In the Service Configuration Editor, from the Tree View pane, expand Advanced, right-click Endpoint Behaviors, and then select New Endpoint Behavior Configuration.

    4. In the Behavior details pane, enter a name for the behavior, for example, ServiceCredentialBehaviorB.

    5. In the Behavior element extension position area, select Add, from the Available Elements box, select transportClientEndpointBehavior, and then select Add again. You must add this element to enter the Service Bus credentials for a particular endpoint.

    6. In the Tree View pane, go back to the service endpoint (RelayService_LargeAmounts) that you created, and select the newly created endpoint behavior configuration from the BehaviorConfiguration drop-down list. Accept the default values for all the other properties and from the File menu, select Save. Close the dialog box.

    7. Open the config file (available under the MessageFlowItinerary.bcs node in the Solution Explorer) in an XML editor. You will notice that the following has been added to the service configuration file:

      
      <behaviors>
        <endpointBehaviors>
          <behavior name="ServiceCredentialBehaviorB">
            <transportClientEndpointBehavior>
              <clientCredentials>
                <sharedSecret issuerName="" issuerSecret="" />
              </clientCredentials>
              <tokenProvider>
                <sharedSecret issuerName="" issuerSecret="" />
              </tokenProvider>
            </transportClientEndpointBehavior>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      
      

      For a Service Bus relay endpoint, you only need to include the token credentials. So, you must remove the clientCredentials element and add the value for the Service Bus Issuer Name and Issuer Secret for the tokenProvider credentials. The section of the configuration file would now resemble the following:

      
      <behaviors>
        <endpointBehaviors>
          <behavior name="ServiceCredentialBehaviorB">
            <transportClientEndpointBehavior>
              <tokenProvider>
                <sharedSecret issuerName="owner" issuerSecret="**********************" />
              </tokenProvider>
            </transportClientEndpointBehavior>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      
      

      Save changes and close the configuration file.

    8. On the Bridge Configuration design surface, right-click the component, and then select Properties. The following table provides information about the properties:

       

      Property Name Description

      Associated Project Item

      A read-only field that provides the name of the associated .config file. If you change the name of the component on the BizTalk Service project design surface by changing the Entity Name property, the name of the .config also changes.

      Endpoint Configuration Name

      Name of the client endpoint configuration in the .config file that defines the address, the binding, and the contract for the WCF relay service that you are representing on the BizTalk Service project design surface. For this tutorial, set this property to RelayService_LargeAmounts. You specified the same value for the Name property in the previous step.

      Because the service configuration file can have any number of endpoints defined, the endpoint name you enter for this property is matched with the endpoint configuration name in the .config file. When a match happens, the corresponding address, binding, and contract for that endpoint are considered.

      Entity Name

      The name of the relay endpoint component on the BizTalk Service project design surface. This name must be unique for an BizTalk Service project. For this tutorial, name it LargeAmounts_Service.

      Runtime Address

      The public runtime endpoint URL where the relay service is deployed. For this tutorial, this value is https://newintegration-0-9.servicebus.appfabriclabs.com/RelayReceiverServiceB.

  3. Save changes to the BizTalk Service project.

Connect the bridge with Relay Services

This section provides instructions on how to connect the bridge with the two relay services. As part of the Connectors, enter the ‘route conditions’ that govern when a message is routed to RelayReceiverServiceA and when it’s routed to RelayReceiverServiceB. The following procedure provides instructions on how to connect the bridge with the two services and how to set the routing conditions.

To connect bridge with relay services

  1. In the BizTalk Service project, select the Connector component under the bridges category in the Toolbox.

  2. Take the mouse pointer to the right-end of the bridge (denoted by a red dot when you move the cursor over the component). The mouse pointer changes to show a small “S” sign denoting that this component is the source for the Connector. Select and hold the mouse at the dot, drag it to the left end of the target component, SmallAmounts_Service relay endpoint. The cursor changes again to show a small “T” denoting the target; release the mouse. The two components are now connected.

    Repeat this step to connect the bridge to the other relay service endpoint, LargeAmounts_Service.

  3. Set the routing conditions on the two Connectors. The routing condition must be set on the quote amount in the request message that the bridge receives. The procedure, To extract and promote properties in the pre-transform Enrich stage, already configures the bridge to extract the value of the quote amount into a property called QuoteAmount. Here, you use that property to define the routing condition.

    1. Right-click the route Connector between XML Request-Reply Bridge and SmallAmounts_Service relay endpoint, and then select Properties. In the Properties pane, for the Filter Condition property, select the ellipsis (…) button to the open the Route Filter Configuration dialog box.

    2. In the dialog box, select the Filter option, and then enter the following filter string:

      QuoteAmount < 10000
      
      noteNote
      Use standard SQL 92 syntax for filter expressions.

      Select OK to save the changes and exit.

    3. Repeat the previous step for the Connector between XML Request-Reply Bridge and LargeAmounts_Service relay endpoint and enter the filter string as:

      QuoteAmount >= 10000
      

      The Bridge Configuration design surface resembles the following:

      Connecting bridges with relay services

  4. Save changes to the BizTalk Service project.

With these changes to the project, messages that are sent to the bridge are appropriately routed to the right relay service based on the quote amount.

Include Custom Headers in the Message

The other requirement of the Business Scenario as part of the routing configurations is to ensure that the messages sent to the relay services are stamped with a header called QuoteType. The value of the QuoteType header must be set to SmallAmounts (if the message is routed to the relay endpoint SmallAmounts_Service) or LargeAmounts (if the message is routed to the relay endpoint LargeAmounts_Service).

To add custom headers to the message

  1. Right-click the route Connector between the bridge and the SmallAmounts_Service relay endpoint, and then select Properties. In the Properties pane, for the Route Action property, select the ellipsis (…) button to the open the Route Actions dialog box.

  2. In the Route Actions dialog box, select Add to open the Add Route Action dialog box. In the Add Route Action dialog box, do the following:

     

    Section Field name Description

    Property (Read From)

    Expression

    Set this property to 'SmallAmounts', which is the value of the message header we are adding.

    ImportantImportant
    Always enter the value for an expression within single quotes.

    Destination (Write To)

    Type

    Set this property to SOAP.

    SOAP Header Namespace

    Set this property to http://Northwind.com/insurance/ACORD1/xml/. The value you enter is the namespace of the message header.

    Identifier

    Set this property to QuoteType. The value you enter is the name of the message header.

    The dialog box resembles the following:

    Set route action for connections from EAI bridges

    Select OK in the Add Route Action dialog box and then select OK again in the Route Connections dialog box.

  3. Repeat the last step on the route Connector between the bridge and the LargeAmounts_Service relay endpoint. However, for that Connector you must enter the value in the Expression field as 'LargeAmounts'

  4. Save changes to the BizTalk Service project.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft