Mohammed Atef’s Technical blog

Exposing WCF services from orchestrations using BizTalk 2009

Today i am trying to make simple BizTalk application for exposing WCF service from Orchestration.
i will explain this example from A to Z and you can download full BizTalk solution by click here .

Problem definition
Our application is used for receive xml file for customer and send this xml file to output folder by updating the customer status to received.

Solution composed from Three parts as follows :
Part one: Develop Schema and Orchestration and testing it
This part is direct and simple for all BizTalk developer. first i will create new BizTalk project and select add new file after that select schema file and build schema like the following image

then build the solution by specifying strong key and application deployment project attributes.
now we can build the orchestration project.
like the first project select new BizTalk Project and add new item but this time select new Orchestration then build the new orchestration like the below image
all this shapes is very sample and i am sure you can do it but to update the status for customer double click in the MessageAssignment shape and add this two lines of code

//assume the input message called InMsg and output message is OutMsg

now build the solution by specifying the strong key and application name like the previous project and deploy the solution.

finally go to the BizTalk server application console and extract applications you will find the new application. just you need to define receive and send port and bind these to the generated Orchestration and test you application.

Part Two : Generating Orchestration WCF

Now we are going to generate WCF for our Orchestration so kindly follow this steps

1- select Tools –>BizTalk WCF Service Publish wizard and press next

2- select Service Endpoint radio button and check the below two check boxes

3- select public BizTalk Orchestration as WCF Service

4- press next for all the incoming screens till you reach the finish screen.

now go to IIS you will find new WCF service found named by the orchestration name.

try to browse it now…ohhhh……..not work!!!!!!

to fix this issue go to the BizTalk Application console and open our application you will find new receive location with transport type WCF-WShttp disabled just enable it and go to the orchestration binding screen and select the new generated receive port in it is receive port.

Important note make sure that the application pool user account  for the WCF Service found  in BizTalk Isolated Host Users group.

Now i am sure if you browse this WCF service it will work.

Part three: Consume the WCF Orchestration

lets finish this project it over now. just add console windows project and right click the project name then select add service reference and put the WCF orchestration URL.

open the program.cs file code and add the following code

WCFSOAClient.SOAWCF_soawcf_Port_1Client client = new WCFClient.WCFSOAClient.SOAWCF_soawcf_Port_1Client();
WCFSOAClient.Customer cust = new WCFClient.WCFSOAClient.Customer();
cust.Address = "salmia";
Console.WriteLine("begin call wcf orchestration");
Console.WriteLine("done! check the output folder");

now run this console project you will see begin call WCF Orchestration and done! check the output folder and new fill dropped to the out folder contain the following xml.

<?xml version="1.0" encoding="utf-8"?>
<Customer xmlns="http://schema.Schema1" xmlns:xsi="" xmlns:xsd="">
<FName xmlns="">Mohammed</FName>
<LName xmlns="">Atef</LName>
<Address xmlns="">salmia</Address>
<Status xmlns="">Received</Status>

I Hope This Help.


July 8, 2009 Posted by | Biztalk, SOA | , , , | Leave a comment

BizTalk 2009 Orchestration Dehydration and Persistence Points

I am going to describe the Orchestration Dehydration and Persistence Points.this post for understanding why and how BizTalk use these.So let’s go quickly.

We know that BizTalk some times depending on other external application, so it is possible to ask BizTalk for waiting the other external application responses this my consume a lot of resources and memories, Instead of just waiting, the orchestration will dehydrate, and the state of the instance is taken out of memory and stored in SQL Server. BizTalk does this to free up valuable resources
for other processes and special subscription will be created for the dehydrated instance of the orchestration.This subscription will monitor the BizTalk message box for context properties
that match your unique correlation ID. When the subscription comes across that message, the
orchestration will “wake up,” and the state of the instance will be taken out of the database
and reconstituted in memory. The point at which the orchestration will, essentially, come alive
is known as a persistence point.
Persistence Points
The orchestration engine persists the entire state of a running orchestration instance at various points, so that the instance can later be completely restored in memory.
The state includes
1. The internal state of the engine, including its current progress.
2. The state of any .NET components that maintain state information and are being used by the orchestration.
3. Message and variable values.
if a message is received but there is an unexpected shutdown before state can be saved, the engine will not record that it has received the message, and will receive it again upon restarting. The engine will save the state in the following circumstances:

1. The end of a transactional scope is reached.
The engine saves state at the end of a transactional scope so that the point at which the orchestration should resume is defined unambiguously, and so that compensation can be carried out correctly if necessary.
The orchestration will continue to run from the end of the scope if persistence was successful; otherwise, the appropriate exception handler will be invoked. If the scope is transactional and atomic, the engine will save state within that scope.If the scope is transactional and long-running, the engine will generate a new transaction and persist the complete state of the runtime.
2.Debugging breakpoint is reached.
3. message is sent.The only exception to this is when a message is sent from within an atomic transaction scope.
4. The orchestration starts another orchestration asynchronously, as with the Start Orchestration shape.
5. The orchestration instance is suspended.
6. The system shuts down under controlled conditions. in that case, when the engine next runs, it will resume the orchestration instance from the last persistence point that occurred before the shutdown.
7. The engine determines that the instance should be dehydrated.
8.The orchestration instance is finished.

I hope this help…………

June 20, 2009 Posted by | Biztalk | , , | 1 Comment

Import orchestration Issue

Can you import one orchestration to two applications in BizTalk?
Answer is no, you can import the same orchestration to only one application and if you tried to re-import orchestration to application but buy checked the overwrite checkbox.
Okay, now you know the correct scenario for importing Orchestration. Let’s see this issue that I have faced before.

Did you face this exception before while you are importing Orchestration to an Application ‘asembly xxxx is already stored ’?
If yes, let’s see why this exception thrown and how to solve it

This exception happens because you are trying to import on orchestration into an application but this orchestration found in another application.

You can solve this issue by following these steps
1- Remove the old orchestration from the orchestration list in the old application.

2- Remove the assembly name from resources list in the old application.

I hope this help.

June 11, 2009 Posted by | Biztalk | , | Leave a comment