Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. You can get more detail here on msdn WCF. I was very relunctant to post this blog but then I thought that my blog will save alot of time of others plus I could provide simple way to achieve this.
Now for consumption we need to have a WCF web srevice ,there are two ways to create a wcf service, one is to create through BizTalk wcf web publishing wizard and other is publish through Visutal studio by defining our web method on that , on IIS.
I have already created a WCF service in which I send a request to Database and get response through our service. I have created below service through BizTalk WCF web publishing wizard.
Now I service has made and browsed on our browser as in my screen shot. Now service is responding fine , Now we have to work on our orchestration where we do our implementation part, with the following steps
(1) Create a Empty biztalk project, and then Add Web Reference, by right click on the project.
as we Added web reference in our project so , we will have the following artifacts in our project as fellows, as we are consuming WCF service in our orchestration.
Now Create a new orchestration, with nay name
Now whenever we add reference of any service, BizTalk generate request and response artifact in port type tab, when we open our orchestration we could find them below picture.
, on the right or left side of the orchestration click and Create a new Configuration port mentioned in below.
Now this is our dynamic configuring port which go and get back our required data from our WCF service whenever our orchestration instance created against this service in the message box, or simple is that it will bring data form wcf service for our project, In the port configuration wizard just name to your port and check on existing port radio button which will show the port which dynamically created by the biztalk, as I show in the image below.
Now designed your workflow as your project or service requirement, for simplicity I make it simpler.
Work Flow of Service:
Start Create a Receive port to get request form our application
(1) Create a Receive Shape , which receive our service request.
(2) Create a Map so that we can create a request message for our wcf service
(3) Send shape to send request to the WCF service,
(4) Again We need to heave a receive shape to get response form WCF service
End Create a send port to send or manipulate the wcf service response
Now most of our work has been done , we just need to create our mesage and make two and flow of those. Create request mesage, transform that mesage to WCF service request mesage, then make a resposne message which receive our response from WCF service, but when you are going to create a request and response message you will need to select request/response schema of Wcf from Web Message Type option as mentioned below.
Now our whole work has done, finally the workflow will be looking like below.
I hope this will remove most of the queries in consuming WCF service within orchesration.