biztalk2009buildingyourfirstbizalksolution

Upload: psycopatha

Post on 10-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    1/18

    BizTalk Server 2009 : Building your first BizTalk Server solution

    Microsoft Virtual Labs

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    2/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Table of Contents

    BizTalk Server 2009: Building your first BizTalk Server solution .......................................... 1 Exercise 1 Creating a Schema ......... ........... .......... ........... .......... ........... .......... ........... ........... .......... ........... .......... .......... 2

    Exercise 2 Creating a map and pipeline ......................................................................................................................... 4 Exercise 3 Creating an orchestration .......... .......... ........... .......... ........... .......... ........... ........... .......... ........... .......... .......... 7 Exercise 4 Deploying your solution............................................................................................................................. 11 Exercise 5 Configuring messaging ports ..................................................................................................................... 13

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    3/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 1 of 16

    BizTalk Server 2009: Building your firstBizTalk Server solution

    Objectives After completing this lab, you will be able to: Create a BizTalk project in Visual Studio 2008 Configure a BizTalk project for deployment Deploy a BizTalk solution and configure it Create ports to receive and send messages

    ScenarioYou work for Contoso Winery and you are about to begin development on aproject utilizing BizTalk Server 2009. In order to get familiar with thedevelopment tasks involved, you will build a simple solution, deploy it and sendmessages through the system.

    Estimated Time toComplete This Lab 30 Minutes

    Computers used in thisLab BTSHOLs

    The password for the Administrator account on all computers in this lab is:pass@word1

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    4/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 2 of 16

    Exercise 1Creating a Schema

    ScenarioIn this exercise, you will be creating a BizTalk project in Visual Studio for purposes of deploying theartifacts youll need for processing messages. You will also create a schema to represent messages arrivinginto your system.

    Tasks Detailed Steps

    Complete the followingtasks on:

    BTSHOLs

    1. Creating the BizTalkProject and addingan existing schema.

    a. Open Visual Studio 2008from Start -> All Programs -> Microsoft VisualStudio 2008.

    b. Choose File | New Project from the menu.c. In the new project dialog box, choose the Empty BizTalk Project template and

    enter ContosoMessaging for the project name.

    d. Ensure the path for the solution is C:\MSLabs\BizTalk Server 2009\CoreLabs\Lab 1\Start

    e. After the project is created, right-click the ContosoMessaging project andchoose Add | Existing Item .

    f. Browse to the C:\MSLabs\BizTalk Server 2009\Core Labs\Lab 1\Startfolder and select the CustomerOrderFlatFile.xsd schema file.

    Note: The schema you have added describes a flat-file message, in this case a message

    with comma-delimited values. Open the schema and take note of how the message isdescribed using the Xml Schema Definition (XSD) language with additional attributesto describe the flat-file formatting. BizTalk uses this information to translate between

    XML and the flat file format.

    2. Creating a newschema

    a. Right-click the ContosoMessaging project in Solution Explorer and choose Add| New Item .

    b. Select the Schema item template and enter Order.xsd for the name. Note : The schema will open in the BizTalk Schema editor which is the tool you useto work with the schemas that define the structure of your messages.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    5/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 3 of 16

    Tasks Detailed Steps

    c. In the treeview, right-click the node labeled Root and rename it toCustomerOrder.

    d. Right-click the CustomerOrder node and choose Insert Schema Node | Child

    Record . Name the new record CustomerInfo .e. Right-click the CustomerInfo node and select Insert Schema Node | Child

    Field Element . Name the new element FirstName .f. Repeat the previous step to create two other elements named LastName and

    Phone .g. Right-click the CustomerOrder node one more time and choose Insert

    Schema Node | Child Record. Name the record OrderDetails.

    h. Right-click the Order.xsd file in the solution explorer and choose GenerateInstance .

    i. In the output window, hold down the CTRL key and click the link to thegenerated file to see what an instance of this message looks like.

    Note: You have created a schema to define the structure of an order message from acustomer. In this simple example the order details have been left out to save time.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    6/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 4 of 16

    Exercise 2Creating a map and pipeline

    ScenarioIn this part of the exercise, you will be creating two components that help in processing messages. First you willcreate a map which enables you to define transformations of messages from one format or schema into a messagethat follows a different schema. Then you will define a pipeline that provides staged processing for messagesentering or exiting BizTalk Server. Your pipeline will define processing steps to serialize an XML message to itsflat-file format and your map will transform a message between the two schemas you worked with in the previousexercise.

    Tasks Detailed Steps

    Complete the followingtasks on:

    BTSHOLs

    1. Creating the Map

    a. In Visual Studio, right-click the ContosoMessaging project in the SolutionExplorer and choose Add | New Item .

    b. Select the Map template and name the file MapOrderToCustomer.btm .c. After the map is added, click the link to choose the source schema.d. In the type picker dialog, expand the Schemas node and select the

    ContosoMessage.Order schema.

    e. Now click the link in the right pane to select the destination schema and select theContosoMessaging.CustomerOrderFlatFile schema in the type picker.

    Note: You have selected the two schemas you will be mapping. The map providesinstructions for how the runtime transformation of messages should be done, when thetype of the incoming message matches the source schema in the map.

    f. Expand the nodes in the source schema until you can see the nodes under theCustomerInfo record.

    g. Click on the Phone node and drag it to the ContactNo node on the destinationschema. There should a line connecting to the two when you release the mousebutton.

    Note: This is an example of a simple mapping where data is simply copied.

    h. In the toolbox, find the String Functoids group and expand it if it is not alreadyvisible. Drag the String Concatenate functoid onto the grid between the source

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    7/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 5 of 16

    Tasks Detailed Steps

    and destination schemas.

    Note: Functoids provide additional transformation capabilities beyond simple copyingof data. Look in the toolbox and you will find many different categories of functoids

    for different transformation tasks.

    i. Drag the FirstName and then LastName elements from the source schema to theString Concatenate functoid on the grid.

    j. Now click on the String Concatenate functoid on the grid and drag to connect it tothe FullName element in the destination schema.

    k. Double-click the functoid on the grid and click the button to add a new constantvalue adding a single space as the value (to add space between the first and lastnames).

    l. Click OK and save your work. The completed map should look similar to theimage below.

    2. Creating a sendpipeline

    Note: Pipelines define message processing that happens as messages enter or leave BizTalk. They are commonly used to handle manipulation of files such asdeserialization into XML, encryption or encoding of messages, and customcomponents to manipulate messages.

    a. Right-click the ContosoMessaging project and choose Add | New Item .b. Select the Send Pipeline template and name the item FlatFileSendPipeline.btp c. In the designer, drag a Flat file assembler and drop it in the Assemble stage

    where indicated.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    8/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 6 of 16

    Tasks Detailed Steps

    d. Note in the properties grid that there are various settings for the component thatyou can modify. For this lab you will leave all settings at their default values.

    Note: Now you have a pipeline that can serialize an xml message into the correct Flat File format using the information found in a schema. In a later exercise youwill use this pipeline to do just that.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    9/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 7 of 16

    Exercise 3Creating an orchestration

    ScenarioIn this exercise, you will be creating an orchestration to define a business process around your messages.Orchestrations are meant to coordinate, or orchestrate, message exchanges, primarily for longer runningprocesses. This example will create a very simple orchestration to receive and send a message. You would notnormally use an orchestration for this purpose; it is used here simply to help you understand how all of the piecesfit together.

    Tasks Detailed Steps

    Complete the followingtasks on:

    BTSHOLs

    1. Defining theorchestrationmessages

    Note: Orchestrations primarily manage message interactions. The first step is tocreate some message variable that represent the messages you will be processing inthe orchestration.a. Right-click the ContosoMessaging project in Solution Explorer and choose Add |

    New Item .b. Select BizTalk Orchestration and name the file OrderProcessing.odx c. After the orchestration designer appears, make sure the Toolbox and the

    Orchestration View windows are visible. You can make them visible by selectingthem from the View menu.

    d. In the Orchestration View tool window, right click the Messages node and selectNew Message .

    e. Once the new message appears (named Message_1), ensure it is selected and thenchange the Identifier property in the property grid to OrderMessage .

    f. In the property grid, expand the Message Type values to select Schemas |ContosoMessaging.Order .

    g. Repeat steps d-f to create another message with the identifier of CustomerMessage and the message type of ContosoMessaging.CustomerOrderFlatFile .

    2. Define themessagingactivities.

    Note: In the orchestration you will need activities or shapes that model the receipt and

    sending of messages. You will also need shapes to create message that are not received.

    a. From the toolbox, drag a Receive shape onto the design surface and drop it nearthe top.

    b. Follow this with a transform shape and then a send shape so that youorchestration looks like the following image.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    10/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 8 of 16

    Tasks Detailed Steps

    c. Select the Receive_1 shape and set the Activate property to True .d. Select the OrderMessage you created in the previous step for the Message

    property on the Receive_1 shape.

    Note: In the last two steps, you have told BizTalk that you expect to receive an order message and that it should activate, or start a new instance of this orchestrationwhen that messages arrives. When the orchestration is started, the OrderMessagevariable will hold a reference to the received message.

    e. Select the Send_1 shape and set the Message property to CustomerMessage .

    Note: In order to send the CustomerMessage you first have to create it. In the following steps you will use the map created in an earlier exercise to create the

    CustomerMessage by transforming the OrderMessage.f. Select the Transform_1 shape and click the ellipses to edit the MapName

    property.g. When the Transform Configuration dialog appears, select the Radio Button next

    to Existing Map .h. From the drop down, choose the MapOrderToCustomer map you created

    earlier.i. Highlight Source in the Transform tree on the left and select the OrderMessage

    under the Variable Name column. j. Highlight Destination in the Transform tree on the left and select the

    CustomerMessage under the Variable Name column.k. Click OK to close the transform configuration.

    3. Defining theorchestration ports

    Note: Ports allow you to define logical entry and exit points into the business process. In a later step you will bind these logical ports to physical ports.

    a. Drag a port from the toolbox and drop it on the leftmost area of the designerlabeled Port Surface .

    b. When the wizard appears, click Next .c. Enter OrderPort for the Name and click Next .d. In the Select a Port Type wizard page, enter OrderPortType for the Port type

    name and leave the other values at their defaults.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    11/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 9 of 16

    Tasks Detailed Steps

    e. On the Port Binding page, leave the defaults to indicate you will be receivingmessages through this port and will specify the binding information later.

    f. Finish the wizard.g. Drag another port to the rightmost area of the designer and drop it under the label

    Port Surface.h. Complete the wizard as before, with the following values.

    Wizard Page Property Value

    Port Properties Name CustomerPort

    Select a port type Port Type Name CustomerPortType

    Port binding Port direction of communication

    Ill always besending message onthis port.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    12/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 10 of 16

    Tasks Detailed Steps

    i. Now that the ports are defined, drag the green connector from the OrderPort anddrop it on the green connector on the Receive_1 shape.

    j. Drag the connector from the CustomerPort and drop it on the connector for theSend_1 shape.

    k. Build the solution to ensure that all steps have been completed correctly.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    13/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 11 of 16

    Exercise 4Deploying your solution

    ScenarioIn this exercise, you will be configuring and then deploying your solution into BizTalk Server so it can bemanaged and started.

    Tasks Detailed Steps

    Complete the followingtasks on:

    BTSHOLs

    1. Configuring thesolution fordeployment

    a. Right-click the ContosoMessaging project in Solution Explorer and chooseProperties .

    b. In the properties page, select the Signing tab.c. Click the box next to Sign the assembly and then choose New from the drop

    down to choose a strong name key file.d. When prompted, name the key file key.snk and indicate that you do not want to

    use a password to protect the file.

    e. Now click the Deployment tab on the properties page.f. Enter Lab1 for the Application Name g. Change the Server property to . (period without the quotes)

    h. Save all files.

    2. Deploy the solution a. Right-click the ContosoMessaging Solution in Solution Explorer and chooseDeploy Solution .

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    14/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 12 of 16

    Tasks Detailed Steps

    b. Make sure the Output window is visible and monitor the progress of thedeployment. When the deployment is completed, the status bar in Visual Studioshould read Deploy succeeded .

    Note: At this point you should be able to navigate to c:\windows\assembly and find theContosoMessaging assembly deployed into the Global Assembly Cache (GAC) where

    BizTalk can find it. Additionally, metadata about your assembly and the components

    within it, has been deployed to the BizTalk management database.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    15/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 13 of 16

    Exercise 5Configuring messaging ports

    ScenarioIn this exercise, you will be creating the physical receive and send ports that define the actual entry and exitpoints for BizTalk Server. You will enable messages to be received by BizTalk Server from a file folder and tobe sent to another folder after your message has been processed. The end solution is that the XML file should bepicked up by BizTalk, processed by your orchestration and transformed to the flat-file structure, and sent out to adifferent folder, being serialized to its flat-file representation along the way.

    Tasks Detailed Steps

    Complete the followingtasks on:

    BTSHOLs

    1. Create a receiveport and receivelocation

    a. Open the BizTalk Server 2009 Administration Console from Start -> AllPrograms -> Microsoft BizTalk Server 2009 -> BizTalk ServerAdministration.

    b. In the BizTalk Server 2009 Administration Console, find the Applications

    node and expand it to find the Lab1 node representing your application.c. Expand Lab1 and notice the various artifacts that make up your application. You

    can navigate to the Maps and Pipelines nodes to see several of the componentsyou have built and deployed.

    d. Right-click the Receive Ports node and choose New | One-way receive port. e. In the dialog box that appears, enter OrderReceivePort as the name and click

    OK.

    Note: A receive port is a logical entry point into BizTalk server and contains one or more receive locations. This logical entry point allows for several different physicalentry points that all appear as one logical entry point. Some settings can be applied at the port level to impact all messages entering through the port.

    f. Highlight the Receive Ports node, then right-click on the OrderReceivePort and

    choose New | Receive Location .g. For the name, enter CustomerOrder_FILE.h. In the Type dropdown for transport, choose FILE .i. For the Receive Pipeline , choose XmlReceive .

    Note: A receive location consists of the adapter and the pipeline. The adapter handlesreceiving the data and converting it to a BizTalk message, while the pipeline then pre-

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    16/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 14 of 16

    Tasks Detailed Steps

    processes the message to prepare it for routing and processing.

    j. Click on the Configure button to change settings for the File adapter.k. For the Receive folder, enter this path: C:\MSLabs\BizTalk Server 2009\Core

    Labs\Work\Lab 1\Messaging\Receive\

    Note: Notice that the adapter dialog has settings specific to the File adapter. Eachadapter has different settings that make sense for how the adapter processesmessages.

    l. Click OK on the dialogs until you are returned to the administrative console.

    2. Creating a sendport

    Note: A Send Port models a physical exit point for BizTalk server and consists of anadapter, pipeline and optionally maps. Send ports are used to send messages to other systems and partners.

    a. In the BizTalk Server 2009 Administration Console, find the Lab1 Application.b. Right-click the Send Ports node and choose New | Static One-way send port .c. For the name , enter CustomerSendPort .d. Choose FILE for the transport type .e. Select the FlatFileSendPipeline for the Send pipeline .

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    17/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 15 of 16

    Tasks Detailed Steps

    Note: The pipeline being used is the one you created earlier and will serialize thecustomer message into its flat-file format.

    f. Click the Configure button to change the output path for the File adapter.g. Enter C:\MSLabs\BizTalk Server 2009\Core Labs\Work\Lab

    1\Messaging\Send\ for the destination folder.h. Change the extension in the File Name field to .txt.i. Click OK on the dialogs to return to the administration console.

    3. Bind theorchestration portsto the physicalports.

    Note: In the orchestration, there are logical ports representing message exchanges. In the previous steps you created physical ports with adapters, pipelines and addresses. Now you need to bind those two together to provide concreteimplementations that the orchestration can use.

    a. Right-click the Lab1 application in the BizTalk Server Administration Console

    and choose Configure .b. In the Configure Application dialog, select the OrderProcessing orchestration.c. Use the drop downs to set the values for the Host, Inbound and Outbound ports.

    There should only be one option for each, but the mappings are shown below.

  • 8/8/2019 BizTalk2009BuildingYourFirstBizalkSolution

    18/18

    BizTalk Server 2009: Building your first BizTalk Server Solution

    Page 16 of 16

    Tasks Detailed Steps

    d.

    Click OK to close the dialog.e. Right-click the Lab1 application and choose Start .f. When prompted, click Start again.

    4. Test theapplication.

    a. In Windows Explorer, navigate to c:\MsLabs\BizTalk Server 2009\CoreLabs\Work\Lab 1 \Messaging\.

    b. Open the CustomerOrder.xml file to view the contents. This file matches theschema you created in the first exercise.

    c. Close the file, then COPY and paste the file into the Receive folder. BizTalk isnow monitoring this folder and will pick up your file.

    d. Open the Send folder and watch for your message to appear. You should see atext file with a GUID for a name get written to the folder. Open the file inNotepad and examine the contents of the comma-delimited flat-file.

    Note: It may take a minute for BizTalk to pick up your file and process it for the first time.

    5. Delete theapplication

    a. When you are done testing the application, open the BizTalk ServerAdministration console.

    b. Right-click the Lab1 application and choose Stop .c. In the dialog, select Full Stop and click the Stop button.d. Once the application has stopped, right-click the application and choose Delete .