Total Pageviews

Saturday, July 2, 2016

How to Generate Xml Schema in BizTalk

How to Generate Xml Schema

There are three ways to generate the Xml Schema in BizTalk.

1)      Using Existing XSD:

If suppose partner provides the XSD from his end then we can simply add that schema in our project using add existing item.
 This method is generally not used, because it is not necessary that either or both receiving and sending partner knows about the XSD and they have it ready made.

            Follow below steps to add any existing item in project.




2)      Using Xml file

This is the most commonly used format that partner provides and can be used to generate the xml Schema in BizTalk. Any of the partner (Receiver or Sender) provides the xml file based on their requirement then it can be used handy to generate the xml schema. Follow below steps to Generate the Xml Schema from xml file.

a)      Right Click project-> Add->AddGenerateditems


b)      Click on Generated Schema and then click Add.


                                                   
c)      Click on Well-formed Xml rom drop down list, select the xml file provided by partner and then click ok. You can see a schema corresponding to your xml is generated.



Some time you will not get this option in drop down list. Especially when you install  BizTalk. first time.
Do following in this case.
·         Go to below directory and copy the two .dll files.
                        
(One is for DTD to Xsd generator and another is for Wellform Xml to Xsd generator.)


            C:\(Program files (X86) or Program files )\Microsoft Biztalk Server 2010/2013/2013 R2\SDK\Utilities\Schema Generator\:


·         Paste in below location.

C:\ (Program files (X86) or Program files)\Microsoft BizTalk Server 2010/2013/2013 R2\Developer Tools\Schema Editor Extensions

·         Close the visual studio and open again and then try to add existing schema, you will find this option there.


d)      Observe the property of the schema. Target namespace is one of the important properties of the schema and it should be set correctly. Sometimes it auto generated based on the xml message provided by partner. However we can change it based on the customer requirements and their standards. Generally it looks something like http://businesssolution.schemaname/schemaspecification/Version 1.0.0.0 .   It is important property because it contributes in calculating the message type which uniquely identifies the schema across all application of the BizTalk.



3)      Manual Generate the Xml Schema

We can generate the xml schema manually as well. For this purpose you should have all fields , attributes and Record information from the partner, what will be the data type  and their length , all such information should be with you according to agreed requirement between developer and the partner. To generate the Xml Schema manually follow below steps.

Let us say you have below xml message received from partner and we have to create schema manually for this.




a)      Right Click project-> Add->New Item and select Schema, give suitable name for your schema and click Add.



b)      Rename the Root node to EmployeeRoot.
c)      Right Click  EmployeeRootàInsert Schema nodeà child Record. Give it name as Name.


d)      Fname and Lname are the fields as they are nested under Name node. So add 2 Child Field elements. Right click Nameà insert Schema Nodeà Child Field element.  Give them names as Fname and Lname
e)      Right Click Nameà Insert Schema Nodeà Sibling Record. Name it as Address.


f)       Now we can see in input message provide by partner , street, city and state as coming like attribute so we need to add attribute element on Address node.

Right click Addressà Insert Schema nodeà child Field Attribute.
Add 3 such nodes and give them name as Street, City and State.




g)      Save the schema finally it looks like below and you can click on any node and in properties you can change the data type length etc as per requirement.



Hope you like this article, provide your feedback and suggestion in comments. 


No comments:

Post a Comment