Expose WCF Service with BizTalk 2010 tutorial

Hello world !

Today my first tutorial on BizTalk. I’ll show you how to expose a WebService through BizTalk using the “BizTalk WCF Service Publishing wizard”.

The business case is this : I want to expose a WS that will allow a partner to send me customer invoices. These invoices processed by BizTalk might then be sent both to SAP for partner’s billing and to a datawarehouse for analysis.

Step 1 – Prepare the data contract : Create a BizTalk project containing only 1 schema. It wil be used for the customer invoice message (Invoice.xsd). Build the project. Don’t forget to sign the assembly so that it can be deployed to GAC

Now add the schema assembly to your BizTalk application (Right CLick on BizTalk Application then Add, BizTalk Assemblies). This will be useful for the Xm lReceive Pipeline of your WCF ReceiveLocation.

Add the .dll to your application

Step 3 – Run the wizard : Run the BizTalk WCF Service Publishing wizard. Choose the Service Endpoint with WCF-BasicHttp transport type, enable metadata endpoint and create BizTalk ReceiveLocation in the biztalk application BizWCFTutorialApp you’ve just created.

Choose Service Endpoint with WCF-BasicHttp adapter

Then choose to publish the previously created schemas as WCF Service.

publish schemas as WCF Service

In the next screen, you should customize the Web Service description with the following operations. Use your right click :

then you should be able to create the Service and end up to the following screen.

the wizard is over

Step 4 : Adapt IIS & BizTalk – In order for your WS to work you might need to change a few things.

First, as a good practice create a dedicated App Pool for your service. Go to IIS mangement console and create a new App Pool “BizTalkWcfServiceTutorialAppPool”. If you are like me and use BizTalk Server 2010, you must change the app pool .Net Framework to version 4.0. Then change your Service App Pool to the newly created one.

create a dedicated app pool

Give enough privileges to your app pool by choosing the right identity. I suggest admin for development purposes.

In BizTalk now :

Change the name of the wizard created WCF Receivelocation called WcfService_BizTalkWcfServiceTutorial/InvoiceService to something easier like “RcvLoc_Invoice_WCF”.

Change the ReceivePort to “RcvPort_Invoice_WCF”

Add a send port SendPort_Invoice_WCF and make it subscribe to messages from the app ReceivePort.

When choosing message type in the WCF Publishing wizard, you select a dll and a screen shows you availables schemas types available in the assembly so that you can choose wich one to expose as a service. In fact this is not really that. If you have the same .dll deployed to gac this screen shows you the gac dll content and not the content of the dll you’ve just selected. If like me you change and change again your Message types, you should be aware of that.

Now you are ready to Test your WS using the client and see the results in BizTalk. F5 the project “BizWCFTutorialClientApp”. You should see the following in BizTalk :

Tracked services instances

You can see 2 lines highlighted : the older represents the XML ReceivePipeline pipeline (notice it is run under BizTalk Isolated Host), it worked OK ; and the above line represents the send pipeline : pub/sub worked and message has been succesfully sent. See content matches your client code.

The result : invoice has been processed by BizTalk !

Done !

VS code (schemas, client console app, and bizTalk binding) is available here. As uploads of .zip files aren’t supported, you’ll have to delete the .jpg after saving the file to your computer. Sorry about that.

Thank you for your feedback. I’m glad it helped you, that’s one of the reason why I made this blog. I did not practice wcf to wcf communication myself yet. I’m putting appart my C# and Biztalk skills for a while…. I’m practicing Ruby on Rails and XP programming for the time beeing. Maybe I’ll get back to BizTalk dev one day, who knows….

This is very nice tutorial. I have scenario where I have to execute stored procedure for getting the data but without using pollingDataAvailableStatement and PollingDataStatement for say GetInvoice ? Any suggestion

Hi , great post, it really helps me, I´m newbie in biztalk.
This is my first time publishing schemas and this is the best tutorial i have found. THANK YOU VERY MUCH!
But i have a problem, calling client.SetInvoice(i), i get this error

“The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.”

If i type in the Client app.config, i get
{“Unrecognized configuration section serviceDebug. }
in InvoiceServiceClient client = new InvoiceServiceClient();