biztalk training 1

Upload: magunta

Post on 05-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 BizTalk Training 1

    1/47

    Page 1 of47

    BizTalk Training 1 basic send/receive xml message

    BizTalk, Programming, Windows October 30th, 2007

    Overview

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

    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.

    Mr. A

    Sales Manager

    10000

    1. Add new orchestration.

    http://www.linglom.com/2007/10/30/biztalk-training-1-basic-sendreceive-xml-message/http://www.linglom.com/2007/10/30/biztalk-training-1-basic-sendreceive-xml-message/http://www.linglom.com/2007/10/30/biztalk-training-1-basic-sendreceive-xml-message/http://www.linglom.com/category/windows/biztalk/http://www.linglom.com/category/programming/http://www.linglom.com/category/windows/http://www.linglom.com/category/windows/http://www.linglom.com/category/programming/http://www.linglom.com/category/windows/biztalk/http://www.linglom.com/2007/10/30/biztalk-training-1-basic-sendreceive-xml-message/
  • 8/2/2019 BizTalk Training 1

    2/47

    Page 2 of47

    o New BizTalk Project named BizTalkTraining.

    o Add New Item.

  • 8/2/2019 BizTalk Training 1

    3/47

    Page 3 of47

    o Select new orchestration to the project named as Orchestration1.odx.

    o On Orchestration1, drag Receive and Sendcomponents to the orchestration.

    2. Create schemao Now I need to create schema for receive and send component. If you dont 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, its fast but it

    doesnt work well if your xml message is too complex.

    o Solution 1: using BizTalk Schema Generator

    http://www.linglom.com/images/training/BizTalk/1/6.pnghttp://www.linglom.com/images/training/BizTalk/1/6.pnghttp://www.linglom.com/images/training/BizTalk/1/6.pnghttp://www.linglom.com/images/training/BizTalk/1/6.png
  • 8/2/2019 BizTalk Training 1

    4/47

    Page 4 of47

    3. To use this wizard, you need to enable it before use once by execute VBScript file that is inBizTalk 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.

    4. Back to the orchestration, in solution explorer. Select Add Generated Items.

    http://www.linglom.com/images/training/BizTalk/1/7.pnghttp://www.linglom.com/images/training/BizTalk/1/7.png
  • 8/2/2019 BizTalk Training 1

    5/47

    Page 5 of47

    5. Select Generate Schemas on left side and select Generate Schemas on right side. ClickAdd.

    6. On document type, select Well-Formed XML and select input file from sample xmlmessage. Click OK.

  • 8/2/2019 BizTalk Training 1

    6/47

    Page 6 of47

    7. Wait for a while and you will see your schema has been created.

    8.

    Youll need to clear target namespace because the sample file doesnt have any targetnamespace by click on Schema and clear Target Namespace in Properties.

    o Solution 2: create the schema manually

  • 8/2/2019 BizTalk Training 1

    7/47

    Page 7 of47

    1. In solution explorer, select Add New Items.

    9. Select Schema Files on left side and select Schema on right side. Also, named the schemaas person1.xsd. Click Add.

  • 8/2/2019 BizTalk Training 1

    8/47

    Page 8 of47

    1. Now youll see empty schema file. You can add new element by right clickon root node -> select Insert Schema Node -> Child Field Element.

    http://www.linglom.com/images/training/BizTalk/1/14.png
  • 8/2/2019 BizTalk Training 1

    9/47

    Page 9 of47

    10. Try to create element as the same in sample xml message. Also, you can change data typein properties window.

    1. Youll need to clear target namespace because the sample file doesnt have any targetnamespace by click on Schema and clear Target Namespace in Properties.

  • 8/2/2019 BizTalk Training 1

    10/47

    Page 10 of47

    2.Change name of the root to Person and now youll get the schema for incoming message.

    11.Create new Messageo On orchestration1, move to Orchestration View. Right click on Messages and select New

    Message.

  • 8/2/2019 BizTalk Training 1

    11/47

    Page 11 of47

    o Highlight on Message_1, change Identifier to msgPerson and select Message Type as schemathat youve created in 5). (Schema -> BizTalkTraining.person1)

  • 8/2/2019 BizTalk Training 1

    12/47

    Page 12 of47

    o Change Message on receive and send components in the orchestration1 to msgPerson.

    12.Create logical portso 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.

    o Create receive port.1. Right click on Port Surface area (red rectangular) and select New Configured Port.

    http://www.linglom.com/images/training/BizTalk/1/20.pnghttp://www.linglom.com/images/training/BizTalk/1/20.png
  • 8/2/2019 BizTalk Training 1

    13/47

    Page 13 of47

    2. Click Next. Named the port as RecvPersonPort. Click Next.

    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

    http://www.linglom.com/images/training/BizTalk/1/21.png
  • 8/2/2019 BizTalk Training 1

    14/47

    Page 14 of47

    Next.

    4. Configure Port Binding. Ensure that Ill 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.

    http://www.linglom.com/images/training/BizTalk/1/22.png
  • 8/2/2019 BizTalk Training 1

    15/47

    Page 15 of47

    o Create send port.

  • 8/2/2019 BizTalk Training 1

    16/47

    Page 16 of47

    1. Right click on Port Surface area (red rectangular) and select NewConfigured Port.

    2. Click Next. Named the port as SendPersonPort. Click Next.

    http://www.linglom.com/images/training/BizTalk/1/25.pnghttp://www.linglom.com/images/training/BizTalk/1/25.png
  • 8/2/2019 BizTalk Training 1

    17/47

    Page 17 of47

    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.

    4. Configure Port Binding. Ensure that Ill always besending 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.

    http://www.linglom.com/images/training/BizTalk/1/26.png
  • 8/2/2019 BizTalk Training 1

    18/47

    Page 18 of47

    o Now you have configured logical ports to map with physical paths. Next is to connect logicalports 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.

    13.Deploy the project

    http://www.linglom.com/images/training/BizTalk/1/28.pnghttp://www.linglom.com/images/training/BizTalk/1/27.pnghttp://www.linglom.com/images/training/BizTalk/1/28.pnghttp://www.linglom.com/images/training/BizTalk/1/27.png
  • 8/2/2019 BizTalk Training 1

    19/47

    Page 19 of47

    o Click on Receive_1 component and change Activate to True in the properties.

    o We have finished on the orchestration. Next, we are going to deploy the project on BizTalkAdministration. On the solution explorer, right click on Solution BizTalkTraining and select

    Properties.

    o On Solution Property Pages1. Select Configuration in Configuration Properties.2. Change Configuration to Deployment.3. Ensure that Deploy has been checked.4. Click OK.

  • 8/2/2019 BizTalk Training 1

    20/47

    Page 20 of47

    o Next create strong name key and assign to the project1. Open Visual Studio 2005 Command Prompt by select on Programs.

  • 8/2/2019 BizTalk Training 1

    21/47

    Page 21 of47

    2. Type in the command prompt sn -k c:\FILE1\BizTalkTraining.snk. Then the key will becreated in c:\FILE1.

    3. Back to the BizTalkTraining project, right click on BizTalkTraining and select 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.

    http://www.linglom.com/images/training/BizTalk/1/33.pnghttp://www.linglom.com/images/training/BizTalk/1/33.png
  • 8/2/2019 BizTalk Training 1

    22/47

    Page 22 of47

    Click Open and OK.

    To change name of the application when deployed, select Deployment inConfiguration Properties.

    On Application Name, change to BizTalkTraining.

  • 8/2/2019 BizTalk Training 1

    23/47

    Page 23 of47

    Click OK.

    o Now youre ready to deploy the project to BizTalk Administration. Right click on SolutionBizTalkTraining and select Deploy Solution.

  • 8/2/2019 BizTalk Training 1

    24/47

    Page 24 of47

    o Youll see in output window if the deploy was succeeded.

    14.Configure BizTalk Administrationo Open BizTalk Administration; expand BizTalk Server 2006 Administration -> BizTalk Group ->

    Applications. Youll see BizTalk Training was deployed to here. Right click on BizTalkTraining

    and click configure.

  • 8/2/2019 BizTalk Training 1

    25/47

    Page 25 of47

    o On Configure Application window, select Host to BizTalkServerApplication. Click OK.

    o Now you can start your application, but you need to create folder as you have alreadyconfigured in Visual Studio. For receive folder, C:\FILE1\IN. For send folder, C:\FILE1\OUT.

  • 8/2/2019 BizTalk Training 1

    26/47

    Page 26 of47

    o Right click BizTalkTraining again; click start to start BizTalk application.

    o Click Start again.

    o 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.

  • 8/2/2019 BizTalk Training 1

    27/47

    Page 27 of47

    o Result in C:\FILE1\OUT\Person1.xml.

    Resources

    You can download the example source code (zip file) athere.

    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.BizTalk Training 2 receive/send plain text

    Overview

    This tutorial shows how to receive plain text using FILE Adapter and map to xml message while in

    orchestration and finally send out using FILE Adapter as plain text.

    Objectives

    Learn to create schema using Flat File Schema Wizard. Learn to receive file which is plain text to BizTalk. Learn to send file from BizTalk to plain text.

    Prerequisites

    http://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining1.ziphttp://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining1.ziphttp://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining1.ziphttp://www.linglom.com/2007/11/07/biztalk-training-2-receivesend-plain-text/http://www.linglom.com/2007/11/07/biztalk-training-2-receivesend-plain-text/http://www.linglom.com/2007/11/07/biztalk-training-2-receivesend-plain-text/http://www.linglom.com/2007/11/07/biztalk-training-2-receivesend-plain-text/http://www.linglom.com/2007/11/07/biztalk-training-2-receivesend-plain-text/http://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining1.zip
  • 8/2/2019 BizTalk Training 1

    28/47

    Page 28 of47

    BizTalkTraining 1 project. Configuration on BizTalk Administration for BizTalkTraining application.

    Topics

    1. Create schema from plain text using Flat File Schema Wizard.2. Add receive and send pipeline for receive/send plain text.3. Modify orchestration.4. Deploy the project.

    Step-by-step

    As from training 1, I have sample file which is an xml message. Now what if I want a plain text as

    an input, BizTalk can receive any file format which you can determine the schema in pipeline.

    Suppose, I have the same data as in training 1 but its a plain text instead of xml in

    C:\FILE2\person1.txt.

    1. Create schema from plain text using Flat File Schema Wizard.2. Open existing BizTalkTraining project, Add New Item to the project.

  • 8/2/2019 BizTalk Training 1

    29/47

    Page 29 of47

    3. Select Schema Files -> Flat File Schema Wizard and name the schema asFlatFilePersonSchema.xsd?.

    4. BizTalk Flat File Schema Wizard appears, click Next.

  • 8/2/2019 BizTalk Training 1

    30/47

    Page 30 of47

    5. On Instance file, click Browse and select the sample text file that you want to createschema from. Change Record name to Person and click Next.

  • 8/2/2019 BizTalk Training 1

    31/47

    Page 31 of47

    6. On Select Document Data, leave the data highlight and click Next.

    7. Click Next.

  • 8/2/2019 BizTalk Training 1

    32/47

    Page 32 of47

    8. Ensure that Child delimiter is {CR}{LF} which means split data with new line characters.Click Next.

    9. Change Element Names and Data Types as in figure below.

  • 8/2/2019 BizTalk Training 1

    33/47

    Page 33 of47

    10.Click Finish.

  • 8/2/2019 BizTalk Training 1

    34/47

    Page 34 of47

    11.Now that you have created a schema file from plain text.

    12.Add receive and send pipeline for receive/send plain text.o Add New Receive Pipeline.Right click on the project -> Add New Item -> select Pipeline Files -> Receive Pipeline -> name

  • 8/2/2019 BizTalk Training 1

    35/47

    Page 35 of47

    as ReceivePersonPipeline.btp.

  • 8/2/2019 BizTalk Training 1

    36/47

    Page 36 of47

    o New receive pipeline appears.

  • 8/2/2019 BizTalk Training 1

    37/47

    Page 37 of47

    o Drag Flat File disassembler to Disassemble stage.

    o Click on Flat file disassembler object that youve just dropped.On Properties, change Document schema to BizTalkTraining.FlatFilePersonSchema? which

    is the schema that weve created previously.

    oNow add new Send Pipeline.Right click on the project -> Add New Item -> select Pipeline Files -> Send Pipeline -> name

  • 8/2/2019 BizTalk Training 1

    38/47

    Page 38 of47

    as SendPersonPipeline.btp.

  • 8/2/2019 BizTalk Training 1

    39/47

    Page 39 of47

    oDrag Flat file assembler to Assemble stage.

    o Click on Flat file assembler object that youve just dropped.On Properties, change Document schema to BizTalkTraining.FlatFilePersonSchema?

  • 8/2/2019 BizTalk Training 1

    40/47

    Page 40 of47

    which is the schema that weve created previously.

    o Now youve configured receive pipeline for receive plain text and send pipeline forsend to plain text.

    13.Modify orchestration.o Back to Orchestration1.

    o Change the schema from person1.xsd to FlatFilePersonSchema.xsd on ports andreceive/send components.

  • 8/2/2019 BizTalk Training 1

    41/47

    Page 41 of47

    14.Break the green link between ports and receive/send components by right click on theline and select Delete.

    15.Now orchestration will look similar below.

    16.Change message type for msgPerson.o On orchestration1, switch to Orchestration View.o Select msgPerson.

  • 8/2/2019 BizTalk Training 1

    42/47

    Page 42 of47

    o On Properties, change message type to BizTalkTraining.FlatFilePersonSchema?which is the schema that weve created recently.

    17.Change message type on both ports.18.Click Request on RecvPersonPort. Be sure that you click on Request which inside the port,

    youll notice the highlight only around in Request not entire port.

  • 8/2/2019 BizTalk Training 1

    43/47

    Page 43 of47

    19.On Properties, change message type to BizTalkTraining.FlatFilePersonSchema? which isthe schema that weve created recently.

    o Repeat change message type on SendPersonPort, too.20.Connect ports and receive/send components back.

    o Modify RecvPersonPort. Click on RecvPersonPort and move to Properties window. Change the Receive pipeline to BizTalkTraining.RecvPersonPipeline? which is

    the receive pipeline that weve created.

    http://www.linglom.com/images/training/BizTalk/2/29.pnghttp://www.linglom.com/images/training/BizTalk/2/29.png
  • 8/2/2019 BizTalk Training 1

    44/47

    Page 44 of47

    21.Change the URI (Receive location) to C:\FILE2\IN\*.txt?.

    o Modify SendPersonPort.22.Click on SendPersonPort and move to Properties window.23.Change the Send pipeline to BizTalkTraining.SendPersonPipeline? which is the send

    pipeline that weve created.

    24.Change the URI (Receive location) to C:\FILE2\OUT\%SourceFileName%?.

    o Youve just configured to receive plain text (*.txt) from a folder to send to anotherfolder as plain text.

    25.Deploy the project.

  • 8/2/2019 BizTalk Training 1

    45/47

    Page 45 of47

    o Right click on Solution BizTalkTraining and select Deploy Solution.

    26.The output window will show status of the deployment.

    o If you have deployed this project before (in Training 1), you need to restartBizTalkServerApplication and refresh the application.

    0. Expand BizTalk Server 2006 Administration -> BizTalk Group -> PlatformSettings -> Host Instances.

  • 8/2/2019 BizTalk Training 1

    46/47

    Page 46 of47

    27.Right click on the host which runs BizTalkTraining application (Host type as In-Process) andclick Restart.

    0. Next, refresh the application by right click on BizTalk Training and selectRefresh. Now your application on BizTalk is up-to-date.

    o If you havent deployed this application before, go back to Training 1 for furtherdetail.

  • 8/2/2019 BizTalk Training 1

    47/47

    o Now you can test by drop person1.txt to C:\FILE2\IN and wait for result come outin C:\FILE2\OUT.

    Resources

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

    BizTalkTraining folder which is the example project on Visual Studio 2005. FILE2 folder which contains IN and OUT empty sub folders for test receive and send

    message and person1.txt which is an example text message.

    binding.xml file which is a configuration file for import in BizTalk Administration.

    http://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining2.ziphttp://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining2.ziphttp://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining2.ziphttp://www.linglom.com/downloads/BizTalkTraining/BizTalkTraining2.zip