BizTalk Best Practices | Tip and Tricks

Below is a list that needs to be remembered when developing BizTalk solutions.

BizTalk Orchestration:

XPath Expressions: 1. To do an XPath count:


countVariable = System.Convert.ToInt32(xpath(yourMsg, "count({XPATH Instance path,can be copied from Schema})"));

2. To extract a value using XPath (string):

stringVar = xpath(yourMessage, "string({XPATH Instance path,can be copied from Schema})")

BizTalk WCF-SQL Adapter:

When confronted with the problem about MSDTC issue, either due to cross domain or the actual MSDTC being disabled this adapter will still work by just setting the useAmbientConnection to FALSE

BizTalk mySAP Adapter:

1. RFC/BAPI function not returning any result.

When expecting a response from SAP via RFC or BAPI you always need to supply an empty node wherein you’re expecting a result. For example if the field is under the T_QAIVCTAB, in the mapping you need to generate this field by mapping a scripting functoid that returns empty string.

2. Set EnableSafeTyping to True

To avoid nasty data type issue when sending/receiving a response set this value to true in your binding. Data type error: An error occurred when trying to convert the byte array [30-00-30-00-30-00-30-00-30-00-30-00-30-00-30-00] of RFCTYPE RFCTYPE_DATE with length 8 and decimals 0 to XML format. Parameter/field name: Error message: Year, Month, and Day parameters describe an un-representable DateTime. —> System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime. at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day) Configuration: Schema Generation: During the schema generation (WCF Consume Adapter Service) also set the Enable Safe Typing to TRUE.

3. BAPI_SALESORDER_SIMULATE.

– Be sure to pad the material number with leading zeroes up to length of 18.

public string PadMaterialNumber(string s)
{
string val = s.PadLeft(18, ‘0’);
return val;
}

BizTalk Mapping:

Microsoft.XLANGs.Core.XTransformationFailureException: Error encountered while executing the transform. Error:Transformation failed.. —> System.Xml.XPath.XPathException: Function ‘userCSharp:ConvertToDecimal()’ has failed. —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.FormatException: Input string was not in a correct format.

1. Be careful in data conversion inside the mapping especially when using Scripting Functiod to convert values. One prime example is when you use the Convert.ToDecimal method. If you use this method and the value contains scientific notation ( 3.71615996396169E-02) it will throw an exception. The correct way of doing it is by using the Decimal.Parse method.

decimal d = Decimal.Parse("8.71615996396169E-02", System.Globalization.NumberStyles.Float);

SAP Schema Generation Error:

Error Message:

Error while retrieving or generating the WSDL. Adapter message: Details: ErrorCode=RFC_EXCEPTION. ErrorGroup=RFC_ERROR_APPLICATION_EXCEPTION. SapErrorMessage=SEGMENT_UNKNOWN.  AdapterErrorMessage=Error returned by RfcCallReceiveEx while calling RFC: IDOCTYPE_READ_COMPLETE..

Cause:

Idoc segment in SAP is not set to Released. Ask the SAP Team to check whether all segments are released.

BizTalk Deployment

Use BizTalk Deployment Framework (BTDF) to simplify deployment. BTDF can be downloaded from here. BTDF quick tutorial: https://randypaulo.wordpress.com/2012/01/13/biztalk-deployment-framework-btdf-tutorial-walkthrough/ Automating/Silent Install of BTDF using powershell here:  https://randypaulo.wordpress.com/2012/01/31/automating-silent-install-biztalk-deployment-framework-btdf-using-powershell/

ESB Toolkit 2.1 using Enterprise Library 5.0

If you’re here probably you have a problem about this error:

[A]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection cannot be cast to [B]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection. Type A originates from ‘Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ in the context ‘Default’ at location ‘C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\4.1.0.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll’. Type B originates from ‘Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ in the context ‘Default’ at location ‘C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\5.0.505.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll’

Now there’s been lot of discussion how ESB Toolkit 2.1 breaks all other application that uses Enterprise Library 5.0 when deployed on the same machine, that’s because it updates the machine.config, which is the mother of all configs.

As of this moment there’s no fix regarding this matter. To undo the error that ESB Toolkit causes (see error above) you can follow the steps below:

Solution:

Step 1. You need to check the platform that your application targets, either 32bit or 64bit and the .NET Version. For BizTalk 2010 it’s 4.0. 

To check the Host whether it’s using 32bit (default) or 64bit explicitly. BizTalk Admin Console -> Platform Settings -> Hosts -> -> Properties -> Options -> 32-bit only flag.

Step 2. After determining the target platform,  open the Notepad.exe (Run as Administrator). It’s important to run it as administrator as we are going to edit the machine.config.

Step 3. Based on the platform open the machine.config using the Notepad.

32-bit: %Windows%\Microsoft.NET\Framework\v4.0.30319\Config

64-bit: %Windows%\Microsoft.NET\Framework64\v4.0.30319\Config

Step 4. Comment or remove the following sections:

Step 5. Save and restart the application/services/host instances.

IIS 7 The protocol ‘net.tcp’ is not supported, Enabling net.tcp in IIS using WAS

Without the proper configuration, IIS will throw the error below wheneven you try to use net.tcp:

The protocol ‘net.tcp’ is not supported

Below is the configuration on how you can enable net.tcp in IIS 7.

1. Add WCF Activation, to do this go to Server Management -> Features -> Click Add Features

2. After installing the WCF Activation it may throw an error:

Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’

To fix it, open the command prompt (Run as administrator) and enter the ff:

 C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -iru

3. Issue an iireset on command prompt.

4. Go to the Web Site -> Right Click -> Edit Bindings – > Click Add, in the type select net.tcp and in the binding information set it to 808:*

5. Go to the Web Site -> In the Actions Pane click Advance Settings  -> In the Behavior change it to http,net.tcp.

Repeat steps for every WCF Service Application (Virtual Directories) under the Web Site.

Event Log – System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

Event Log – System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

This is a common error specially if you’re using Windows Server 2008 and higher, error means that the application/program that’s trying to write to event log with source not registered properly. Take the sample code below as an example:

EventLog.WriteEntry(“,”Message”);

During the deployment you can register the source by entering the ff command in the command prompt (Run as Administrator):

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO  /D “Registering”

If for some  reason you don’t know the source is and it’s throwing the error do the following:

Start -> Run -> regedit.exe Navigate to My Computer > HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog

in the Permissions, and grant the identity wherein the application/server is running with read/write permissions.

You will see the source that you need to register in the Event Log.

VS Setup – The version of the .NET Framework launch condition ‘.NET Framework 4’ does not match the selected .NET Framework bootstrapper package

I recently upgraded existing solution built using VS2008 to VS2010 and encountered the warning:

The version of the .NET Framework launch condition ‘.NET Framework 4’ does not match the selected .NET Framework bootstrapper package

To resolve it:

1. The .NET Framework version you have in Launch Condition should match with the 2. Prerequisites in Setup Properties.

 

Launch Condition:

Prerequisites:

BizTalk WCF-SQL Adapter MSDTC Issue

This was imported from my old blog dated  July 3, 2009.

I was working on a Biztalk integration project that perform a CRUD operation using old SQL adapter (the new one is available via Microsoft Adapter Pack 2.0), everything works fine on the development environment but when we’ve tried to deploy it to test environment which have the same structure with the production server we stumble again on MSDTC issues.

To cut the story short it was too complicated and too many settings (firewall, NETBIOS etc) needs to be change since the database server is located on DMZ. The next day while I’m configuring the mySAP adapter, I found out that license has expired, since we’ve downloaded the trial version of BizTalk adapter pack 1.0. So I have to look for another setup, it so happen that for some reason I can’t find the 1.0 version that’s why I’ve installed the Adapter pack 2.0. I was a little bit surprise to see that there’s a new SQL Adapter included. So I’ve installed it and give it a try and it works fine.

Two important sql binding settings that needs to be set are:

1) useAmbientTransaction = false, to solve MSDTC issue.

2) allowIdentityInsert = true, if you’re trying to add rows to a table that has identity column.

 

SQL Login not working in SQL 2008R2/2005

From time to time I see this problem reoccurring, suppose you correctly setup an SQL Login for a certain account and when you tried to login it throws: Login failed for ‘RPAULO_WebUser’ (Microsoft SQL Server, Error: 18456) you might want to check whether the sql server supports mixed mode by going to SQL Server Properties of the server (connect via RDP).

Note that updating the settings would require a service restart to take effect.

BizTalk – Error 0x80131700 while starting SSO Enterprise Single Sign-On Service

I’m using BizTalk Server 2006 R2 then after installing .NET 4.0 Framework all services of BizTalk went down. When I tried to start the Enterprise Single Sign-On Service it throws this error:

Windows could not start the Enterprise Single Sign-On Service service on Local Computer.
Error 0x80131700: 0x80131700

When I checked the event log there are more information:

Could not create SSOSQL. To fix the problem, reinstall SSO or try ‘regasm SSOSQL.dll’ from a Visual Studio command prompt.
Error Code: 0x80131700

Solution:

It depends whether you’re using 32bit or 64bit, so please keep in mind before doing ff steps below.

This issue can also be repaired by using the regasm tool to re-register the SSOSQL assembly. Regasm.exe is included with the .Net Framework.

32-bit Server

1.       Open a command window
2.       Go to C:\Windows\Microsoft.NET\Framework\v2.0.50727
3.       Type: regasm “C:\Program Files\Common Files\Enterprise Single Sign-On\ssosql.dll”

64-bit Server

1.       Open a command window
2.       Go to C:\Windows\Microsoft.NET\Framework64\v2.0.50727
3.       Type each of the following and hit ENTER:

32bit:  regasm “C:\Program Files\Common Files\Enterprise Single Sign-On\win32\ssosql.dll”
64bit:  regasm “C:\Program Files\Common Files\Enterprise Single Sign-On\ssosql.dll”

Note On a 64-bit server, regasm will need to be run for both the 32-bit and 64-bit versions of ssosql.dll.

Link to orginal KB Article.

ASP.NET ReportViewer Native compiler return value: ‘[BC2001] file’ error

Recently restored one of our servers and I encountered this error while trying to view a report:

An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC2001] file …. 

Solution:

1. Solving this seems so easy, first check the identity of the AppPool where the website is running:

2. From the command prompt type: %windir% and look for the temp folder. Add read/write permission to temp folder of windows to user in step 1.

Note: In other cases  the temp folder is located somewhere else, so to check where it’s located go to System Properties -> Advance -> Environment Variables. In the System Variables look  for the TEMP or TMP:

 

 

 

EsbToolkit 2.1 – Installation and Configuration Errors (Compilation)

I recently installed BizTalk Server 2010 and EsbToolKit 2.1 and below are the summary of errors and instructions on how to overcome them.

Error:

HTTP Error 404.17 – Not Found
The requested content appears to be script and will not be served by the static file handler.

Resolution:

Be sure that .NET 4.0 is installed, then run the following:  aspnet_regiis -i  in C:\Windows\Microsoft.NET\Framework\v4.0.21006

Error:

HTTP Error 404.2 – Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.

Resolution:

1. Go to Internet Information Services (IIS) Manager, click the {YouComputerName} Home (located  after the Start Page icon).

2. in the IIS Section -> Double click ISAPI and CGI Restrictions -> make sure ASP.NET is allowed.

Error:

HTTPException, Could not load file or assembly ‘System.Web.DataVisualization…

Resolution:

1. Download and install Microsoft Chart Controls for .NET 3.5

 Error:

Could not enlist send port ‘ALL.Exceptions’ in Microsoft.Practices.ESB application (BizTalk Admin Console)

Resolution:

Add new filter expression to it, Property: ErrorReport.FailureCode Operator: Exists

 

Error:

HttpException, Could not load type ‘Microsoft.Practices.ESB.Portal.Global’.  

Resolution:

In the ESB Toolkit installation manual there’s no mention of Enterprise Library but in fact you need to install it. Also, ESB Toolkit uses Enterprise Library 4.1 and not 5.0. Get the installer here. Then rerun the Management_Install.cmd.

Error:

WebException,  The remote server returned an error: (401) Unauthorized. 

Resolution:

1. Click Start, click Run, type cmd, and then press ENTER.

2. Locate the directory that contains the Adsutil.vbs file. By default, this directory is C:\Inetpub\Adminscripts.

3. Type cscript adsutil.vbs set w3svc/1/root/NTAuthenticationProviders “Negotiate,NTLM”

 The number after w3svc is the website id, the script above assumes that the ESBPortal is your first website.

For the complete Microsoft Guide click here.

 

Error:

WebException,  The remote server returned an error: (404 ) not found.  

Resolution:

.svc should be register in IIS, run the following command in command prompt.

“%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe” -r -y

Error:

Runtime Error, Client found response content type of  ‘text/html; charset=utf-8’, but expected ‘text/xml’

Resolution:

Problem lies with ESB.BizTalkOperationsService, by going to the web.Config of this service then setting customErrors mode to “RemoteOnly”, you can see the actual error which is: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel’. 

This error could occur if IIS is installed only after installing .NET 4.0. To solve this type the ff: in command prompt:

%WinDir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -iru

 

Error:

Management_Install.ps1 cannot be loaded because the execution of scripts is disabled on this system.

Resolution:

Open Powershell Command Prompt (Run as Administrator). Type  Set-ExecutionPolicy Unrestricted