BizTalk : Exposing Orchestration as WCF service
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 :
**
**
https://3.bp.blogspot.com/-zZwr2x47lt8/UVKZrin4nzI/AAAAAAAAAN0/YR0xoEe7XxM/s320/Schema.png
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.
**
**
https://2.bp.blogspot.com/-6eHVQgFl0p8/UVKaUj-ikiI/AAAAAAAAAN8/hOQLAJIFzbk/s320/Orchestration.png
**
**
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.
https://2.bp.blogspot.com/-ICJ26xja8VM/UVKaj_3yaoI/AAAAAAAAAOE/1g-imu-l3rQ/s320/Orch_Msgs.png
The message assignment shape simply copies the input message into output &
then assigns the status field as 'received'.
https://2.bp.blogspot.com/-9XWUwiZ6M3U/UVKaxV9WVYI/AAAAAAAAAOM/QvKihYOJAd0/s320/Expression.png
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.
https://4.bp.blogspot.com/-KRcJmUm2Ty4/UVK-O1kF8WI/AAAAAAAAAPk/zGMxHVaYsPg/s320/Exposing_1stpage.png
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.
https://4.bp.blogspot.com/-yaXyF2B7mf0/UVK-WUtP0TI/AAAAAAAAAPs/7BnALBm97yU/s320/Exposing_2ndpage.png
After that clicking next we see two options of exposing either schema or
Orchestration.Choose Orchestration & click next.
https://4.bp.blogspot.com/-UfD9C13arJQ/UVK-dSqXvqI/AAAAAAAAAP0/BoInCvog99Q/s320/Exposing_3rdpage.png
Then we need to choose our Biztalk project dll.
https://1.bp.blogspot.com/-lvRVb4gBCj8/UVK-jmjeW_I/AAAAAAAAAP8/aDNkexLbw1k/s320/Exposing_4page.png
After clicking next a receive port is created with the name specified on
the logical port in the Orchestration.
https://4.bp.blogspot.com/--jZd54BsmC4/UVK-s4f1Y9I/AAAAAAAAAQE/N_CO-8a2tl0/s320/Exposing_5page.png
After clicking next Specify the appropriate namespace for our service.
https://2.bp.blogspot.com/-9CETRM1rFS8/UVK-0J8PFKI/AAAAAAAAAQM/J8_6uBnveeo/s320/Exposing_6page.png
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.
https://2.bp.blogspot.com/-W-D-g4hSWRk/UVK-6zWEzwI/AAAAAAAAAQU/DMFMKVdnFqs/s320/Exposing_7page.png
On clicking next a WSDL is created for our service.
https://3.bp.blogspot.com/-AtGI-dcdnhE/UVK_CnmoLXI/AAAAAAAAAQc/8qM77ZM6GjA/s320/Exposing_8page.png
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.
https://1.bp.blogspot.com/-6HN1Jnnd02c/UVK_I-N-CAI/AAAAAAAAAQk/0WxfBaCrJNg/s320/Rcv_Enable.png
Next step is to browse the service from the IIS.
https://1.bp.blogspot.com/-1fp-ODlNQR4/UVK_VHtcXTI/AAAAAAAAAQs/NyufxT0uUiY/s320/IIS_browse.png
https://4.bp.blogspot.com/-BmsR-66N1cs/UVK_gBFiHGI/AAAAAAAAAQ0/uKMsvt-I5HY/s320/Browse_1.png
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.
https://4.bp.blogspot.com/-w0G6n7pCitY/UVK_mV3VY1I/AAAAAAAAAQ8/vgePfwOMSeU/s320/Browse_2.png
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.
https://4.bp.blogspot.com/-OlDIek-0IRw/UVK_4QXhWlI/AAAAAAAAARE/QodrHBAUUwM/s320/Add_Service.png
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.
https://4.bp.blogspot.com/-EfVjCB6ae-o/UVK__1XvEtI/AAAAAAAAARM/TvFp8qHkINA/s320/Add_Service._1png.png
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.
https://3.bp.blogspot.com/-COZ0hnF7p6Q/UVLAKps2khI/AAAAAAAAARU/21W2W525L-M/s320/Console_Code.png
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.
https://1.bp.blogspot.com/-hHbsGrnfl2o/UVLAT2gcgwI/AAAAAAAAARc/p9T4fTpf_M8/s320/Start_Console.png
See Also
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.