5,693,062 members and growing! (15,523 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft BizTalk Server » General     Beginner

Calling a Web Service with Custom Parameters from an Orchestration in BizTalk Server 2004

By Naveen Karamchetti

This article describes how to invoke a Web Service which has custom parameters from a BizTalk Orchestration.
Windows, .NET, Visual Studio, Dev

Posted: 23 Mar 2006
Updated: 19 Apr 2006
Views: 30,996
Bookmarked: 12 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
9 votes for this Article.
Popularity: 3.17 Rating: 3.32 out of 5
2 votes, 22.2%
1
0 votes, 0.0%
2
2 votes, 22.2%
3
2 votes, 22.2%
4
3 votes, 33.3%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

It is generally very straight forward to invoke a Web Service from an BizTalk Orchestration. In some special cases, a Web service returns or accepts an object. In such cases a custom map is required to send a request to the web service. We shall consider a case where an object is returned from a web service and how this is handled in BizTalk.

Employee Data Retrieval - Example

Consider a simple scenario where some information about an Employee is required within an orchestration. This employee infomation is provided by some web service, which takes in a EmployeeInput object as a input parameter and returns a EmployeeOutput object. Notice that both the input and output parameters to the web service are objects, and not simple .NET types.

First came the schemas...

Let us have a quick look at the input and output schemas...

Employee Request Schema

EmpRequest

This is very simple schema with EmployeeCode element.

Employee Response Schema

EmpResponse

The output schema contains all the elements related to the employee information.

Approach Overview - Steps to Invoke a Web Service

  • In the Solution Explorer, right-click on the Project and select "Add Web Reference". Follow the instructions on the dialog displayed.
  • Look under the folder "Web References" and open the file "Reference.xsd". This file would contain the expected input and output formats(xml elements) to correctly invoke the Web Service.
  • Promote all the properties(xml elements) in the "Reference.xsd" file, which are required within the Orchestration.
  • Create a new "Map" which maps the data from the Orchestration message to the Web Service input. In this case, select the namespace for "Reference.xsd" as the Destination schema.
  • Lastly use the "Send" and "Receive" shape to send Web service Request and Response respectively.

Reference

BizTalk Maps

In this project we are using two maps,

  • The first one, would convert the input message into the one required by the Web Service.
    MessageSchema
  • The second one would convert the input message into the ouput message as required by the orchestration.
    MessageSchema

Building the Orchestration (also known as a "Business Process")

The parallel branch in this orchestration shall invoke the Web Service and perform the Transformation simultaneously.

WSOrchestration

Setting the parameters required to invoke the Web Service

WSParamEmployeeInput.EmployeeCode = EmployeeIn.EmployeeCode;
WSRequest.employeeInput = WSParamEmployeeInput;
System.Diagnostics.EventLog.WriteEntry("Transformation", "EmployeeIn -> WSRequest");

Assigning the EmployeeOut message into a temporary variable.

TempEmployeeOut = EmployeeOut;
System.Diagnostics.EventLog.WriteEntry("Transformation", "Employee In to EmployeeOut");

Assigning the data obtained from the Web Service to the EmployeeOut message.

EmployeeOut = TempEmployeeOut;

EmployeeOut.EmployeeCity = WSResponse.RetrieveEmployeeResult.EmployeeCity;
EmployeeOut.EmployeeName = WSResponse.RetrieveEmployeeResult.EmployeeName;
EmployeeOut.EmployeeDept = WSResponse.RetrieveEmployeeResult.EmployeeDept;
EmployeeOut.EmployeeEmail =WSResponse.RetrieveEmployeeResult.EmployeeEmail;

List of various messages used in the Orchestration...

InputXML

Executing the DEMO

Input XML File

InputXML

Notice the input file data. The EmployeeCode is filled up.

Solution Explorer

SolutionExplorer

Observe the various artifacts in the Solution Explorer.

Output XML File

OutputXML

The output XML file has all the information about the Employee.

About the Downloadable Code

  • Unzip the file WSParamDemo.zip with the folder names in the C:\drive.
  • Unzip the file EmployeeInfoService.zip with the folder names in the C:\inetpub\wwwroot drive and setup the Web Service Application through Internet Services Manager.
  • The folder KeyAndBindings contains the Bindings.xml file, which can be imported after the solution is built and deployed.
  • Place the EmployeeRequest_1.xml in the In folder and observe the Event log to find out the various events generated, and finally observe the Out folder for the output XML file.

Quick Takeaways

  1. Always set the Activate property to "true" for the first Receive shape in the orchestration.
  2. Note the XSD file generated when a Web Reference is added to the Project.
  3. Ensure that all the promoted properties in the schema have a default value. 
  4. A BizTalk service needs to be re-started everytime a deployment is done.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Naveen Karamchetti


Naveen Karamchetti has done his Masters (M.S.) in Software Engineering from B.I.T.S, Pilani and is based out of Fremont, CA.
The author has more than 8.5 yrs of experience in the IT industry, has started his career
starting from the good old days of using a Unix, Tcl/tk. The author has been associated with
several companies based out of Silicon Valley, California.

The author has won several programming awards within the organizations worked and is well-recognized. The author has also worked for Microsoft based at Redmond.

Hobbies include training, mentoring and research. Spends his free time travelling in the BART (Bay Area Rapid Transit) in Fremont, CA.
Occupation: Software Developer (Senior)
Location: United States United States

Other popular Microsoft BizTalk Server articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
GeneralHow to setup the Web Service Application through Internet Services Manager.membersam yassa6:42 15 Sep '08  
GeneralThanks a lot!memberBogdan Dumitrescu1:57 19 Apr '07  
GeneralNot very user friendlymembershahzad.syed21:07 15 Aug '06  
GeneralDoes anyone actually care about this?memberHeywood5:32 19 Apr '06  
GeneralRe: Does anyone actually care about this?memberbenjamin wegner22:25 26 Apr '06  
GeneralRe: Does anyone actually care about this?memberHeywood4:28 27 Apr '06  
GeneralRe: Does anyone actually care about this?memberNaveen Karamchetti9:20 27 Apr '06  
GeneralRe: Does anyone actually care about this?memberniles bhor5:09 28 Apr '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 19 Apr 2006
Editor:
Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2008
Web10 | Advertise on the Code Project