Repost – BizTalkRocks ‘Debugging Tips and Tricks’ Webcast

This post disappeared from a previous blog of mine so I'm reposting it.

 

'Thank you' to everyone who attended the Debugging Tips and Tricks webcast that I presented today for the BizTalkRocks community.  You can find the presentation at http://www.msnusers.com/BizTalkRocks/Documents/Debugging%20Tips%20and%20Tricks.zip

 

I recorded the webcast.  I will repost this article and include a link to the recorded webcast when it is posted.

 

If you have any questions on the presentation or the webcast please contact me through the Contact link on this blog.

 

Update (12/9/05): I think I skipped a slide yesterday. If you download the presentation, search for 'BizUnit' to find another 'Other Tools…' slide.  Sorry about that.

Repost – IIS 6.0, Integrated Windows Security, Application Pools with Domain Accounts and ’The target principal name is incorrect’

This post disappeared from a previous blog of mine so I'm reposting it.

 

A couple of weeks ago I was having difficulty turning on Windows Integrated security for a couple of virtual directories that were interfaces to the SOAP and HTTP adapter.  I initially had Anonymous and Integrated Windows turned on.  As soon as I turned off anonymous and left only Integrated Windows security turned on I would get prompted to enter my credentials.  After three failed attempts to login I would get the following error message: ‘HTTP Error 401.2 – Unauthorized: Access is denied due to server configuration.’

 

I assumed that I didn’t have the ACLs properly configured on the directories and files that the virtual directories managed but after reviewing their configuration everything checked out.

 

I stumbled across a reference to AuthDiag, a new tool from MS that helps you troubleshoot authentication and authorization issues with IIS 5.x and 6.0.  I installed the tool, ran the ‘Check Authentication’ test on the virtual directories and quickly discovered that my issues had something to do with the fact the identity for the application pools that my virtual directories were running in wasn’t configured properly.  Auth Diag kept giving me a failure with the message ‘Service principal name (SPN) for user xx\yy not found in Active Directory’ where xx was the domain and yy was the user name for the account I was using as the application pool identities.  (As you probably know, if you have multiple BizTalk Servers in your BizTalk Group then you must use domain accounts for you host instance credentials and I was using the same account for the application pool identities.) 

 

After a suggestion from a colleague, I switched the identities for the application pools to a local account (Network Service) and the prompt and 401 immediately went away.  Of course the requests couldn’t make it into BizTalk because the local Network Service Account didn’t have the permissions to reach the BizTalk MessageBox database.

 

Another colleague suggested using wfetch.exe, part of the IIS 6.0 Resource Kit to help debug my issue.  I ran wfetch.exe using NTLM (for the ‘Auth’ value in the ‘Authentication’ group box) and could access the virtual directories without problems.  However, when using either Kerberos or Negotiate I saw the following error message in the response from the IIS: ‘0x80090322 (The target principal name is incorrect.): Unable to InitializeSecurityContext’.  This article describes the differences between these three options although it describes these in the context of the IIS authentication and not wfectch.exe

 

I was stumped until I found the Configuration Application Pool Identity in the IIS 6.0 documentation.  According to that page, there are issues with using Kerberos (which may be used when you use Integrated Windows Security.)  The solution to my problem was that I needed to run the setspn.exe tool in order to set a Service Principal Name (SPN) on the account configured as the Identity for the application pools.  We ran setspn.exe using the machine name and the machine’s fully qualified domain name, and the issue immediately went away:

 

setspn -A HTTP/servername domain\account

setspn -A HTTP/servername.fullyqualifieddomainname domain\account

 

You can find the setspn.exe tool on the Windows 2003 CD-ROM or .ISO at \support\tools\suptools.msi

 

One thing to note about setspn.exe is that you must be a domain administrator, of the domain that the account is in, that you use as a parameter to setnspn.exe (which is also the account you are using for the application pool identity.  There is a note here (click on the ‘Troubleshooting Setspn’ link) that says the permission necessary for running the setspn.exe can be delegated.

 

In summary, you must ex

Repost – BizTalk 2004 Developer Workstation Installation Tips

This post disappeared from a previous blog of mine so I'm reposting it.

I've installed BizTalk 2004 on a developer workstation several times at this point.  For a developer workstation I recommend the following:

1) If you do 'regular' ASP.NET development on your workstation and you will continue to do so after installing/configuring BizTalk then when you are configuring Windows SharePoint Services (WSS) do not configure it to use your default website.  Create a second website in IIS and point to this site during WSS configuration (and later during BizTalk configuration point to this site instead of your default web site for the BAS site location.)  If you don't do this you will have to put your ASP.NET applications on a second website that doesn't run on port 80 or you will have to configure WSS to not 'apply' to each Virtual Directory that you want to use for ASP.NET applications.

2) I have never succesfully been able to create the WSS configuration db from the WSS configuration wizard.  I always get an access denied error when it tries to create the configuration database, complaining about NT Authority\Network Service not having appropriate access to the database (or something like that.)  Instead, I create the WSS configuration database prior to configuring WSS using the Using the Command Line to Create or Connect to a Configuration Database section of the Administrator's Guide for SharePoint Services.  This section describes how you can use the following command to create the config database:

stsadm -o setconfigdb -ds -dn

You can then point to the database you created with stsadm during the WSS configuration.

Repost – Reusing the BizTalk Server 2004 Schema Generator Wizard’s Library

This post disappeared from a previous blog of mine so I'm reposting it.

I've been doing some research on custom adapter development and one of the issues that came up was figuring out how to do the schema generation.  BizTalk Server 2004 includes a wizard that will generate schemas from Xml instance documents.  I decided to figure out how it worked – and if it could be reused.

 

It is possible to reuse this functionality.  Here's how you do it:

 

  1. Create a console project.
  1. Reference the Microsoft.BizTalk.WFXToXSDGenerator.dll and XSDInfer.dll assemblies in the [installDir]\Microsoft BizTalk Server 2004\SDK\Utilities\Schema Generator directory. 
  1. Reference the Microsoft.BizTalk.SchemaEditor.Extensibility.dll assembly in the [installDir]\Program Files\Microsoft BizTalk Server 2004\Developer Tools directory.
  1. Pull in the Microsoft.BizTalk.WfxToXSDGenerator namespace.
  1. Add the following code to your Main method:

 

WfxToXSDGenerator gen = new WfxToXSDGenerator();

 

gen.GenerateSchema(args[0], args[1]);

 

object[] warnings = gen.Warnings();

object[] errors = gen.Errors();

object[] schemas = gen.ReferencedSchemas();

 

if(warnings.Length != 0)

{

Console.WriteLine("Warnings were found:");

 

          for(int i = 0; i < warnings.Length; i++)

          {

        Console.WriteLine(warnings[i].ToString());

          }

 

          Console.ReadLine();

          return;

Repost – Preparing to Take Your BizTalk Server 2004 Application to Production

 

This post disappeared from a previous blog of mine so I'm reposting it.

Are you read to take your BizTalk Server 2004 application to production?

 

Integration applications are usually very complex; they have a lot of moving pieces, they use many different technologies and they are often built to automate processes that are not understand nearly as well as the business units involved think they are understood.  In addition to the technical problems related to integration applications, integration problems have a corresponding set of issues centered around communication difficulties.  Often these communication difficulties arise because the different teams involved in the project do not understand ant technologies other than their own, because people of various technical levels are involved in project and because project teams do not reside at the same physical location.

 

Because of these complexities it is easy to overlook items that should be handled prior to your BizTalk Server 2004 application going live.  The article contains suggestions for items you should resolve prior to going live.

 

Deployment

  • Is your deployment automated?  Fully automated?
  • Have you defined your rollback procedures?

 

Application Architecture Review

  • Have you covered all of your error handling scenarios from you requirements?
  • Will HAT provide all of the necessary debugging, process analysis and replay requirements for your application?  If not you may need to
  • Database recovery, backups, failover, etc.
  • Logging – where, how, when?
  • How are you going to monitor you application and environment?  What happens after hours?  Have you considered Microsoft Operations Manager?
  • How are you going to implement notification?  Who gets notified?  When?  Will you filter so that you don't send out notifications for each and every BizTalk related event log entry?
  • Will you have enough information to debug your problems (they will occur!)?

Repost – Adding to ‘Knowing which BTSNTSvc.exe to attach to…’

This post disappeared from a previous blog of mine so I'm reposting it.

 

A couple of weeks ago I wrote a short article about an ‘easy’ method of determining the correct BTSNTSvc.exe process to attach to in VS.NET in order to debug orchestration utility components.  Scott Colestock described a better way to determine this here.

 

I liked his method much better than mine but I didn’t want to have Perfmon open whenever I needed to find the correct process id.  I took his suggestion one step further and created a simple console application that writes out the process ids of all started, in-process host instances.  Here are the steps to create (using C#) and use this simple application:

 

  1. Create a new .NET console application.
  2. Add a reference to System.Management.dll
  3. In the class that contains your main() method add using statements for:
    1. System.Diagnostics
    2. System.Management
  4. Add the following code to the main() method:

 

                  //Enumerate all HostInstances of "InProcess" type

                  try

                  {

                        //Create EnumerationOptions

                        EnumerationOptions enumOptions = new EnumerationOptions();

                        enumOptions.ReturnImmediately = false;

 

                        //Search for all HostInstances of 'InProcess' type in the Biztalk namespace scope

                        ManagementObjectSearcher searchObject = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer","Select * from MSBTS_HostInstance where HostType=1 and ServiceState=4",enumOptions);

 

                

Repost – Orchestration Engine – ‘AppDomain configuration’ Default Values

This post disappeared from a previous blog of mine so I'm reposting it.

One may get the impression, based on the example configuration listing for 'AppDomain configuration' in the BTS docs (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdk/htm/ebiz_prog_orch_jzex.asp), that the Orchestration Engine's default values for SecondsIdleBeforeShutdown and SecondsEmptyBeforeShutdown are 1200 and 1800, respectively.   The example configurations are so plagued with errors that I investigated a bit further.

In the Microsoft.XLANGs.BizTalk.CrossProcess.AppDomains constructor (in the Microsoft.XLANGs.BizTalk.CrossProcess assembly),
the default values are set to the reverse:

SecondsIdleBeforeShutdown = 1800 (30 minutes)
SecondsEmptyBeforeShutdown =  1200 (20 minutes)

Obviously these values could be reset to something other than their default values by code that executed after the constructor but it does appear that the default values are reversed in relation to the example's configuration.

In case you are not familiar with the settings here is a snip from the referenced page in the BizTalk docs:

"In this section the user may specify default configuration for any app domain created that does not have a named configuration associated with it (see AppDomainSpecs below) SecondsEmptyBeforeShutdown is the number of seconds that an app domain is empty (that is, it does not contain any orchestrations) before being unloaded. Specify -1 to signal that an app domain should never unload, even when empty. Similarly, SecondsIdleBeforeShutdown is the number of seconds that an app domain is idle (that is, it contains only dehydratable orchestrations) before being unloaded. Specify -1 to signal that an app domain should never unload when idle but not empty. When an idle but non-empty domain is shut down, all of the contained instances are dehydrated first."

I encourage you to review all of the Orchestration Engine settings on the referenced page; many of them are very useful.

Repost – Don’t Forget the XPath string() function

This post disappeared from a previous blog of mine so I'm reposting it.

When using the xpath() function in the orchestration designer you may need to obtain the value from a single node (I'm distinguishing between trying to obtain the node vs. the node's value.)  If you are attempting to do this, please don't forget to wrap your xpath statement with the xpath string function, for instance:

 

myStringValue = xpath(myMessage, "string(/*[local-name()='MyElement' and namespace-uri()='']/@*[local-name()='MyAttribute' and namespace-uri()=''])");

 

If you forget to do this your variable (in this case myStringValue) will have a value of null and depending on your usage of that variable later on in your orchestration you may end up with an exception.

Repost – VS.NET 2003 Xml Decode/Encode Macros

This post disappeared from a previous blog of mine so I'm reposting it.

I've been working with a third-party database adapter that returns encoded Xml in some cases.  BizTalk handles the decoding just fine but when I have problems with the adapter it can be problematic to examine the encoded documents.  After a few days of dealing with this I put together a couple of VS.NET macros for encoding/decoding Xml which I'm sure people can find other uses for.

 

Here's how you can create these macros:

 

  1. Open VS.NET.
  1. View the Macro Explorer.
  1. Copy and paste the code snips, below, into appropriately named macro module (I created a new Macro Module and named it XmlHelpers.)
  1. Make sure you add a reference to System.Web in the macro editor for the macro module you just pasted the code snips into.
  1. Add an Imports statement for System.Web
  1. Save the macro.
  1. Select an Xml fragment in the editor that you would like to encode or decode.
  1. Double-click the XmlEncode or XmlDecode macro in the Macro Explorer.
  1. Note that it is actually using the System.Web.HttpUtility.HtmlEncode/HtmlDecode functions.

 

Here are the snips:

 

Sub XmlDecode()

Dim theTextSelection As TextSelection = DTE.ActiveDocument.Selection

Dim actualText As String = theTextSelection.Text

 

theTextSelection.Delete()

theTextSelection.Insert(HttpUtility.HtmlDecode(actualText))

End Sub

Sub XmlEncode()

Dim theTextSelection As TextSelection = DTE.ActiveDocument.Selection

Dim actualText As String = theTextSelection.Text