Export (0) Print
Expand All

ConsumeWebService (BizTalk Server Sample)

The ConsumeWebService sample demonstrates how to invoke a Web service from within a BizTalk orchestration.

This sample performs the following sequence of steps:

  1. The BizTalk orchestration retrieves the XML purchase order (PO) message file from the receive location In folder.

  2. The orchestration passes the XML PO message as a string to the Web service.

  3. The Web service receives the XML PO message string, converts it to a corresponding XML invoice message string, and returns it as a string to the calling orchestration.

  4. The orchestration writes the invoice message to an .xml file in the Out folder.

The primary purpose of this sample is to show you how to consume an external Web service within an orchestration. Before you can consume a Web service, you need to add it as a Web reference in your BizTalk project.

In the middle of the orchestration, a Send shape and a Receive shape are connected to a port named POWebServicePort. This is where the orchestration makes a synchronous Web method call to the external Web service through a request-response port, specifying to send the message first. The logical request-response port is bound with a physical Solicit-Response send port. When calling the external Web service, you must make sure that the Web method name you are calling matches the Operation name on the port, or you will receive a SOAP exception.

The name is case-sensitive.

In this sample, submitPO is the name of the Web method that is being called.

<Samples Path>\Orchestrations\ConsumeWebService\

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

File(s) Description


Used to undeploy assemblies and remove them from the global assembly cache. Removes send and receive ports. Removes Microsoft Internet Information Services (IIS) virtual directories as needed.

ConsumeWebService.btproj, ConsumeWebService.sln

Project and solution files for this sample.


Used for automated setup such as port binding.


Sample input PO message file.

InboundPO.xsd, Invoice.xsd, PropertySchema.xsd

Schemas for the input PO message, the output invoice message, and the default property schema, respectively.


The main BizTalk orchestration that:

  • Retrieves a PO message as input and submits it to the sample Web service for processing.

  • Receives an invoice message from the sample Web service and writes it to a file as output from the sample.


Used to build and initialize this sample.

In the \POWebService folder:

AssemblyInfo.cs, Global.asax, Global.asax.cs, Global.asax.resx, POWebService.csproj, POWebService.csproj.webinfo, POWebService.sln, SubmitPOService.asmx, SubmitPOService.asmx.cs, SubmitPOService.asmx.resx, Web.config

The sample Web service with which the orchestration interacts. It converts the PO messages it receives into corresponding invoice messages that it returns in a synchronous manner.

In the \Web References\localhost folder:

Reference.map, Reference.odx, SubmitPOService.disco, SubmitPOService.wsd

Used in the Web service infrastructure.

  1. In a command window, navigate to the following folder:

    <Samples Path>\Orchestrations\ConsumeWebService

  2. Run the file Setup.bat, which performs the following actions:

    • Creates the input (In) and output (Out) folders for this sample in the following folder:

      <Samples Path>\Orchestrations\ConsumeWebService

    • Compiles and configures the sample Web service.

    • Compiles and deploys the BizTalk orchestration.

    • Creates and binds the relevant BizTalk Server ports.

    • Starts the BizTalk orchestration.

    Be sure your predefined IIS application pool identity is set to NT AUTHORITY\Network Service.

    You should confirm that BizTalk Server did not report any errors during the build and initialization process before attempting to run this sample.

  1. Paste a copy of the XML PO message input file ConsumeWebServiceInput.xml into the In folder.

  2. Observe the XML output file created in the Out folder. This file contains the XML representation of the invoice message constructed from the original PO message. The format of the name of this file is <MessageID>.xml, where <MessageID> is the GUID generated to uniquely identify the message.

  1. In a Visual Studio 2005 command window, navigate to the following folder:

    <Samples Path>\Orchestrations\ConsumeWebService\

  2. Run Cleanup.bat.

Community Additions

© 2015 Microsoft