BizTalk Training 1 – Basic Send/Receive XML Message

This entry is part 1 of 5 in the series BizTalk Training

Basic Send/Receive XML Message

This tutorial shows how to create simple orchestration to send/receive xml messages using FILE Adapter.

There are 5 tutorials in this training.

  1. BizTalk Training 1 – basic send/receive xml message
  2. BizTalk Training 2 – receive/send plain text
  3. BizTalk Training 3 – customize filename dynamically
  4. BizTalk Training 4 – using Functiods in Map
  5. BizTalk Training 5 – using FTP Adapter

Objectives

  • Learn how to create schema from sample xml file.
  • Learn how to send/receive xml message using FILE adapter.
  • Learn how to deploy BizTalk project to BizTalk Administration.

Topics

  1. Add new orchestration.
  2. Create schema.
  3. Create new Message.
  4. Create logical ports.
  5. Deploy the project.
  6. Configure BizTalk Administration.

Step-by-step

Suppose that I want BizTalk to process xml message from folder A (C:\FILE1\IN\*.xml) to folder B (C:\FILE1\OUT\%SourceFileName%). The sample data of xml message is in C:\FILE1\person1.xml.

  <person>
     <name>Mr. A</name>
    <position>Sales Manager</position>
     <salary>10000</salary>
   </person>
  1. Add new orchestration.
    • New BizTalk Project named ‘BizTalkTraining’.
      New BizTalk Project
    • Add New Item.
      Add new Item
    • Select new orchestration to the project named as ‘Orchestration1.odx’.
      Add new Orchestration
    • On Orchestration1, drag Receive Receive component and Send Send component components to the orchestration.
      Orchestration1
  2. Create schema
    • Now I need to create schema for receive and send component. If you don’t have schema file (.xsd file) that corresponds with xml message, you need either to create schema by using wizard to generate from xml message or create by yourself. By using wizard, it’s fast but it doesn’t work well if your xml message is too complex.
    • Solution 1: using BizTalk Schema Generator
      1. To use this wizard, you need to enable it before use once by execute VBScript file that is in BizTalk SDK Utilities directory. If you installed BizTalk on default directory, the files should be in C:\Program Files\Microsoft BizTalk Server 2006\SDK\Utilities\Schema Generator\. If your document type is DTD, execute InstallDTD.vbs. If your document type is standard XML (Well-formed XML), execute InstallWFX.vbs. Or you can execute both files.
        Install the scripts
      2. Back to the orchestration, in solution explorer. Select Add Generated Items.
        Add generated item
      3. Select Generate Schemas on left side and select Generate Schemas on right side. Click Add.
        Select generate schemas
      4. On document type, select Well-Formed XML and select input file from sample xml message. Click OK.
        Select Well-Formed XML
      5. Wait for a while and you will see your schema has been created.
        The created schema
      6. You’ll need to clear target namespace because the sample file doesn’t have any target namespace by click on “Schema” and clear Target Namespace in Properties.
        Clear target namespace
    • Solution 2: create the schema manually
      1. In solution explorer, select Add New Items.
        Add new Item
      2. Select Schema Files on left side and select Schema on right side. Also, named the schema as person1.xsd. Click Add.
        Create a new empty schema
      3. Now you’ll see empty schema file. You can add new element by right click on root node -> select Insert Schema Node -> Child Field Element.
        Insert a new element
      4. Try to create element as the same in sample xml message. Also, you can change data type in properties window.
        Change type of the element
      5. You’ll need to clear target namespace because the sample file doesn’t have any target namespace by click on “Schema” and clear Target Namespace in Properties.
        Clear target namespace
      6. Change name of the root to Person and now you’ll get the schema for incoming message.
        Change root name
  3. Create new Message
    • On orchestration1, move to Orchestration View. Right click on Messages and select New Message.
      Change root name
    • Highlight on Message_1, change Identifier to msgPerson and select Message Type as schema that you’ve created in 5). (Schema -> BizTalkTraining.person1)
      Change message type
    • Change Message on receive and send components in the orchestration1 to msgPerson.
      Change message type on send and receive components
  4. Create logical ports
    • You have configured to receive msgPerson and send out msgPerson. Next you need to create logical ports to receive and send these messages from/to.
    • Create receive port.
      1. Right click on Port Surface area (red rectangular) and select New Configured Port.
        New Configured port
      2. Click Next. Named the port as RecvPersonPort. Click Next.
        Port Properties
      3. Configure Port Type.
        Name Port Type Name as ‘RecvPersonPortType’. Leave Create a new Port Type, Communication Pattern as One-Way and Access Restrictions as Internal selected. Click Next.
        Select a port type
      4. Configure Port Binding.
        • Ensure that “I’ll always be receiving messages on this port.” is selected.
        • Select Port binding as “Specify now”.
        • Select Transport as “FILE”.
        • Type URI: as path with file mask that you want to receive. In this sample, it is “C:\FILE1\IN\*.xml”. That means to read any .xml file in C:\FILE1\IN.
        • Select Receive pipeline as XMLReceive.
        • Click Next and Finish.

        Configure Port Binding

    • Create send port.
      1. Right click on Port Surface area (red rectangular) and select New Configured Port.
      2. Click Next. Named the port as SendPersonPort. Click Next.
        Port Properties
      3. Configure Port Type.
        Name Port Type Name as ‘SendPersonPortType’. Leave Create a new Port Type, Communication Pattern as One-Way and Access Restrictions as Internal selected. Click Next.
        Select a port type
      4. Configure Port Binding.
        • Ensure that “I’ll always be sending messages on this port.” is selected.
        • Select Port binding as “Specify now”.
        • Select Transport as “FILE”.
        • Type URI: as path to destination file that you want to send. In this sample, it is “C:\FILE1\OUT\%SourceFileName%”.
          Note: %SourceFileName% is the mask that means using file name as it was receive.
        • Select Send pipeline as XMLTransmit.
        • Click Next and Finish.

        Configure Port Binding

    • Now you have configured logical ports to map with physical paths. Next is to connect logical ports to receive and send components that you have created previously. Drag green button on RecvPersonPort (1) to green button on Receive_1 component (2). Also, repeat this on send port.
      Connect receive and send ports
  5. Deploy the project
    • Click on Receive_1 component and change Activate to “True” in the properties.
      Set Activate to 'True'
    • We have finished on the orchestration. Next, we are going to deploy the project on BizTalk Administration. On the solution explorer, right click on Solution ‘BizTalkTraining’ and select Properties.
      Open Solution Property page
    • On Solution Property Pages
      1. Select Configuration in Configuration Properties.
      2. Change Configuration to Deployment.
      3. Ensure that Deploy has been checked.
      4. Click OK.

      Set to deployment

    • Next create strong name key and assign to the project
      1. Open Visual Studio 2005 Command Prompt by select on Programs.
        Open Visual Studio 2005 Command Prompt
      2. Type in the command prompt ‘sn -k c:\FILE1\BizTalkTraining.snk’. Then the key will be created in c:\FILE1.
        Create a strong name key file
      3. Back to the BizTalkTraining project, right click on BizTalkTraining and select Properties.
        Open project's Properties
      4. On Property Pages
        • Select Assembly in Common Properties.
        • Find Assembly Key File. Click … to browse.
        • Select file that you have just created “BizTalkTraining.snk”.
        • Click Open and OK.
          Assign the strong name key to the project
        • To change name of the application when deployed, select Deployment in Configuration Properties.
        • On Application Name, change to “BizTalkTraining”.
        • Click OK.
          Change application name when deployed to BizTalk host
    • Now you’re ready to deploy the project to BizTalk Administration. Right click on Solution ‘BizTalkTraining’ and select Deploy Solution.
      Deploy the project
    • You’ll see in output window if the deploy was succeeded.
      Deploy succeeded
  6. Configure BizTalk Administration
    • Open BizTalk Administration; expand BizTalk Server 2006 Administration -> BizTalk Group -> Applications. You’ll see BizTalk Training was deployed to here. Right click on BizTalkTraining and click configure.
      Open Configure Application window
    • On Configure Application window, select Host to BizTalkServerApplication. Click OK.
      Configure host for the application
    • Now you can start your application, but you need to create folder as you have already configured in Visual Studio. For receive folder, C:\FILE1\IN. For send folder, C:\FILE1\OUT.
    • Right click BizTalkTraining again; click start to start BizTalk application.
      Start the application
    • Click Start again.
      Start the application
    • Now BizTalkTraining application is running, you can test your application by copy person1.xml (sample xml file) to receive folder (C:\FILE1\IN). If the application is configured correctly, the file will be moved to send folder (C:\FILE1\OUT) with the same name as in receive folder.
    • Result in C:\FILE1\OUT\Person1.xml.
      Result window

Resources

You can download the example source code (zip file) at here.
The zip file contains

  • BizTalkTraining folder which is the example project on Visual Studio 2005.
  • FILE1 folder which contains IN and OUT empty sub folders for test receive and send message, BizTalkTraining.snk which is a strong name key file used in the example project and person1.xml which is an example xml message.
  • binding.xml file which is a configuration file for import in BizTalk Administration.
Series NavigationBizTalk Training 2 – Receive/Send Plain Text >>

22 Comments

  1. Arik December 7, 2008
  2. Lingesh May 2, 2009
  3. Sudha Rajkumar October 14, 2009
  4. linglom October 15, 2009
  5. Sudha Rajkumar October 19, 2009
  6. Smitha March 11, 2010
  7. linglom March 12, 2010
  8. kotireddy April 23, 2010
  9. linglom April 25, 2010
  10. Priya October 5, 2010
  11. linglom October 11, 2010
  12. Shadab Hasan December 27, 2010
  13. Jost February 25, 2011
  14. Nellapodiadag June 12, 2011
  15. AldenJanrhett July 27, 2011
  16. Solai September 1, 2011
  17. EricFI November 18, 2011
  18. tony bonn June 22, 2012
  19. Vimal Bhavsar September 20, 2012
  20. p November 5, 2012
  21. divya May 8, 2013
  22. baalu June 17, 2017

Leave a Reply