8/5/15

Exposing orchestration as WCF service biztalk example

I am going to demonstrate how to expose an Orchestration as WCF service & then consuming this exposed service using a WCF client.

Overall flow of the solution :
1. Creation of a solution
2. Creation of a BizTalk project in the solution which contains an XML schema & an Orchestration.
3. Publishing the Orchestration to IIS using BizTalk WCF publishing wizard.
4. Creation of a C# console project in the same solution.
5. Addition of the service reference of the above exposed orchestration into the C# console application.

Schema :

Created an XML schema with 'Status' field as distinguished field.

Orchestration :

The Orchestration simply receives a message from a folder path & the Status
of the message is changed to 'received' & then this new message is send to a
output folder location.

There are two messages used in the orchestration one for receive shape & one
for send shape but these two messages uses the same schema as message type.

The message assignment shape simply copies the input message into output &
then assigns the status field as 'received'.

After doing all this I'll build this BizTalk project & deploy this project to
Admin console.

Exposing the Orchestration :

Our brand new orchestration is ready to be exposed to IIS. We a wizard to
to perform this thing. In visual studio -> tools we have BizTalk WCF publishing
wizard.

After clicking next we have two options Service Endpoint & Metadata only endpoint.

We'll choose Service endpoint & also create a receive location in the deployed BizTalk
project.

After that clicking next we see two options of exposing either schema or
Orchestration.Choose Orchestration & click next.

Then we need to choose our Biztalk project dll.

After clicking next a receive port is created with the name specified on
the logical port in the Orchestration.

After clicking next Specify the appropriate namespace for our service.


After clicking next we have the option to locate our service. We can use
localhost to deploy the service on local IIS server or we can change host
to deploy the service on any other machine's IIS server.

On clicking next a WSDL is created for our service.

After clicking next a new receive location is created in the our project
in the admin console. We need to enable this receive location to browse
our WCF service.

Next step is to browse the service from the IIS.


Our exposed Orchestration service looks like below screenshot.
We need to copy the link in the explorer so that a service reference can be
added to consume this service.

After that I have created a new C# console application to act as a client
for our WCF service calling. Now we need to add the service reference of our
service.

Paste the URL copied from the explorer & click go.
Our service will be discovered & change the namespace.
This namespace will be used in our client to call the service.

Now in the client code we create an object of the client WCFClient.
An object of the root node of the schema is also created. We pass the
appropriate values to this object & call a method which is nothing but the
operation specified on the logical receive port in the Orchestration. Then
we close our client.

We simply start a new instance of our console program.
This will create a new message which will be passed to the
logical port of the orchestration & finally the message will be
processed by orchestration & a new XML file will be created at
the output folder.

Note: Original post by Rahul Madaan from biztalkvillage

No comments:

Post a Comment