Editar

Compartilhar via


AS2 over File (BizTalk Server Sample)

The AS2 Over File sample demonstrates how to receive an AS2 message over a FILE receive location. This enables you to use a FILE adapter to receive the AS2 message, rather than an HTTP adapter, which is normally used. To do so, this solution writes the HTTP headers in the AS2 message to the InboundHTTPHeaders context property, as required by the AS2 Decoder.

What This Sample Does

This sample demonstrates how to process the HTTP headers in an AS2 message without having an HTTP adapter. Specifically, this sample does the following:

  1. When you drop the test message into an input folder, the FILE receive location picks it up.

  2. The custom pipeline component in the custom AS2 receive pipeline processes the message, writing its HTTP headers to the InboundHTTPHeaders context property.

    Note

    If processing of the message fails downstream of the custom pipeline component, you may have difficulty resuming the processing of the message because it will have already been converted to XML encoding.

  3. The AS2 Decoder in the custom receive pipeline processes the message, reading the properties in the InboundHTTPHeaders context property to do its processing.

  4. A send port subscribes to the XML message generated by the receive pipeline, passes it through a passthrough send pipeline, and drops it into an output folder.

Where to Find This Sample

This sample is located in the BizTalk Server installation folder: \Program Files (x86)\Microsoft BizTalk Server <VERSION>SDK\Samples\AS2\AS2 Over File.

The following table shows the files in this sample and describes their purpose.

File(s) Description
AS2OverFile.csproj The project containing the custom pipeline component code.
AS2OverFile.sln The solution containing the AS2OverFile.btproj project.
Program.cs Includes classes representing headers data.
SampleMessage.txt The sample message containing HTTP headers.

Implementing and Running This Sample

To implement the AS2 Over File sample, you need to do the following:

  • Build and deploy the BizTalk project for this sample, creating the custom pipeline component

  • Create a custom pipeline using the custom pipeline component, and build and deploy a project with that custom pipeline

  • Create input and output file folders

  • Configure a receive port and location, and enable the receive location

  • Configure a send port and start the send port

  • Create a party for sending the sample message

To build a custom pipeline with the AS2 Over File Emulator Pipeline Component

  1. In Visual Studio, open the AS2OverFile project in the \Program Files (x86)\Microsoft BizTalk Server <VERSION>SDK\Samples\AS2\AS2 Over File folder.

  2. Create a strong name key file, open the Properties dialog box for the AS2OverFile project, and assign the key file to the project.

  3. Build the project.

  4. In Visual Studio, create a new BizTalk Project named AS2OverFile_Pipeline.

  5. Right-click the AS2OverFile_Pipeline project, point to Add, and then click New Item.

  6. In the Add New Item dialog box, select Pipeline Files in the left-hand pane, select Receive Pipeline in the right-hand pane, name the pipeline AS2OverFile_Receive.btp, and then click Add.

  7. Click View in the menu bar, and then click Toolbox to display the Toolbox.

  8. In the Toolbox, right-click BizTalk Pipeline Components, and then click Choose Items.

  9. In the Choose Toolbox Items dialog box, click the BizTalk Pipeline Components tab. Click AS2 Over File Emulator, and then click OK.

  10. Add the AS2OverFile.dll file to the global assembly cache by opening a Visual Studio Command Prompt, and executing the command gacutil /if "<file name and path>" on the Microsoft.BizTalk.Sdk.Components.AS2OverFile.dll in the \AS2 Over File\obj\Debug folder.

  11. In Visual Studio, drag the AS2 Over File Emulator pipeline component from the Toolbox into the Decode stage of the custom pipeline.

  12. Drag the AS2 decoder component into the Decode stage of the custom pipeline, after the AS2 Over File component.

    Note

    If you want to generate an MDN, add an AS2 disassembler into the Disassemble stage of the custom pipeline. If you are not returning an MDN, the AS2 disassembler is not required.

  13. Create a strong name key file, open the Properties dialog box for the AS2OverFile_Pipeline project, and assign the key file to the project.

  14. Build and deploy the custom pipeline.

  15. In the BizTalk Server Administration Console, add the custom pipeline to the Pipelines node by clicking the Pipelines node, and then clicking Refresh.

To implement the solution for this sample

  1. In Windows Explorer, in the \Program Files (x86)\Microsoft BizTalk Server <VERSION>SDK\Samples\AS2\AS2 Over File folder, create an In input folder and an Out output folder.

  2. In the BizTalk Server Administration Console, create a one-way receive port named AS2OverFile_Receive. In the receive port, create a receive location with the following properties:

    Property Setting
    Name AS2OverFile_Receive
    Type FILE
    Receive folder \Program Files (x86)\Microsoft BizTalk Server <VERSION>SDK\Samples\AS2\AS2 Over File/In
    File mask *.txt
    Receive pipeline AS2OverFile
  3. In the Receive Locations node, right-click the AS2OverFile_Receive receive location, and then click Enable.

  4. In the Send Ports node, create a Static On-way send port with the following properties:

    Property Setting
    Name AS2OverFile_Send
    Type FILE
    Receive folder \Program Files (x86)\Microsoft BizTalk Server <VERSION>SDK\Samples\AS2\AS2 Over File/Out
    File mask %MessageID%.xml
    Send pipeline Passthru
    Filter BTS.REceivePortName == AS2OverFile_Receive
  5. In the Send Ports node, right-click the AS2OverFile_Send send port, and then click Start.

  6. In the Parties node, create a party named "Partner". To the Aliases list, add an alias with a name of EDIINT-AS2 From Value, a Qualifier of AS2-From, and a Value of Partner.

    BizTalk Server is now ready to work with this sample.

Running This Sample

Use the following procedure to run the AS2 Over File sample.

To run this sample

  1. Copy the SampleMessage.txt file from the \Program Files (x86)\Microsoft BizTalk Server <VERSION>SDK\Samples\AS2\AS2 Over File folder into the \AS2 Over File\In folder.

  2. Verify that an output XML message is dropped into the \AS2 Over File\Out output folder.

  3. Open the input message SampleMessage.txt in a text editor, and open the output message <GUID>.xml in a text editor. Verify that the SampleMessage.txt input message has HTTP (and AS2) headers and that the output message does not have HTTP headers.

Classes or Methods Used in This Sample

None

See Also

EDI and AS2 (BizTalk Server Samples Folder)
Sending an AS2 Message over a FILE Send Port