The ConsumeWebService sample demonstrates how to invoke a Web service from within a BizTalk orchestration.
This sample performs the following sequence of steps:
-
The BizTalk orchestration retrieves the XML purchase order (PO) message file from the receive location In folder.
-
The orchestration passes the XML PO message as a string to the Web service.
-
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.
-
The orchestration writes the invoice message to an .xml file in the Out folder.
How This Sample is Designed and Why
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.
Note |
|---|
|
The name is case-sensitive.
|
In this sample, submitPO is the name of the Web method that is being called.
Where to Find This Sample
<Samples Path>\Orchestrations\ConsumeWebService\
The following table shows the files in this sample and describes their purpose.
|
File(s)
|
Description
|
|---|
|
Cleanup.bat
|
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.
|
|
ConsumeWebServiceBinding.xml
|
Used for automated setup such as port binding.
|
|
ConsumeWebServiceInput.xml
|
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.
|
|
ReceivePOandSubmitToWS.odx
|
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.
|
|
Setup.bat
|
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.
|
Building and Initializing This Sample
To build and initialize the ConsumeWebService sample
-
In a command window, navigate to the following folder:
<Samples Path>\Orchestrations\ConsumeWebService
-
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.
Note |
|---|
|
Be sure your predefined IIS application pool identity is set to NT AUTHORITY\Network Service.
|
Note |
|---|
|
You should confirm that BizTalk Server did not report any errors during the build and initialization process before attempting to run this sample.
|
To run the ConsumeWebService sample
-
Paste a copy of the XML PO message input file ConsumeWebServiceInput.xml into the In folder.
-
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.
To uninstall the ConsumeWebService sample
-
In a Visual Studio 2005 command window, navigate to the following folder:
<Samples Path>\Orchestrations\ConsumeWebService\
-
Run Cleanup.bat.
Other Resources
Orchestrations (BizTalk Server Samples Folder)