When the BizTalk Server 2004 team development and test environment is put into place, it is important to make certain that the platform and environment is stable. The following sections detail techniques and approaches that will help deliver a stable environment and stable development process.
Backing Up Development Data
First, ensure that the Visual SourceSafe store is robust. Always ensure that the Visual SourceSafe repository is located on a file server that is under a backup regime or on a resilient disk subsystem. In this way all the entities that are checked into Visual SourceSafe will be retrievable in the event of a workstation failure.
Always use Visual SourceSafe to store all the shared deliverables like install scripts, build scripts, and deployment scripts. This ensures that although they are not necessarily assigned to a specific user they are still under a versioning and backup strategy.
The recommended approach to using Visual SourceSafe is to check in code only when it has passed functional testing. This means that a considerable period of time can pass between check-in operations, during which time the code is not on the backed-up Visual SourceSafe disk location. To mitigate the failure of a developer workstation it is important to ensure that a backup of the developer's workstations takes place.
A simple approach to back up developer workstations can be set up by using the robust copy (robocopy.exe) tool that is distributed with the Windows resource kits. You can find this tool on the Windows 2000 Web site at http://go.microsoft.com/fwlink/?LinkId=44527.
Robust copy will perform an incremental, multifolder copy, providing an efficient way to perform simple backup operations.
To set up a developer workstation backup:
-
Copy robocopy.exe into the Windows\System32 folder of all developers' workstations.
-
Create a command file that contains a line similar to the following:
robocopy c:\SysInteg2004 \\backupserver\SysteInteg2004\DeveloperWorkstation001\ /s /z
-
Create a scheduled task to run the task at regular intervals, making sure that the user account used to run the task has appropriate write permissions on the destination backup server.
For developers who are new to integration development, one of the most noticeable differences is the lack of visual feedback when testing integration code. Traditionally a client application or server assemblies can report status or errors and the Integrated Development Environment (IDE) will provide detailed messages and error context information (such as stack contents and traces). Development under BizTalk Server 2004 requires an alternative approach to debugging the runtime.
This section provides debugging and tracing information that will be of use to those new to BizTalk Server 2004 development.
No Activity Checklist
One of the most common scenarios that occurs when developing with BizTalk Server 2004 is that of initiating a business process (for example, dropping an input file into a folder) and then not finding any corresponding output (for example, no corresponding output file in the output folder).
Due to the flexibility available in BizTalk Server 2004 configuration, there are many possible causes for this type of scenario. The following list is provided as a simple checklist to allow a developer to check some of the commonly occurring causes:
-
Check the system event viewer for error messages. The event log is the location that BizTalk Server 2004 uses to record runtime errors and is the best place to diagnose errors with documents being processed. Remember that if your BizTalk Server 2004 configuration has multiple servers you may need to check the event logs of all the servers.
-
Ensure that the BizTalk Server 2004 service is running.
-
Ensure that the in-process host is shown as running in the BizTalk Server 2004 Administrator.
-
If using a file port or file send port, check that the "BizTalk Server 2004 Application User" has "read, write, and modify" permissions on any file locations in use. If this user does not have permissions to create and delete files the receive functions will fail because they cannot guarantee to successfully read or write files.
-
If using a file receive location, ensure that any input files dropped into a file receive location do not have the READ ONLY attribute set. If this is the case the file receive port will disable itself. Remember to refresh BizTalk Explorer to identify if the status of the receive ports has changed.
-
Check that the orchestration is enlisted and running. A common initial oversight is to fail to enlist or start the process that will handle the incoming messages. Use BizTalk Explorer in Visual Studio .NET to ensure that the process you are testing is running.
-
If the deployed DLL has just changed, it is possible that the BizTalk Server 2004 runtime has not yet picked up the latest version and is using a cached copy of the previous DLL. To force the runtime to pick up the new version, recycle the BizTalk Server 2004 hosts or restart the BizTalk Server 2004 service. See "Restarting BizTalk Server Hosts and Services" for more details.
-
Check Health and Activity Tracking (HAT) to see which phases the message is passing through (see "Health and Activity Tracking" for more details).
-
If using an HTTP receive port, check that it is functioning correctly. Use the IIS MMC to navigate to the virtual directory containing the BTSHTPPReceive.DLL. Right-click the BTSHTPPReceive.DLL file in IIS admin and then click Browse. An HTTP page should be returned and an error should be reported in the event log of the receiving BizTalk Server 2004 server, reporting that the runtime received a message but could not process it. The error message shows that the receive function is working but that BizTalk Server 2004 could not successfully process the message (which is to be expected because it had no actual XML content).
-
If using any test harnesses (like the ASP HTTP POST application), ensure that the harness is posting to the correct address. Check that the test harness is posting to the correct address by pasting the address into a browser and ensuring that the address resolves and a page is returned successfully.
-
Ensure that no orchestrations have debug points set that would cause processing to halt.
-
If binding files have been used to deploy a solution, check the installed binding configuration against the expected configuration in case incorrect binding files have been used.
-
If an IIS configuration change has been made (for example, changing an application pool setting), run IISRESET to ensure that any changes have been picked up.
-
Certain BizTalk Server 2004 configuration changes require the host to restart to take effect. If changes have been made to the BizTalk Server 2004 runtime, try restarting the BizTalk Server 2004 service.
-
Check that the appropriate BizTalk Host is running on the appropriate computer. When multiple servers are configured and processes can be bound to specific hosts it is important to confirm that the correct host is started and running.
Health and Activity Tracking
The Health and Activity Tracking (HAT) tool is a valuable tool for understanding the content and status of messages submitted to the BizTalk Server 2004 runtime. For more information about HAT, see BizTalk Server 2004 Help.
It is often useful to be able to use HAT to view the actual contents of a message. This is not enabled by default (due to the resource overhead incurred when recording message bodies). The following steps can aid a developer looking to capture the content of specific messages submitted to the runtime.
To capture message contents using HAT:
-
Make sure that message tracking is set up to capture the message contents for a specific message:
-
Start HAT and then select Configuration|Orchestrations.
-
Select the <orchestration name>. Under "Select the events and data to be tracked" select the "Inbound message bodies" and "Outbound message bodies" check boxes, and then click Apply.
To see messages passing through a pipeline (for example, for a flat file):
-
Start HAT and then select Configuration|Pipelines.
-
Select <pipeline name>. Under "Select the events and data to be tracked" select the "Inbound message bodies" and "Outbound message bodies" check boxes, and then click Apply.
To see messages not associated with an orchestration (for example, messages directly bound to the MessageBox:
Note |
|---|
|
This approach also records all messages passing through the default XML pipeline.
|
-
Start HAT and then select Configuration | Pipelines.
-
Select Microsoft.BizTalk.DefaultPipelines.XMLReceive and select the "Inbound and outbound message bodies" check box under "Select the events and data to be tracked."
-
Select Microsoft.BizTalk.DefaultPipelines.XMLTransmit and select the "Inbound and outbound message bodies" check box under "Select the events and data to be tracked."
Having performed the above configuration changes, message bodies will now be available to be saved within HAT.
-
To view the message body, locate the message in HAT and right-click Save all tracked messages.
Two files are produced for each message saved. The XML file contains the context properties of the message (internal message ID, send location, and so on). The .OUT file contains the actual message.
Be aware that messages may not be available for up to a minute after sending, because a SQLAgent job runs once a minute to make message bodies available. If the SQLAgent is not running, the message bodies will not become available. Messages that passed through BizTalk Server prior to the configuration change to save message bodies will not be available (because the message body was not recorded).
Business Monitoring with HAT
It is worth noting here that HAT can also be used for business operations monitoring as well as the developer-based tasks described above. It is common to set up saved queries that display key indicators. For example, creating a saved query that lists the number of a specific business transaction within the last hour can act as a simple method of monitoring for unexpected behavior (for example, zero messages in 24 hours may suggest a transport failure in an upstream system).
Working with Suspended Messages
This section addresses the handling of suspended documents that need to be edited and resubmitted. This can often happen when a malformed message is sent into the integration solution. This section provides an outline of how messages could be accessed, modified, and sent back into the system.
Subscribing to Events
BizTalk Server provides scriptable management capability via Windows Management Instrumentation (WMI) classes. These classes are used to programmatically access the administrative functions available in Microsoft BizTalk Server 2004.
BizTalk provides a WMI Event, MSBTS_ServiceInstanceSuspendedEvent. You can set up a listener to take action when a message is suspended. The following code fragment provides an example of how to listen for these messages:
string scope = "root\\MicrosoftBizTalkServer";
string wqlQuery = "Select * from MSBTS_ServiceInstanceSuspendedEvent";
watcher = new ManagementEventWatcher(scope, wqlQuery);
watcher.EventArrived += new EventArrivedEventHandler(onEvent);
watcher.Start();
This code fragment assigns an event handler that can take action when an event is fired. There is also another event, MSBTS_MessageInstanceSuspendedEvent, but this only occurs for a BizTalk Message Queuing (MSMQT) message instance.
Write Suspended Messages to File
The event that is called when suspended messages occur can be used to write out the message to a file using another built-in BizTalk method, MSBTS_MessageInstance.SaveToFile. The following code provides a snippet of saving a message to file. After messages are saved off, they can be consumed by another receive location.
public void onEvent(object sender, EventArrivedEventArgs e)
{
// Before calling the following code, query and return all the messages instances
// associated with the particular service instance that was suspended.
// Construct full WMI path to the MSBTS_MessageInstance using the message guid
string strInstanceFullPath = "root\\MicrosoftBizTalkServer:MSBTS_MessageInstance.MessageInstanceID='{" + MessageInstanceId.ToString() + "}'";
// Load the MSBTS_MessageInstance
ManagementObject objSvcInst = new ManagementObject(strInstanceFullPath);
// Invoke "SaveToFile" method to save the message out into the specified folder
objSvcInst.InvokeMethod("SaveToFile", new object[] {strOutputFolder});
}
Developing
When developing BizTalk Server 2004 solution orchestrations for the first time there are several key concepts and techniques it helps to understand. These concepts are sometimes not immediately clear from the product documentation and so are listed below. This is not an exhaustive list but represents some of the common topics that are helpful to a new BizTalk Server 2004 developer.
-
Messages are absolute in BizTalk Server. This means that after a message has been created (or received by BizTalk Server) it cannot be changed or modified. To modify a received message it is required to create a new copy of the message.
-
Why do Message Construct shapes exist? As mentioned, messages are immutable. This raises the obvious question, when creating a new message, at what point does it become immutable? The short answer is that the message is immutable after the Message Construct shape that created it is complete. All new messages must be created in a Message Construct shape that specifies the message instance to be created. When this shape completes, the message becomes immutable.
-
How do I create new messages? It is not possible to simply perform a "create new instance of a message type X" within an orchestration. The reason for this is the complexity of determining how to populate an instance of a message (especially when the message may contain optional or repeating structures). In practice it is possible to create new messages by using the following approaches:
-
A map with destination schema of type X, but no links
-
Call custom .NET code that uses the document object model to create a new message instance
-
In an expression shape, instantiate the XML Document Object Model (DOM) and create a simple message using strings to populate the DOM
All the above must take place inside of a Message Construct shape.
-
How can I create arrays within an orchestration? Orchestrations cannot handle arrays. If the orchestration needs to create in an array (for example, construct an array of facts/documents for sending to a policy in the Business Rules Engine), define a variable of type System.Collections.ArrayList.
The following code shows how to create arrays within an orchestration from the Business Rules Framework Programmers Guide:
Declare an orchestration variable FactsArrayList of type System.Collections.ArrayList and mark it as created using the default constructor.
FactsArrayList.Add(Doc1)
FactsArrayList.Add(Doc2)
Policy = new Microsoft.RuleEngine.Policy("ValidateSalesOrder");
Policy.Execute(FactsArrayList.ToArray());
-
How do I get and use file names within an orchestration? In your orchestration, create an expression and store the message context property value in a variable with code that is similar to the following:
//CreditCardApplicationInfoMsg is the name of your instantiated incoming message. fname is just a variable that you declare.
fname = CreditCardApplicationInfoMsg(FILE.ReceivedFileName);
To modify the outgoing file name, use the %SourceFileName% macro in the send port and modify the FILE.ReceivedFileName property in an expression shape.
-
How do I use the reserved word "message"? "Message" is a reserved word. Often the name "message" is in schemas and needs to be referenced in an expression. Since "message" is a reserved keyword for orchestrations, it is necessary to delimit (prefix) it with the "@" character, as follows:
This approach is valid for any reserved word that needs to be referenced in a message.
-
Can messages be split? Messages can be split by using an envelope. There is a sample in the SDK, under <Samples Path>\Pipelines\AssemblerDisassembler\EnvelopeProcessing\. Alternatively, you can search on "EnvelopeProcessing (BizTalk Server Sample)" in BizTalk Server 2004 Help.
-
What is valid in the orchestration expression shape? The following list provides rules for valid orchestration expression shapes:
-
"if" and "while" statements are handled by the decision shape. You cannot put an "if" or "while" into an expression shape.
-
Comments work fine, but you need at least one statement in the expression box.
-
Simple types (integer, string, floating point) cannot have the dot operator applied to them (that is, there is no member access).
-
For non-simple types, you can only access public member functions and properties and static literal fields.
-
Compound assignments (+=, -=, *=, etc) are not supported.
-
More than one assignment operator in a statement is not supported.
-
Assignment within an "if" or "while" predicate is not supported.
-
Increment and decrement are not supported (++, --).
-
For message parts, the only member access allowed is on distinguished fields.
-
Indexers or parameterized properties are not supported.
-
Delegates and events are not supported.
-
For each, for, do/while, break and continue are not supported.
-
Why is it important to serialize .NET assemblies? BizTalk Server 2004 orchestrations can be dehydrated to SQL Server during their execution when they meet certain conditions (such as waiting for a message and Delay shapes). This allows the BizTalk runtime to flush inactive orchestrations out of memory, thus improving scalability and performance.
It is recommended that any .NET assemblies being called from BizTalk Server be marked as Serializable to facilitate this wherever possible. If it is not possible (for example, due to the assembly being from a third party), you must invoke these assemblies from within an Atomic Transactional scope.
If you can mark your assembly as Serializable then you do not need to follow these steps:
-
Right-click your orchestration surface and click Properties.
-
Change the Transaction type to "Long Running."
-
Drag a scope onto the orchestration and configure it to be a transaction type of Atomic. This tells BizTalk Server that any operations within this scope cannot be interrupted.
-
Place the usage of the non-serializable .NET assemblies within this scope.
-
How can I get and set file names within an orchestration? You can also use the FILE.SourceFileName property for reading and redefining the file name to be used on output. Use the macro %SourceFileName" in the file transport.
Outputting Debug and Trace Information
When developing orchestrations it is important to be able to understand the status of an orchestration both during and after execution. HAT provides the capability to view the flow of an orchestration after it has completed and to place a breakpoint within an orchestration (see "Health and Activity Tracking" under "Operations" in the product documentation for more details). Although HAT is effective, it can also be useful to develop orchestrations that write out debugging information as they run.
One of the techniques most commonly used when developing debugging traditional code is to write out useful data during code execution to allow observation of the data and processes that are actually executing. The same functionality can be achieved in BizTalk Server 2004 orchestrations by using the following technique.
Within the .NET class library, the System.Diagnostics.Trace class allows the outputting of trace and debug information to listeners, which can capture and log the information. It is possible to write listeners using .NET code (see "Debug Class" in the .NET documentation), but it is also possible to use readily available utilities.
One such utility is DebugView, which is a freeware utility available from SysInternals at http://go.microsoft.com/fwlink/?LinkId=43665.
When DebugView is running, it will catch and log the output of any debug statements, allowing the developer to view progress and actual data within the process. Note that debug statements also exist within other Microsoft applications (including BizTalk Server 2004), so expect to see debug output from other applications too.
The following steps describe how to output a hard-coded string containing a process name and version number:
-
In Visual Studio .NET, open an existing orchestration that can successfully be deployed and executed.
-
Create a new expression shape below the start shape of the orchestration.
-
Edit the expression as follows:
System.Diagnostics.Trace.WriteLine("Entering Orchestration)");
-
Compile, deploy, and start the orchestration as normal.
-
Start DebugView or an alternative debug listener.
-
Activate the BizTalk Server process and observe the output in DebugView as the orchestration is started by the BizTalk Server runtime.
Output Assembly Version to Aid Tracing, Debugging, or Exception Handling
It can be useful to have orchestration output information about the assembly that is currently running. The following example code displays information about the current assembly. You can use the example code during development to provide a generic approach to listing assembly information. This sample writes to the event log rather than to a trace or debug listener.
-
Within an orchestration add the following variables:
var_Assembly of type System.Reflection.Assembly
var_AssemblyName of type System.Reflection.AssemblyName
var_version of type string.
-
Within the same orchestration add the following to an expression:
var_Assembly = System.Reflection.Assembly.GetExecutingAssembly();
var_AssemblyName = var_Assembly.GetName();
var_Version = var_AssemblyName.Version.ToString();
System.Diagnostics.EventLog.WriteEntry("BTS Sample", "Version is: " + var_Version);
//Must set .net types to null to prevent attempted serialization if the orchestration dehydrates.
var_Assembly = null;
var_AssemblyName = null;
Debugging Message Content from an Orchestration
The trace.writeline technique described above can also be used to write out the contents of messages and variables at run time. This can be extremely useful when working with complex orchestrations, for example, multi-map transformations where it would normally not be possible to observe the intermediate messages produced by maps inside the orchestration.
The following procedure describes how to write out the contents of a populated orchestration message (named myMsg) to a debug listener:
-
Within an orchestration add the following variables:
myString declared as an orchestration variable of type 'string'
xmlDoc declared as an orchestration variable of type 'xmlDocument' (type found under .Net classes, System.XML)
myMsg is the orchestration message whose contents are to be output
-
Convert the message into a string and output the string in an expression block by adding the following expression to an expression shape:
xmlDoc = myMsg; //create XML doc from the BTS message
myString = xmlDoc.OuterXml; //get a string representation of the XML
System.Diagnostics.Trace.WriteLine(myString); // output the string
-
Run the orchestration with a debug listener running. The XML representation of the message will be output.
It is also worth noting that it is possible to perform the reverse of the "Message to string" operation and create a BizTalk Server 2004 message with an XML string.
To convert the string back to a document in a message construct, use the following code:
xmlDoc.LoadXml(myString);
myMsgFromString = xmlDoc;
To achieve this, the following requirements are necessary:
-
The orchestration message myMsgFromString must be defined as having a type derived from a valid schema.
-
The XML being assigned to the message should conform to the schema of the message.
-
The expression shape needs to be enclosed within a message assignment shape, which is explicitly creating message myMsgFromString.
Debugging Maps
Viewing the map output is an important step when testing maps. The resulting XML produced by the map is saved to disk, even if the output is not valid according to the destination schema. Examining this output can be valuable in understanding why the output of the map is not valid.
Compare the resulting output XML against the schema definition to determine why the error is occurring. The map output document can be seen by looking in the temporary location for the output of a map, for example:
C:\Documents and Settings\<username>\Local Settings\Temp\_MapData
The output document is also available by CTRL-clicking the file name in the output window after a performing the test map operation.
Using Map XSLT to Aid Map Debugging
When developing maps, if map links or functoids do not seem to be producing the expected output or are producing errors, then consider examining the XSLT to work out what node data is being processed and where the results are being written. The XSLT is produced when validating a map and it represents the actual mapping that the BizTalk Server 2004 runtime will perform. By reading the generated XSLT it is sometimes possible to observe the reason that a map is producing unexpected output.
The XSLT is usually quite simple to follow, typically consisting of many simple XPATH queries. By reading the XPATH statements it is often possible to clearly see the input values and any operators followed by the nodes in which the output is written.
The XSLT is produced during a map validation and is located at
C:\Documents and Settings\<username>\Local Settings\Temp\_MapData
Debugging Custom .NET Methods Within the Scripting Functoid on a Map
BizTalk Server 2004 supports the creation of maps that use the scripting functoid. Users can create their own .NET methods and use them from within the scripting functoid to allow better reuse of custom code and functionality. Debugging these functions when testing a map can be very useful to determine if your custom map functions are working properly, but the steps to debug these custom assemblies are not obvious. Here are the steps you need to take to directly debug your scripting assembly while testing your map:
-
Open your assembly class in its own Visual Studio .NET development environment. Build the assembly normally, making sure that the build is in debug mode and a symbols file is created.
-
Deploy your custom assembly to the global assembly cache normally. Make sure you deploy the version in bin\debug.
-
Open up your BizTalk project in a second Visual Studio .NET development environment, reference your custom assembly DLL in the same directory above, and configure your scripting functoid as normal (you should see it as a choice in the list of available assemblies).
-
Return to your custom assembly environment, and under processes, attach to your BizTalk DEVENV process. Initially, when you set a breakpoint, the environment will say "symbols not loaded". This is normal, because the assembly is not loaded until it is actually invoked by the mapper.
-
Return to your BizTalk project and test the map (using right-click, Test Map). If you watch your assembly environment the symbols get loaded and the "?" goes away, at which time your breakpoint should hit.
-
Debug in the normal fashion. Your breakpoint will be hit every time the functoid is called.
Error: "Map contains a reference to a schema node that is not valid"
This design-time error can occur when the map being opened uses a project dependency for one of its schema. If this error occurs ensure that the dependency has been recompiled to reflect any recent changes.
To understand why this error arises, consider the following scenario:
-
Project Y references project X. Project Y uses schema X which are contained in Project X.
-
The schema information used by the map editor in Project Y is actually contained within the compiled DLL produced by project X.
-
This means that if the DLL from project X is deleted then the maps in project Y will not compile until project Y's DLL is recompiled.
This is significant when Visual SourceSafe is being used to store projects. Visual SourceSafe does not store DLLs by design, and when retrieving a BizTalk project containing schema the project will need to be recompiled to produce the DLLs that dependent projects need.
Error: "Element cannot contain text or white spaces. Content model is empty"
This runtime error can occur when using Complex Content elements (like <ANY> or <SEQUENCE>). Complex content elements are not allowed to contain text unless their 'Mixed' property is set to 'True'.
For example, if the schema uses complex content elements, the XML <Root> </Root> (note the space between the nodes) will produce the above error. The XML <Root/> will not because no white space exists. To avoid this error set the Mixed property of the root node of the schema to true, as shown in the following figure.
Figure 8 Schema root node mixed property
Debugging Adapters and Pipelines
You can debug adapters by using a similar approach to that outlined in the preceding section. Be aware that although adapters do not need to be in the global assembly cache for the runtime to find them, they do need to be in the global assembly cache for Visual Studio .NET to find them when debugging. Make sure that adapter assemblies are in the global assembly cache before attaching to the BTSNTSvc.exe to debug them.
Debugging Web Services Called by BizTalk Server
A common integration requirement is to a call a Web service from the orchestration, and then debug the Web service to determine the functionality taking place within the Web service when called from BizTalk Server 2004. The following steps describe how to debug this scenario. The orchestration is shown in the following figure. It receives a message from the MessageBox, transforms it into the message expected by the Web service, sends it to the Web service, and receives a response.
Figure 9 Orchestration calling a Web service
To debug the Web service, perform the following steps:
-
Open Visual Studio.
-
Open the solution (or project) that contains your Web service.
-
Set the breakpoint (in our example we set it at line 86).
-
On the Debug menu, click Processes. The Processes dialog box appears.
Figure 10 Process dialog box
-
Select aspnet_wp.exe (The ASP.NET worker process represents the ASP.NET runtime environment. It consists of a Win32® unmanaged executable named aspnet_wp.exe, which hosts the .NET common language runtime (CLR). This process is the executable you need to attach to in order to debug ASP.NET applications.)
-
Select Attach. The Attach to Process dialog box appears.
Figure 11 Attach to process dialog box
-
Select Common Language Runtime and then click OK.
The Attach to Process dialog box closes.
-
In the Processes dialog box, click Close.
The Web service is now ready to be debugged. Send the message to the orchestration and Developer Studio will stop at the breakpoint.
Debugging Pipelines
Pipeline assemblies are often used in BizTalk Server 2004 solutions to provide special handling of files before they are sent into or out of the BizTalk MessageBox. Debugging pipeline assemblies in Visual Studio .NET is critical in order to quickly troubleshoot and fix problems.
Copying and Debugging Assemblies
After you build the pipeline assembly successfully, you will need to copy the files to the "Pipeline Assemblies" directory in the BizTalk Server installation directory (C:\Program Files\Microsoft BizTalk Server 2004\Pipeline Assemblies). If you are updating an assembly that has already been installed and you cannot copy over the existing assembly there are two possible causes:
-
BizTalk process may have the assembly in use. First stop and start the BizTalk service before copying over the existing assembly.
-
A BizTalk project with a pipeline that uses your assembly may have it in use. The Visual Studio .NET IDE may be using the design-time aspects of the pipeline assembly. To release it, close Visual Studio .NET. (It may be necessary to close all instances, not just the pipeline project.)
After the file has been copied, attach to the BizTalk process as follows:
-
With the pipeline assembly project open, on the Tools menu, click Debug Processes.
-
From the Available Processes list, select the BizTalk Server process (BTSSvc.exe) and click Attach.
-
In the Attach to Process dialog box, in the "Choose the program types that you want to debug" list, select Common Language Runtime is selected.
-
Click OK.
-
Click Close.
Note |
|---|
|
After a changing a pipeline, the BizTalk Server 2004 runtime does not pick up the change until it refreshes its configuration. To test the changes immediately, recycle the appropriate hosts (using recyclehosts.vbs as described in Table 20 under "Redeployment Scripts").
|
Note |
|---|
|
If the "redeploy" option is set to true this allows a modified pipeline to be redeployed without undeploying a previous version. However be aware that this redeploy action resets any send or receive ports that used this pipeline to "PassThrough". After the redeploy it is necessary to reassign the port to the custom pipeline.
|
Helper Classes
It can be useful to include helper classes within a BizTalk project to perform business logic tasks or functions that aid the development process. A typical task of a developer helper class would be to write messages out to the file system to aid debugging and diagnostics.
Included in samples is a template of a general BizTalk Server helper class that manipulates messages. It provides limited functionality to aid the debugging of messages, including a "DumpMessageToFile" function that writes a BizTalk Server message to the file system.
This sample can be modified to handle more complex functionality. To use the sample within a BizTalk project complete the following steps:
-
Compile the project.
-
Copy GeneralHelper.dll to a permanent location on the local file system.
-
Add the DLL to the global assembly cache so it is visible to the BizTalk Server runtime using:
GACUTIL /I GeneralHelper.dll
-
Add a reference to the GeneralHelper.dll in the orchestration project.
-
Within an expression shape in an orchestration use the following syntax:
DebugHelper.Utils.DumpMessageToFile(<MessageName>,"<path>","<filename>",<timestamp>);
<MessageName>: String, Name of the BizTalk Server message in the orchestration to be written out
<path>: String, Path for file to be written to, with backslashes denoted with "\\"
<filename>: String, Filename for the resulting file
<timestamp>: Boolean, prepends a timestamp to the filename to create quasi-unique filenaming for messages
Another Example:
DebugHelper.Utils.DumpMessageToFile(AccountUpdateIncoming,"c:\\tmp"," AccountUpdateIncoming.xml",true);
Useful Development Tools
The following tools are useful to have available within the BizTalk Server 2004 developer's environment:
-
BizTalk 2004 Management Tool. This stand-alone tool provides functionality similar to the BizTalk Explorer capabilities in Visual Studio .NET, and as such is an extremely useful tool when configuring or debugging a server environment that does not have Visual Studio .NET available. The tool enables the user to manage assemblies, orchestrations, ports, deployment, and messaging. You can download the BizTalk 2004 Management Tool from the GotDotNet Workspaces Web site at http://go.microsoft.com/fwlink/?LinkId=44998.
-
BizTalk Server 2004 Configuration Documenter. This tool runs against the Configuration database of a BizTalk Server 2004 group and documents the configuration of all the deployed BizTalk Server 2004 solutions within the group. This tool can be extremely useful in documenting and validating deployments, and it also provides a basis for solution documentation. You can download BizTalk Server 2004 Configuration Documenter from the GotDotNet Workspaces Web site at http://go.microsoft.com/fwlink/?LinkId=44999.
-
DebugView. This tool is described in the debugging sections. You can find the DebugView tool on the SysInternals Web site at http://go.microsoft.com/fwlink/?LinkId=43665.
-
TCPTrace. TCPTrace provides the ability to view and log the data flowing between TCP ports. When using BizTalk Server 2004 and the HTTP or SOAP protocols, it can be extremely useful to view the actual data flowing between systems and the integration layer. By configuring TCP to act as a proxy between the integration layer and an application it is possible to capture HTTP and SOAP messages and then examine the schema and content of these messages.
You can download the TCPTrace tool on the Pocket SOAP Web site at http://go.microsoft.com/fwlink/?LinkId=43666.
-
Windows Explorer BizTalk Server Extension. The Windows Explorer BizTalk Server Extension tool is part of the BizTalk Server 2004 installation process, but by default is not registered. To register the tool, close all instances of Internet Explorer and run the following command from the command prompt:
regsvr32 "c:\Program Files\Microsoft BizTalk Server 2004\Developer Tools\BtsAsmExt.dll
This tool adds a BizTalk Server search pane to the standard Windows Explorer. You can access the new pane from the folders bar or by using the Windows Explorer View menu, pointing to the Explorer bar, and clicking BizTalk Server Search.
This tool also allows you to search across the deployed assemblies for any of the BizTalk artifacts and to view detailed information about the artifacts found. The following figure shows the location of the tool.
Figure 12 BizTalk Server Extension tool
-
BizTalk Server Documentation Tools. See "Documenting BizTalk Server 2004 Systems" for more information about these tools.
-
ASP HTTP Test Stub and Test Harness. Two simple ASP pages are included in the samples with this document and include the following resources:
-
A test harness to POST an XML message to an HTTP URL and display the response.
-
A test stub to provide an XML response (taken from an XML file) to an HTTP GET request.
These simple ASP files are designed to provide easy-to-modify templates to create test stubs and harnesses. You can find the ASP files in the samples folder called "XML HTTP Test Stub and Test Harness."
-
ASP.NET HTTP Test Stub and Test Harness. You can find an ASP.NET base test stub and harness in the samples folder. This test tool allows you to simulate the source and target application to perform end-to-end testing. The source application initiates the business process by posting data to the receive location of the BizTalk Server and waits for the response from the BizTalk Server. The business process then submits the data to the target application by using the "Solicit Response" port and listens for the response from the target application.
This ASP.NET application provides the same functionality as the ASP version, but could be significantly extended by using further .NET functionality to meet project requirements. The following figure shows operations that you can perform with the stub and harness.
Figure 13 ASP.NET stub and harness operations
You can find the ASP.NET HTTP test stub and test harness tools in the samples folder under "ASP.NET HTTP test stub and test harness."
Additional BizTalk Server 2004 tools are currently being collected on the Web under the collective name of "BizTalk Server 2004 Power Toys," and a search for these may reveal more useful tools. BizTalk Server 2004 tools were also written for the Microsoft "BizTalk Tools Competition" in September 2004, and these can also be found by searching the Web.