Problem Statement

  • For one of the old BizTalk Project, we got a Change request for enhancements, it's common to get change request for existing project with the solution.
  • The challenging part here is we don’t have BizTalk solution maintained in TFS for this particular project / solution code is lost for some reason. Now we need to implement this change request and give it to the customer. OR
  • For some reason you need to analyze the BizTalk artifacts for an existing application without BizTalk solution, using only available BizTalk assemblies. OR
  • How to create BizTalk artifacts from DLL, without BizTalk solution. OR
  • MSDN Forum similar thread Click here

Existing Solution Flow, DLLS

  • I was thinking of the solution how to take up this scenario, after some days came up with a solution, to illustrate how I achieved this particular scenario will demo with the below simple interface example.
  • Find the below sample interface with Schema, Map, Pipeline, Orchestration and a pipeline component in send pipeline.
  • Existing Interface Functionality.
    • Receive, disassemble the message with XML dissembler in receive pipeline.
    • Orchestration, the message will be transformed when the records count is more than zero, otherwise, log an event in event viewer with file name saying file didn’t process.
    • Send, with custom pipeline component in an encoding stage (Component: Logs an event to Event Log).


Fig – Assembly Path containing BizTalk, Dot Net DLLs



Fig – BizTalk, Dot Net-Libraries Assembly

Tools used IL Spy

  • You can download IL Spy from the below links all are same any link is fine. 
  • https://github.com/icsharpcode/ILSpy/archive/2.3.1.zip
    https://codeload.github.com/icsharpcode/ILSpy/zip/2.3.1
    http://ilspy.net/
  • Download, Extract the zip file, open the solution and then Build successfully.
  • Open the application from the below path.
  • Path:        \ILSpy-2.3.1\ILSpy-2.3.1\ILSpy\bin\Release\ILSpy.exe
  • Open the BizTalk application DLL from the assembly or from the location where the DLL is present.
  • Expand your BizTalk assembly till you reach the BizTalk project namespace.
  • Once it opens looks like below, you can observe the BizTalk artifacts.
    • Below DLL contains 4 Artifacts Schema, Map, Pipeline, Orchestration.


Fig - IL Spy BizTalk DLL
  • Naming Rule: Replace Underscore with Dot from the above image / type name of the class that you copy for file naming. 


Fig - Artifacts Naming Format

Steps to Re-Create the BizTalk Artifacts

  • The below steps helps you to create the BizTalk artifacts.

Points to Follow Before

  • Go to ILSpy, expand your BizTalk assembly till you reach the BizTalk project namespace.
  • Get all the possible artifacts details related to the project that you are going to re-create.
  • For Helpers classes called in Orchestration can be found using ILSpy under the References, from the assembly name you could extract it from GAC.
  • When you click on References folder, in the right panel you could see all the assembly details, you can use that information to get the DLL from the GAC.


Fig – BizTalk Artifacts Classes, Reference
  • For Pipeline Components you can observe in Receive, Send Pipelines in two different ways.
    • Using BizTalk Administration console u can see the stages, components used.
    • Using BizTalk Pipeline class from the assembly. (Next Section you can refer)

New BizTalk Server Project

  • Step 1: Create a new BizTalk project from the BizTalk assembly namespace 
    • Example: BizTalk.Old.Project
  • Step 2: Add the below assembly reference, required for Pipelines reference.
    • Microsoft.BizTalk.Pipeline.Components.dll
  • Step 3: Add all the custom components DLL to your BizTalk project for send, receive pipeline reference.
  • After performing all the 3 steps you can observe with the below.

Schemas

The schemas can be extracted from the below steps.

  • Select the Schema Class in the left panel, in the right panel, you can see the decompiled classes for the schema class you selected.
1) Copy the text XmlContent schema class, within the quotes to Notepad or visual studio, follow the below steps.

 Fig – Schemas Content

2) Replace \" to "   - > Replace All


Fig – Replace Slash quotes with quotes

3) Replace \n to empty - > Replace All



Fig – Replace Slash n with nothing

4) Change the xml declaration tag encoding="utf-16" to encoding="utf-8"

5) Copy the name i.e. class name -> Replace Underscore with Dot ( _ to . ) - > Save file with BT.Source.Schema.xsd extension
(
BT_Source_Schema =>BT.Source.Schema.xsd)



Fig – Source Schema Class

(BT_Destination_Schema => BT.Destination.Schema.xsd)



Fig – Destination Schema Class

6) File Name to BT.Source.Schema.xsd, BT.Destination.Schema.xsd and Save as type All Files




Fig – Solution after creating XSD Schemas.

7) Add the XSD’s to your BizTalk project as an existing item and try to open – Should open successfully.
8) Repeat the same steps for every schema that you extract.


Maps

The mapping XSLT can be extracted from the below steps.

  • Select the Map Class in the left panel, in the right panel, you can see the decompiled classes for the Map class you selected.

1) In your BizTalk, add a new map with the below name like below shown.
Copy the name i.e. class name -> Replace Underscore with Dot ( _ to . ) - > Save file with BT.Map.btm
BT_Map => BT.Map.btm



Fig – Map Class


2) Copy the text XmlContent from the Map class, within the quotes to Notepad, follow the below steps.




Fig – Map Class XML Content
3)Replace \" to "   - > Replace All


Fig – Replace Slash quotes with quotes


4)Replace \n to empty - > Replace All


Fig – Replace Slash n with nothing

5)Change the xml declaration tag encoding="utf-16" to encoding="utf-8"
6)File Save = > File Name to BT.Map.xsl and Save as type All Files
7)Open the BT.Map.btm, Select the source, Destination schemas from the mapping window.
8)Open the Grid mapping properties, Select the Custom XSLT Path, Specify the XSL file just saved in the previous step.



Fig – Configure Custom XSL
9)Right-Click on map => Test map the map you should be able to see the results like expected.
Mapping Source Input and Output.



Fig – Testing the Map using valid source instance

10)There should not be any comments in C# Scripting, if it’s their remove it and try to test map.
11)The solution should like this at this stage.



Fig – Solution After Schema, Map with XSLT

Pipelines


The Pipelines can be extracted from the below steps.
  • To see what are the components referenced either in Receive or Send pipelines, its qualified assembly name to get it from GAC.
  • On the right panel, you could see the two methods.



Fig – Receive Pipeline Components Assembly Name




Fig – Send Pipeline Components Assembly Name

  • Select the Send, Receive Pipeline Classes in the left panel, in the right panel you can see the decompiled classes for the Pipeline Class you selected.


Fig – Receive Pipeline Class



Fig – Send Pipeline Class

1)Copy the text XmlContent from the pipeline class, within the quotes to Notepad or Visual Studio follow the below steps.





Fig – Pipeline Class XML Content

2)Replace \" to "   - > Replace All



Fig – Replace Slash quotes with quotes

3)Add PolicyFilePath Tag in Document Tag Section like below Receive / Send.

Receive Pipeline
PolicyFilePath="BTSReceivePolicy.xml"
Send Pipeline
PolicyFilePath="BTSTransmitPolicy.xml"



Fig – Pipelines with PolicyFilePath Formatting

4)
For every <Stage> copy the CategoryId attribute like CategoryId=""



5)For every Stage CategoryId attribute copy the GUID value from its corresponding StageId to CategoryId like shown in below images.

6)Save the File with BT.ReceivePipeline.btp, BT.SendPipeline.btp and add to an existing project.

BT_ReceivePipeline => BT.ReceivePipeline.btp
BT_SendPipeline      => BT.SendPipeline.btp




Fig – Overall steps for Receive Pipeline Creation



Fig – Overall steps for Send Pipeline Creation

7)
When you complete the above the steps you will be able to open the pipelines successfully with all the components active.




Fig – Solution After Schema, Map with XSLT, Pipelines Send, Receive with components.

Orchestrations

The Orchestrations can be extracted from the below steps.
  • You should refer all the helper classes that are referencing this orchestration like shown in above step.
  • Select the Orchestration Class in the left panel, in the right panel you can see the decompiled classes for the Orchestration Class you selected.





Fig – Orchestration Class

1)Copy the text _symODXML within the quotes to Notepad or Visual Studio follow the below steps.



Fig – Orchestration Content String

2)Replace \n to empty - > Replace All



Fig – Replace Slash n with nothing

3)
Now minimize the xml tag like shown below, Copy the below tags Top, Bottom tag like below, format with the below syntax.


#if __DESIGNER_DATA
#error Do not define __DESIGNER_DATA.
     
XML Text Contents Goes Here
 
#endif // __DESIGNER_DATA



Fig – Orchestration File Formatting

4)
Finally, Save the file with BT.Orchestration.odx extension.

BT_Orchestration => BT.Orchestration.odx



Fig – Orchestration file saving format

5)
Add this orchestration to your BizTalk project and open orchestration – should open successfully.



Fig – Solution After Schema, Map with XSLT, Pipelines Send, Receive with Components, Orchestration.

Build, Deploy Test the BizTalk Project

  • Now you can Build, Deploy if required Test the solution.
  • Analyze the solution deeply. 

Solution to Mistakes

  • General Mistakes in following the above steps.


Solution: xml encoding="utf-16" to encoding="utf-8"



Solution: You need to add Policy Tag either Receive or Send



Solution: xml encoding="utf-16" to encoding="utf-8"

Comments

  • This is one of my favorite Article.
  • I hope this helps you.

Source Code

  • To work with this example, you can download the sample Project, DLL from MSDN Code Gallery.

Conclusion

  • In this Article, you have learned how to create BizTalk artifacts from BizTalk assembly or DLL.
  • With this information, you can analyze the solution clearly, its implementation in details instead of just.

Tags helps in searching

  • How to get BizTalk Orchestration code from dll
  • How to get BizTalk Schemas from dll
  • How to get BizTalk Maps, XSLT code from dll
  • How to get BizTalk Pipelines from dll

See Also