none
What is a Canonical Schema? RRS feed

  • Question

  • Hello All,

    What is a Canonical Schema?

    As per my knowledge, we can create small-small schema and import into a single schema is Canonical Schema. Have you ever implement in your project? Please provide me a real time scenario.

    Please share your experience where you have used Canonical schema.


    Thanks, Mohit Dahiya

    Saturday, October 8, 2016 6:00 PM

Answers

  • A Canonical Schema is just an internal schema that can represent a business 'object' in a common format, independent of any external specification of format.

    Basically, you would map different incoming Purchase Order formats (X12, cXml, Flat File) to your internal Canonical format, then use that for a process common to all PO's.

    Then the reverse on the way out.

    Saturday, October 8, 2016 6:19 PM
    Moderator
  • Hi Mohit,

    Cannonical schema in broader term specifies the schema which is like a collection of fields across various schemas...

    hence you can map N number of different messages to a canonical schema and then use this schema to process the messages in Biztalk..

    A canonical schema is a design pattern, which is applied within service oriented paradigm, and within BizTalk server context establish loose coupling between systems. Through performing transformation of messages from one system to canonical schema and from canonical schema to message of another system, systems have no direct relation with each other. Canonical schema can also be viewed as an internal schema in BizTalk and aid you in structuring your solution through best practice of creating separate projects for maps, orchestrations, internal and external schemas. Another advantage of using a canonical schema is that it reduces the number of transformations you need. If you need a to map a few types of inbound message coming from different parties to a few outbound messages, you can create a map to your canonical schema for each inbound schema and then a map from your canonical schema to each outbound schema. If for example you have three types of incoming that needs to be mapped to three types of outgoing messages you will only need to build and maintain six maps instead of nine. 

    Refererence: Canonical Schemas

    For a sample, you can refer: Create a Canonical Schema Step by Step

     For more details refer : Thoughts on the Canonical Messaging Pattern

    Regards,



    Mandar Dharmadhikari


    Saturday, October 8, 2016 6:38 PM
    Moderator

All replies

  • A Canonical Schema is just an internal schema that can represent a business 'object' in a common format, independent of any external specification of format.

    Basically, you would map different incoming Purchase Order formats (X12, cXml, Flat File) to your internal Canonical format, then use that for a process common to all PO's.

    Then the reverse on the way out.

    Saturday, October 8, 2016 6:19 PM
    Moderator
  • Thank you Johns.

    Do you have any example? I mean any tutorial.


    Thanks, Mohit Dahiya

    Saturday, October 8, 2016 6:23 PM
  • Hi Mohit,

    Cannonical schema in broader term specifies the schema which is like a collection of fields across various schemas...

    hence you can map N number of different messages to a canonical schema and then use this schema to process the messages in Biztalk..

    A canonical schema is a design pattern, which is applied within service oriented paradigm, and within BizTalk server context establish loose coupling between systems. Through performing transformation of messages from one system to canonical schema and from canonical schema to message of another system, systems have no direct relation with each other. Canonical schema can also be viewed as an internal schema in BizTalk and aid you in structuring your solution through best practice of creating separate projects for maps, orchestrations, internal and external schemas. Another advantage of using a canonical schema is that it reduces the number of transformations you need. If you need a to map a few types of inbound message coming from different parties to a few outbound messages, you can create a map to your canonical schema for each inbound schema and then a map from your canonical schema to each outbound schema. If for example you have three types of incoming that needs to be mapped to three types of outgoing messages you will only need to build and maintain six maps instead of nine. 

    Refererence: Canonical Schemas

    For a sample, you can refer: Create a Canonical Schema Step by Step

     For more details refer : Thoughts on the Canonical Messaging Pattern

    Regards,



    Mandar Dharmadhikari


    Saturday, October 8, 2016 6:38 PM
    Moderator
  • So, don't over think it, it's just a pattern that uses Schemas and Maps.  There's nothing really to tutorial on since both are just normal BizTalk operations.

    The example really is as simple as I describe.  You can receive a PO in X12 EDI, EDIFACT EDI, cXml or any number of formats, then Map them all to a single internal format that you define for your app.

    That's really all the Canonical Pattern is.

    Saturday, October 8, 2016 7:22 PM
    Moderator
  • There is nothing special about Canonical schema. Its just another schema but it represents your internal model and all external systems maps to it. 

    This is done to make sure that if there are any changes to a system or a addition of new systems you just make changes to one map and the other business process is taken care of.

    You can read about the usage, patterns around this..

    https://dzone.com/articles/soa-pattern-week-6-canonical

    http://geekswithblogs.net/mattjgilbert/archive/2009/04/07/a-brief-note-on-canonical-schemas.aspx

    It also depends if it suits your business needs.. So its not for always use..

    https://buddhiraju.wordpress.com/2011/10/24/challenges-with-the-canonical-schema-design-pattern/


    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool

    LinkedIn: LinkedIn

    Saturday, October 8, 2016 8:12 PM
    Answerer
  • Hi,

    You have got all; the definition from our experts of canonical schema, I will write a novice version of it.

    Think of it as a sort of helper schema where you can store some values temporarily.

    For example if you have an orchestration which calls 4 service A1 B1 C1 D1 and from the response of each service you need to construct another message and send it to some endpoint. Then you can create a schema in your project call  it the canonical or helper schema and after each sevice call you create a map, destination of the map would be the helper schema and will store the required  values of each service response.

    Once all the service responses from A1 B1 C1 D1 are received you will have this canonical schema of your storing all the required values from the four service responses which can further be used for the logic to create your final orchestration response and send it to the end point you want to.


    Regards Pushpendra Singh : Please mark the reply as answer or vote it up, as deemed fit.


    Sunday, October 9, 2016 2:04 AM
  • Thank you all for the reply.

    Example : I have a sample application and have three input schema and three output partner Schema.

    1. AddressDetails.XSD

    2. PaymentDetails.XSD

    3. OrderDetails.XSD

    4. AddressDetails_Partner.XSD

    5. PaymentDetails_Partner.xsd

    6. OrderDetails_Partner.XSD

    Now, I need to transform from input schema to partner Schema. So, I have to create three MAP i.e. Address, Payment and Order.

    Question : Can I use Canonical schema here? I tried but I am not really sure whether it is good practice or not.

    I have created two Canonical (Internal schemas) and single MAP.


    When I drop a AddressDetails file into IN folder, file didn't transform. I mean that my approach is not working. 

    Can you please tell me how I can achieve it.


    Thanks, Mohit Dahiya


    Sunday, October 9, 2016 5:23 AM
  • When I drop a AddressDetails file into IN folder, file didn't transform. I mean that my approach is not working. 

    Can you please tell me how I can achieve it.


    Thanks, Mohit Dahiya


    Is your file a valid input for the map ? U can validate the input against the schema and see. 

    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool

    LinkedIn: LinkedIn

    Sunday, October 9, 2016 6:25 AM
    Answerer

  • Is your file a valid input for the map ? U can validate the input against the schema and see. 

    Pi_xel_xar


    No, I cannot. Error : Root element is missing.


    Thanks, Mohit Dahiya

    Sunday, October 9, 2016 6:48 AM
  • Root element is missing in output. Check ur test input .. what is the xml Addressdetails_output.xml that u r using to test map. U should check ur input msg.. try debugging map .. right click debug to see why u r not getting Output. Probably something is not right with ur input msg namespace or root node.

    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool

    LinkedIn: LinkedIn

    Sunday, October 9, 2016 6:53 AM
    Answerer
  • Yes. I am sending only Address details in Input.

    Internal or Canonical Schema which I am using in inbound Map.



    Thanks, Mohit Dahiya

    Sunday, October 9, 2016 7:00 AM
  • Hi Mohit,

    Can you share the map details??? a screen shot perhaps

    Regards,


    Mandar Dharmadhikari

    Sunday, October 9, 2016 7:10 AM
    Moderator
  • As per ur map your msg should have start tag of <MyInternalSchema> Test the map from a default generated msg and then chk the input created for you. You are close..

    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool

    LinkedIn: LinkedIn

    Sunday, October 9, 2016 7:19 AM
    Answerer
  • Thank you all for the reply.

    Example : I have a sample application and have three input schema and three output partner Schema.

    ...

    These questions actually have nothing to do with a Canonical Schema.  So, please open a new thread.

    What you're asking about here are Schema references, import and include.

    Sunday, October 9, 2016 11:53 AM
    Moderator