Step 4: Creating the HeaderHelper Project
In this step, you create a .NET class library. When a private process orchestration receives an incoming message, the HeaderHelper library determines whether a document conversion is required and if it is required, performs that conversion. This lets your orchestration work with different versions of RosettaNet Implementation Framework (RNIF) documents. Additionally, when a 3A2 response message is sent, the HeaderHelper library performs an additional document conversion before transmitting the message.
To create the HeaderHelper project
In Visual Studio, in Solution Explorer, right-click the Contoso solution, point to Add, and then click New Project.
In the Add New Project dialog box, in the Project Types pane, select Visual C#.
In the Templates pane, select the Class Library template.
In the Name box, type HeaderHelper, and then click OK to create the project.
In Solution Explorer, right click the Class1.cs file in the HeaderHelper project, click Rename, type HeaderHelper.cs, and then press Enter.
To create the Helper class
In Solution Explorer, expand the HeaderHelper project, and then double-click the HeaderHelper.cs node to open the HeaderHelper source file.
Type the following code into the source file, overwriting all the existing code:
using System; using System.Xml; namespace ContosoPriceAndAvailability { public class Helper { static public XmlDocument NormalizeHeader( XmlDocument curPip ) { string strInput = curPip.OuterXml; try { XmlDocument xDoc = new XmlDocument(); strInput = strInput.Replace("<!DOCTYPE Pip3A2PriceAndAvailabilityQuery SYSTEM \"3A2PriceAndAvailabilityQueryMessageGuideline_v1_3.dtd\"[]>",String.Empty); strInput = strInput.Replace("<Pip3A2PriceAndAvailabilityQuery>","<Pip3A2PriceAndAvailabilityQuery xmlns=\"http://schemas.microsoft.com/biztalk/btarn/2004/3A2PriceAndAvailabilityQueryMessageGuideline_v1_3.dtd\">"); strInput = strInput.Replace("xml:",String.Empty); strInput = strInput.Replace("b:",String.Empty); strInput = strInput.Replace("lang:",String.Empty); strInput = strInput.Replace("ns1:",String.Empty); xDoc.LoadXml(strInput); return xDoc; } catch(Exception ex) { System.Diagnostics.Debug.Write( ex.Message ); throw ex; } } static public string ReturnSCWithDocType( XmlDocument xmlDoc ) { try { string sResponse = xmlDoc.InnerXml; sResponse=sResponse.Replace("ns0:",String.Empty); xmlDoc.LoadXml(sResponse); xmlDoc.DocumentElement.RemoveAllAttributes(); sResponse = xmlDoc.InnerXml; sResponse = sResponse.Insert(0,"<!DOCTYPE Pip3A2PriceAndAvailabilityResponse SYSTEM \"3A2PriceAndAvailabilityResponseMessageGuideline_v1_3.dtd\">"); sResponse = sResponse.Replace("ns0:",String.Empty); sResponse = sResponse.Replace("b:",String.Empty); sResponse = sResponse.Replace("lang:",String.Empty); sResponse = sResponse.Replace("ns1:",String.Empty); return sResponse; } catch(Exception ex) { throw ex; } } } }
On the File menu, click Save All.
To create a strong named assembly for the HeaderHelper project
In Solution Explorer, right-click the HeaderHelper project, and then click Properties.
In the HeaderHelper Property Pages dialog box, select Signing in the left pane of the HeaderHelp properties pane.
In the right pane, click Sign the Assembly.
Click the Choose a strong name key file text box, and then select <Browse> from the drop-down list.
In the Select File dialog box, move to the location of your Contoso assembly, and double-click FabConPriceAvail.snk.
On the File menu, click Save All.
In Solution Explorer, expand the HeaderHelper project, expand the Properties node, and then double-click the AssemblyInfo.cs node to open the AssemblyInfo.cs source file.
In the AssemblyInfo.cs source file, type the following code on the line after the AssemblyCulture attribute:
[assembly: AssemblyKeyFile("../../../FabConPriceAvail.snk")]
On the File menu, click Save All.
To build and deploy the HeaderHelper project
In Solution Explorer, right-click the HeaderHelper project, and then click Build.
Start Visual Studio 2012 Command Prompt.
At the command prompt, move to the location of the HeaderHelper project output directory (the \Bin\Debug folder).
At the command prompt, type gacutil /if HeaderHelper.dll and press Enter to install the HeaderHelper assembly into the Global Assembly Cache.