Category nameļ¼šBizTalk 2006 R2

Difference in mapping between BizTalk 2010 and 2013

December 16, 2013 / Comments Off on Difference in mapping between BizTalk 2010 and 2013

Difference in mapping 2010
versus 2013

 

Artifacts description

In a
BizTalk 2010 project we have a function that passes the current XmlNode as an
XpathNodeIterator to a helper component. In BizTalk 2010 the map look like
this:

Note that
we are using custom XSLT here. The content of the XSLT is show below :

<?xml version=1.0 encoding=UTF-16?>
<xsl:stylesheet
xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” xmlns:msxsl=”urn:schemas-microsoft-com:xslt” xmlns:var=”http://schemas.microsoft.com/BizTalk/2003/var” exclude-result-prefixes=”msxsl var userCSharp
ScriptNS0″ version=”1.0″ xmlns:ns0=”http://TestMap.SomeSchema” xmlns:userCSharp=”http://schemas.microsoft.com/BizTalk/2003/userCSharp” xmlns:ScriptNS0=”http://schemas.microsoft.com/BizTalk/2003/ScriptNS0″>
  <xsl:output omit-xml-declaration=“yes” method=”xml” version=”1.0″ />
  <xsl:template match=“/”>
    <xsl:apply-templates select=“/ns0:Root” />
  </xsl:template>
  <xsl:template match=“/ns0:Root”>
    <ns0:Root>
      <xsl:for-each select=“RepeatingNode”>
        <xsl:variable name=“var:v1″ select=”userCSharp:StringTrimRight(string(SomeNode1/text()))” />
        <xsl:variable name=“var:v3″ select=”userCSharp:StringTrimRight(string(SomeNode2/text()))” />
        <RepeatingNode>
          <xsl:variable name=“var:v2” select=”ScriptNS0:WriteNode(string($var:v1) , .)” />
          <SomeNode1>
            <xsl:value-of select=“$var:v2” />
          </SomeNode1>
          <xsl:variable name=“var:v4” select=”ScriptNS0:WriteNode(string($var:v3) , .)” />
          <SomeNode2>
            <xsl:value-of select=“$var:v4” />
          </SomeNode2>
        </RepeatingNode>
      </xsl:for-each>
    </ns0:Root>
  </xsl:template>
  <msxsl:script language=“C#” implements-prefix=”userCSharp”><![CDATA[

public
string StringTrimRight(string str)
{
       if (str == null)
       {
               return “”;
       }
       return str.TrimEnd(null);
}
]]></msxsl:script>
</xsl:stylesheet>

 

The content
of the Extension XML is shown below :

<ExtensionObjects>
  <ExtensionObject Namespace=“http://schemas.microsoft.com/BizTalk/2003/ScriptNS0″ AssemblyName=”MapHelper,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=94092251336a29ea” ClassName=”MapHelper.mapHelperClass” />
</ExtensionObjects>

 

The code of
function in the Helperclass is shown below :

using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Xml.XPath;
using
System.Xml;

 

namespace
MapHelper
{
   public class mapHelperClass
   {

        public static bool
WriteNode(string somedata,XPathNodeIterator node)
        {
           XPathNavigator
xpn = node.Current;
           XmlDocument
xdoc = new XmlDocument();
           xdoc.LoadXml(xpn.OuterXml);
           System.Diagnostics.Trace.WriteLine(“In
function ->”+ xdoc.OuterXml);
            return true;
       }
   }
}

Expected behavior BizTalk
2010

If we run
this map in BizTalk 2010 and watch for the output in Debug View we get the
expected output

Also the
map test succeeds in BizTalk 2010. As shown below:

Invoking
component…
F:ProjectsTestMapTestMapSomeMap.btm:
The compilation is using the CustomXslt and CustomExtensionXml tags to generate
the output.  The map content is ignored.
TestMap
used the following file:
<file:///C:UsersAdministratorAppDataLocalTempinputfile.xml> as
input to the map.
Test Map
success for map file F:ProjectsTestMapTestMapSomeMap.btm. The output is
stored in the following file:
<file:///C:UsersAdministratorAppDataLocalTemp_MapDataTestMapSomeMap_output.xml>
Component invocation succeeded.


Observed behavior BizTalk
2013

If we run
this in BizTalk 2013 we get the following output.

Invoking component…

C:ProjectsTestMap2013TestMapTestMapSomeMap.btm:
The compilation is using the CustomXslt and CustomExtensionXml tags to generate
the output.  The map content is ignored.
TestMap used the following file:
<file:///C:UsersAdministratorAppDataLocalTempinputfile.xml> as
input to the map.
C:ProjectsTestMap2013TestMapTestMapSomeMap.btm:
error btm1050: XSL transform error: Unable to write output instance to the
following
<file:///C:UsersAdministratorAppDataLocalTemp_MapDataTestMapSomeMap_output.xml>.

Exception
has been thrown by the target of an invocation. An error occurred during a call
to extension function ‘WriteNode’. See InnerException for a complete
description of the error. Enumeration has not started. Call MoveNext.
Test Map failure for map file <file:///C:ProjectsTestMap2013TestMapTestMapSomeMap.btm>.
The output is stored in the following file:
<file:///C:UsersAdministratorAppDataLocalTemp_MapDataTestMapSomeMap_output.xml>
Component invocation succeeded.

So the map failed because the behavior of the compiled xslt is different from the interpreted xslt.

Desired Behavior

The behavior
should be the same as in BizTalk 2010.

 

You can find the test project in the attachment

Getting rid of : WCF-Custom" raised an error message. Details "System.Data.SqlClient.SqlException: Timeout expired

December 22, 2010 / Comments Off on Getting rid of : WCF-Custom" raised an error message. Details "System.Data.SqlClient.SqlException: Timeout expired

I had a nice setup in my BizTalk environment. I had 4 receive locations polling for data (in the same table) and it all boiled down to execute a stored procedure with different parameters. I used the WCF adapter with SQL bindings for that.
For some obscure reason, I would get timeouts in the eventlog. Below is a screenshot of the receive port setup I had. Only one is shown but I had four of them.

Some important things to notice:

  • PolledDataAvailablestatement, is not used cause Pollwhiledatatfound = false. But you still have to put stuff in there to make things work.
  • Execute a specific sproc, with the number of records you want to receive as a parameter.
  • UseAmbientTransaction, no, no,no, had too many problems in the past when using msdtc and receive locations (locks and stuff) so this is a NO.
  • ReceiveTimeout is set to 10 minutes. This is a bit long but i never touched that value, it’s the default.

To make things a little bit more clear, The stored procedure I used looks looked like this :

 CREATE PROCEDURE [dbo].[Get_TeVertalen_Berichten]
(
 @MaximumAantal INT = NULL
)
AS
BEGIN
 EXEC [dbo].[Get_Berichten_Internal]
  @MaximumAantalInternal = @MaximumAantal,
  @OudeBerichtStatus = ‘TeVertalen’,
  @NieuweBerichtStatus = ‘VertalenGestart’,
  @Richting  = ‘Ingaand’  
END

And here is the code of Get_Berichten_Internal:

CREATE PROCEDURE [dbo].[Get_Berichten_Internal]
(
 @MaximumAantalInternal INT = 15,
 @OudeBerichtStatus  VARCHAR(200),
 @NieuweBerichtStatus VARCHAR(200),
 @Richting    VARCHAR(20) 
)
AS
BEGIN
 BEGIN TRY
  — Declare variables
  DECLARE @AFFECTED_KEYS TABLE
  (
   BerichtID NUMERIC(18, 0)
  )
  DECLARE @AFFECTED_ROWS INT
   — Some sets needed
  SET NOCOUNT ON
  — Perform the update statement and capture all the keys
  UPDATE
   TOP (@MaximumAantalInternal) dbo.tb_Bericht
  SET  
   BerichtStatus = @NieuweBerichtStatus
  OUTPUT
   INSERTED.BerichtID
  INTO
   @AFFECTED_KEYS
  WHERE
   BerichtStatus = @OudeBerichtStatus
  AND
   ExternBerichtTypeID IS NOT NULL
  AND
   InternBerichtTypeID IS NOT NULL
  AND
   Richting = @Richting
  — DO STUFF WITH THE AFFECTED KEYS
  <– SNIP–>
 END TRY
END

Now everything looks good and in the query analyzer everything was working blazingly fast. But I started to see the following message in the eventlog every 10 minutes (hmm that’s the receive timeout).  And sometimes several (four to be exactly) of them within a very short period of time.

Event Type: Warning
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5740
Date:  14-12-2010
Time:  10:47:07
User:  N/A
Computer: BA34T
Description:
The adapter “WCF-Custom” raised an error message. Details “System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at Microsoft.ServiceModel.Channels.Common.Design.AdapterAsyncResult.End()
   at Microsoft.ServiceModel.Channels.Common.Channels.AdapterInputChannel.EndTryReceive(IAsyncResult result, Message& message)
   at System.ServiceModel.Dispatcher.InputChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)”.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

And once this message started to appear, stuff went downhill from there on. I could see in the profiler that stored procedures were taking ages, and even simple updates of a single record would take thirty seconds or so. Lock-Time-outs and deadlocks were occuring on a very regular basis. Even though the receive locations werent receiving any data. So nothing was received and I still got may daily portion of errors/warnings/suspended stuff in BizTalk because of this.
So basically it looked like I was having some kind of locking problem even if no work was done by the second stored procedure. But the second procedure did an update (even when there was nothing to update) and maybe that triggered the nasty behaviour.

I started a discusiion on MSDN to see if anybody could help : <<See here>>

 But eventually i cghanged something to make this behaviour go away. The idea was only to perform the update when there was stuff to update. So i changed the first procedure to :

CREATE PROCEDURE [dbo].[Get_TeVertalen_Berichten]
(
   @MaximumAantal INT = NULL
)
AS
BEGIN
 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
 DECLARE @Aantal int
 SELECT
  @Aantal=count(*)
 FROM
  dbo.tb_Bericht WITH (NOLOCK)
 WHERE
  BerichtStatus = ‘TeVertalen’
 AND
  ExternBerichtTypeID IS NOT NULL
 AND
  InternBerichtTypeID IS NOT NULL
 AND
  Richting = ‘Ingaand’
 IF @Aantal > 0
 BEGIN
  EXEC [dbo].[Get_Berichten_Internal]
    @MaximumAantalInternal = @MaximumAantal,
    @OudeBerichtStatus  = ‘TeVertalen’,
    @NieuweBerichtStatus = ‘VertalenGestart’,
    @Richting    = ‘Ingaand’  
 END 
END

 And by first checking if there was any work to do and only then do an update, I got rid of the deadlocks and the errors in the eventlog.
I really don’t know why this solved it, but my guess is there is some bug in the WCF adapters, that go wrong if you start a transaction but return no data.

Everything is running smooth now and I hope this post will help somebody experiencing the same problems.

Strange COM exception in BizTalk

September 27, 2010 / Comments Off on Strange COM exception in BizTalk

A while ago I had serious problems with BizTalk. For some obscure reason the BizTalk engine would throw some XLANG errors and stop processing all messages. A restart of the hosts would fix the problem for a while but after some time the same problem would occur and BizTalk would effectively stop processing. (orchestrations would be marked as  active but nothing happens)

The funny thing is, these orchestrations were deployed on the BizTalk Server a long time ago and they never gave any problem. All of a sudden these problems started to appear. So I think the blame is probably in some kb^*&^(& hotfix somewhere.

I had a case with MS-Support (and for sure they had never seen this error) and even google will not tell you that much about it.
However, until now I have had two people contact me with exactly the same problem.
So I know I was not alone ! Since googling on this gives me very poor results I will put some details about what happened in this post.

Unable to cast COM object of type ‘System.__ComObject’   followed by No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

When this happens you will find a lot of references to the guid 6C90EC05-4918-11D3-A242-00C04F60A533 (see bottom)

I have mentioned both MSDN threads that have this problem. The things we have in common are:

  • Usage of the classic SQL adapter 
  • Typically, this problem occurs when the orchestration engine reaches a Call Orchestration shape or a Start Orchestration shape.

To isolate this problem we added a specific SQL Host that does all the work for the SQL Adapter. We hoped the next time we saw the error, we could see if it was caused by orchestrations or really by the SQL adapter. Cause then onlu the SQL Host would have a problem. We had everything set up to debug the BizTalk environment with the tools provided by MS and we were waiting for the event to happen. But unfortunately after we added a dedicated SQL host the problem never re-occurred. So the supportcase is closed now (without a definitive answer).

If you have had a similar experience please give a response to this post.

About EDI / Property Schemas and Validate instance

May 11, 2009 / Comments Off on About EDI / Property Schemas and Validate instance

In the future we need to process EDI documents so I am currently looking at some EDI Samples.

  • I did some tutorials (from Pro EDI in BizTalk Server 2006 Apress) and I created my own EDI schema based on X12_00401_810 (Exercise 1.0 to 1.4)
  • Then I had to create my own PropertySchemas to promote some nodes (Exercise 1.5)
  • Then I had to validate an instance of the schema i had just created….(Exercise 1.6 to 1.7)

But no matter what I did, I kept getting the same error over and over again. The errors were :

Invoking component…
D:XXXSchemasX12_BatchSchema.xsd: error BEC2004: Object reference not set to an instance of an object.
D:XXXSchemasX12_BatchSchema.xsd: error BEC2004: Validate Schema failed for file: <file:///D:XXXSchemasX12_BatchSchema.xsd>.
D:XXXSchemasX12_BatchSchema.xsd: error BEC2004: Validate Instance failed for schema X12_BatchSchema.xsd, file: <file:///C:Apress.IntegrationChapter 1Test DocumentsValid-Input.txt>.
Component invocation succeeded.

So I googled around a bit and tried to create a new solution. This has helped somebody who whas experiencing the same problems. But it Didn’t help me. The same rror keept popping up.

Only when I removed the property schema from my solution (created in 1.5) everything worked as expected. So since there is very little docuementation on this behaviour I hope this can help anybodu in the future.

 

 

 

  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta