Wednesday, December 31, 2008

WCF & BizTalk -Exposing WCF Service out of BizTalk Server.

 

In this Blog I am going show how to expose BizTalk Server 2009 Schema as a WCF Service using BizTalk Server WCF publishing Wizard.

First we need to create Empty BizTalk 2009 Project and Add Schema to that project.

Here I created the Contacts XSD with the following Child Elements.

<Name>Name_0</Name>

<Email>Email_0</Email>

<Phone>Phone_0</Phone>

 

image

Now Build this project and deploy into BizTalk server DB.

Launch the BizTalk Server WCF Service Publishing Wizard 

image

image

 

Enable metadata endpoint Checking check box  causes the “httpGetEnabled” flag to be set to true, thus enabling  Client application  to retrieve the WSDL for this service.

image

Now select the BizTalk application name which you want to expose as WCF Service.  here we need to select the project we deploy into BTS Server.

image

 

Now we asked whether we want “Publish orchestrations as WCF service” or “Publish schemas as WCF service.”  This both options same as classic BizTalk Web Services Publishing Wizard.  Now we will choose Publish schemas  option.

image

Here we are going to Add method to our WCF Service .

image

Select the Schema type for the method we just created.

image

Provide the Namespace for the WCF Service.

image

 

Provide the IIS Server Location to create the WCF Service. check allow Anonymous Access.

 

image

 

image

 

Go to IIS Manger and  you can see the WCF Service web application is created with  .SVC file

 

 

image

Browse the WCF  .SVC file.   Now you  created WCF service.

image

 

Configure the BizTalk server Receive and Send ports.

Now let's create the Windows Client and consume the  BizTalkServiceInstance WCF Service.

 

image

Run the client Application , now you will see  Message  in BTS Send ports.

image

 

Thanks

SreenivasaRagavan.

1 comment:

Bhavesh said...

Hi,

I have got one .net class called StatusMessage. I have two console application, one publisher and other subscriber. Ideally I want to transmit StatusMessage type message from publisher to subscriber using BizTalk orchestration.

subscriber app also hosts WCF service. there can be many instances of subscriber running on different machines across network. orchestration decides based on the content of StatusMessage which subscriber should the message be routed.

What I have done now is, within orchestration I have referenced StatusMessage type and used it as message for both send and receive shapes. my send shape is binded to dynamic send port. I have tried two senarios here. One publishing orchestration as WCF service and other without publishing.

In first senario used svcutil to create BizTalkServiceInstance.cs and app.config file. BizTalkServiceInstance.cs for some reason creates shadow type to represent my StatusMessage type. In my WCF client console application (publisher) I call the orchestration service and send shadow type to biztalk.

Now my subscriber is waiting for biztalk to call its service and transmit StatusMessage type to its method call. For some reason message arrives upto orchestration Send shape but it is not able to transmit message to subscriber because of conflict in type between orchestration message type and subscriber's StatusMessage type although they are using same type. StatusMessage type is also in GAC.

Please can someone advice what I am doing wrong here? How can I make a .net class transmit from one console application to another console application (hosting WCF service) via biztalk orchestration.