Mohammed Atef’s Technical blog

Canonical schemas

Introduction

Canonical Schema is doing the same using for Canonical data model which designed to communicate between different data formats, actually this pattern used to decease the cost of integration developments while you are doing enterprise application integration and also it is used heavily in SOA solutions.

Problem

suppose you have five different schemas and you are going to integrate between them what you can do?

Solution without Canonical Schema

you will do integration and mapping between each schema you need to integrate with the other one.so you will do the below design pattern.
canonical schema1

the problem of this solution that you are was a lot of time for mapping and integrating each schema.

Solution Using Canonical Schema

you can create common schema called(Canonical Schema) and at any given time you can translate to or from this schema. it is seems you have only one schema and any other schema can transform to it, i think it will be better for you now.so kindly find the pattern design using Canonical Schema in the image below:

canonical schema2

I hope that helped.

Advertisements

August 19, 2009 Posted by | Architucture, Biztalk, Design Patterns, SOA | , , , | 3 Comments

Exposing WCF services from orchestrations using BizTalk 2009

Introduction
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
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
schema

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
Orchestration
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
OutMSg=InMsg;
OutMSg.Status="Received";

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";
cust.FName="Mohammed";
cust.LName="Atef";
cust.Status="pending";
Console.WriteLine("begin call wcf orchestration");
client.Operation_1(cust);
Console.WriteLine("done! check the output folder");
Console.ReadLine();

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="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FName xmlns="">Mohammed</FName>
<LName xmlns="">Atef</LName>
<Address xmlns="">salmia</Address>
<Status xmlns="">Received</Status>
</Customer>

I Hope This Help.

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