BizTalk series (4) In-depth Map Testing

Source: Internet
Author: User
Tags xslt biztalk

For more information, see the BizTalk hands-on experiment series directory.

BizTalk Development Series

During the development of BizTalk, The ing between XML messages is very important. If only the value of the source node is copied to the target node, the MAP test and verification provided by the BizTalk project can meet the requirements. However, it is often necessary to perform complex operations during the ing process. For example, the combined operation of node values. Fortunately, Visual Studio provides the XSLT test function. In the development of BizTalk, you can use this function to debug Map in one step. Next we will take a look at the simple test and advanced test of Map respectively.

Simple Mapping Test

  • Verify Map

Right-click and select Validate. In the "output" window, you can view the verification information about Map.

  • Test Map

Right-click Test map. Visual Studio automatically generates the Map source message and displays the Test information about Map in the output window.

If you want to use a custom message as a test instance. You can right-click and select properties. In the Properties window, TestMap Input Instalce and TestMap Output Instance enter the path of the corresponding file respectively.

 

Advanced Mapping Testing

In the actual development process, custom development of Map is often required. For this reason, the BizTalk Map editor provides the Script Functoid, which supports C #. NET, JScript. NET, Visual Basic. NET, extensible style sheet language conversion (XSLT), and XSLT call templates. If you use "simple test", debugging these scripts will be very troublesome. Because sometimes we need to know the values of input and output parameters, the execution of scripts, and other information. To help improve the script.

If you have verified the Map, you will find that the corresponding XSLT file is generated in the output window (Note: XSLT is a conversion language ). Visual Stuido supports XLST debugging. The following Sample shows how to use the XSLT file generated by Map to test Map. (Note: Modifications to the XSLT file will not be applied to the corresponding Map file)

As shown in, we use custom scripts in Map: inline XSLT and C #.

 

Script code for inline XSLT

<xsl:if test="MainRecord/SubRecord/@AttributeA = 'AttriA'"><FieldB><xsl:value-of select="MainRecord/SubRecord/@AttributeA" /></FieldB></xsl:>

Inline C # script code

public string MyConcat(string param){return param.Trim();}

1. Right-click the Map file and click "verify"

2. Press Ctrl in the output window and click the file suffixed with XSL.

3. Right-click "view source code" on the opened file"

4. Now we can find that you can set breakpoints on the left side of the XSL editor, and an "XML" menu is added to the menu.

5. Set the XSLT input and output files in the attributes.

6. Click "Debug XSLT" to debug XSLT in one step. In the output file window on the right, you can see the rotation effect in real time.

7. In the monitoring column, you can output the variable information. When running to the Template, you can also directly enter the Xpath query statement to verify the output. You can also see the value of the current variable or statement when you move the cursor to the selected field.

 

The script support in XSLT is added to the <msxsl: script> element by Microsoft for extension of the XSLT language. All custom scripts are generated on this node, as shown in the following code.

<msxsl:script language="C#" implements-prefix="userCSharp"><![CDATA[public string MyConcat(string param1, string param2){return param1+param2;}]]></msxsl:script>

With the above Test methods, we can easily find bugs in Map. However, when testing external Assembly, we can only use the Test Map Method of "simple Test, because Map places references to the Assembly, class, and method in the extension object file associated with the generated style table and calls it at runtime. Therefore, you can write custom inline Functoid for testing. Of course, development is troublesome.

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.