Biztalk Server simple XML architecture example

Source: Internet
Author: User
Tags biztalk
Biztalk Server Examples of simple XML ArchitectureAuthor: Zheng Zuo Date: 2006-08-02 if business orchestration is used in the BizTalk project, there is usually a ing process between receiving messages and sending messages. When adding an XML schema to the BizTalk project, if the XML packet contains a namespace, the architecture may fail to be verified. You need to set the attribute to solve the problem. This article is intended for developers who first develop the BizTalk project. Assume there is an input order message named "poin. xml". The message content is as follows.

<Root xmlns = "http://Zhengzuo.ContentTransmit.POin"> <ponumber> 1 </ponumber> <date>: 20: 00.000-05:00 </date> </root>
Add a new project, and select "architecture file" to add the schema poin. XSD file. The structure of the edited file is as follows.

<? XML version = "1.0" encoding = "UTF-16"?> <Xs: schema xmlns: B = "http://schemas.microsoft.com/BizTalk/2003" xmlns = "http://Zhengzuo.ContentTransmit.POin" targetnamespace = "http://Zhengzuo.ContentTransmit.POin" xmlns: xs = "http://www.w3.org/2001/XMLSchema"> <Xs: element name = "root"> <Xs: complextype> <Xs: sequence> <Xs: element name = "ponumber" type = "XS: string"/> <Xs: element name = "date" type = "XS: datetime"/> </Xs: sequence> </Xs: complextype> </Xs: Element> </Xs: schema>
Right-click the poin. XSD file and choose "properties" from the shortcut menu. Specify poin. XML in "input Instance name File". Right-click the file to verify the file instance,   Error prompt:Error 1 element namespace "root" in the http://Zhengzuo.ContentTransmit.POin ". 'Ponumber' in the child element namespace' http://Zhengzuo.ContentTransmit.POin ". Invalid. It should be a list of possible elements: "ponumber ". C:/poin. xml Error 2 failed to verify the instance file of the schema poin. XSD. File: <file: // C:/poin. xml>. E:/vs2005projects/test projects/BizTalk Server test/zhengzuo. contenttransmit/poin. XSD if the namespace "xmlns =" http://Zhengzuo.ContentTransmit.POin "" in the message is removed, the verification passes.   Cause analysis:Edit schema in BizTalk's schema editor. By default, the target namespace attribute is only valid for root record, while the default namespace of conventional XML files is valid for all fields and record, therefore, verification fails when the corresponding schema is used.   Solution:Change the element formdefault attribute of Schema from the default value of unqualified to qualified so that the target namespace attribute is valid for all its records and fields. After setting, the message instance passes verification. Write the Output Architecture file named poout. XSD. The definition structure is as follows,

<? XML version = "1.0" encoding = "UTF-16"?> <Xs: schema xmlns: B = "http://schemas.microsoft.com/BizTalk/2003" xmlns = "http://Zhengzuo.ContentTransmit.POout" targetnamespace = "http://Zhengzuo.ContentTransmit.POout" xmlns: xs = "http://www.w3.org/2001/XMLSchema"> <Xs: element name = "root"> <Xs: complextype> <Xs: attribute name = "ponumber" type = "XS: string"/> <Xs: attribute name = "date" type = "XS: datetime"/> </Xs: complextype> </Xs: Element> </Xs: schema>
Creates a schema ing file named pomap. BTM, through pomap. right-click BTM, choose "properties", set "test verification input instance" and "test verification output instance", right-click "test ing", and the message "success" is displayed. The output file is poout. XML,

<Ns0: Root ponumber = "1" date = ": 20: 00.000-05:00" xmlns: ns0 = "http://Zhengzuo.ContentTransmit.POout"/>
If the attribute formdefault attribute value of poout. XSD is set to qualified, the output content is changed,

<Ns0: Root ns0: ponumber = "1" ns0: Date = ": 20: 00.000-05:00" xmlns: ns0 = "http://Zhengzuo.ContentTransmit.POout"/>
Remove the value of the target namespace attribute of poout. XSD, and the output result is changed,

<Root ponumber = "1" date = ": 20: 00.000-05:00"/>
If a message sample already exists, you can use the XML schema generation Wizard provided by BizTalk to generate the schema file to avoid verification problems. The procedure is as follows: 1. In the BizTalk project, right-click "add"-"add generated item", select "generate architecture" in the window, and click "add ". 2. In the BizTalk architecture builder window, select "well-formed XML" for the document type, set the input file to "poin. xml", and click "OK. The contents of the generated schema file are as follows,

<? XML version = "1.0" encoding = "UTF-16"?> <Xs: schema xmlns: B = "http://schemas.microsoft.com/BizTalk/2003" attributeformdefault = "unqualified" elementformdefault = "qualified" targetnamespace = "http://Zhengzuo.ContentTransmit.POin" xmlns: xs = "http://www.w3.org/2001/XMLSchema"> <Xs: element name = "root"> <Xs: complextype> <Xs: sequence> <Xs: element name = "ponumber" type = "XS: unsignedbyte"/> <Xs: element name = "date" type = "XS: datetime"/> </Xs: sequence> </Xs: complextype> </Xs: Element> </Xs: schema>
The following attributes are added to the root node. Attributeformdefault = "unqualified" elementformdefault = "qualified" for optional elements, such as the input order message to modify the name, the date element becomes optional:

<Root xmlns = "http://Zhengzuo.ContentTransmit.POin"> <ponumber> 1 </ponumber> </root>
In this case, the system will see the error bec2004: the content of the element "root" is incomplete. It should be a list of possible elements: "date ". This is because the default values of the "Min occurs" and "Max occurs" attributes of an element node are 1. That is to say, the element appears at least once and only once. Set the value of the "Min occurs" attribute to 0 to pass the verification. If this element is allowed to appear multiple times, you can set the "Max occurs" attribute value to N, or "*". N indicates a number, and * indicates the maximum number of uncertain values, the architecture editor in the BizTalk project automatically changes * to "unbounded ". The modified architecture is shown as follows,

<? XML version = "1.0" encoding = "UTF-16"?> <Xs: schema xmlns: B = "http://schemas.microsoft.com/BizTalk/2003" xmlns = "http://Zhengzuo.ContentTransmit.POin" elementformdefault = "qualified" targetnamespace = "http://Zhengzuo.ContentTransmit.POin" xmlns: xs = "http://www.w3.org/2001/XMLSchema"> <Xs: element name = "root"> <Xs: complextype> <Xs: sequence> <Xs: element name = "ponumber" type = "XS: string"/> <Xs: element minoccurs = "0" maxoccurs = "unbounded" name = "date" type = "XS: datetime"/> </Xs: sequence> </Xs: complextype> </Xs: Element> </Xs: schema>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.