AS2 and context properties

In a previous post I wrote about an AS2 problem that I encountered after renaming the BizTalk Groupname.
In this post I digg into another AS2 problem, this time related to context properties.

Lately I have been asked to reconfigure an AS2 configuration to send messages with a predefined filename. This is easily done by selecting Transmit file name in MIME header. This checkbox can be found under the AS2 properties of the sending party. As you can see in the printscreen there is a possibility to point to a context property of which the value will be used as filename.
Simply put the context property shortname between two percent signs. If the context property wouldn’t exist you can choose to suspend the message.

After my first attempt to send a message another AS2 error showed up.

A message sent to adapter “HTTP” on send port “sp_As2ToACC” with URI “””
” is suspended. Error details: There was a failure executing the send pipeline: “Microsoft.BizTalk.EdiInt.DefaultPipelines.AS2Send, Microsoft.BizTalk.Edi.EdiIntPipelines, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35” Source: “AS2 encoder” Send Port: “sp_As2ToACC” URI:

Reason: The type initializer for ‘Microsoft.BizTalk.AS2.Pipelines.BizTalkPropertyList’ threw an exception.

MessageId: {451AC15C-7545-4487-8979-26E0511BCC3E}

InstanceID: {B8823D47-30F9-4E29-8649-8A965ADA1AF4}

Following the errormessage something went wrong with the initialisation of the BizTalkPropertyList.
This list can be found in the BizTalkMgmt database table bt_DocumentSpec.
The AS2 encoder will query this table to look up the property configured for retrieving the filename.
So what happened? If we open this table we see a lot of columns. But for the AS2 encoder only two seems to matter: clr_namespace and schema_root_name. The error mentioned above is caused when there are two or more property schemes deployed with the same value for these fields. In other words to avoid the AS2 encoder error, the concatenation of these fields must act as a primary key within this table. Also note that the duplicate property does not necessarely have a relation to the configured filename property. Lets have a closer look. Every BizTalk developer knows that every scheme must be made unique by its targetnamespace and rootname. This garantuees that BizTalk will process every message correctly. In the bt_DocumentSpec table this value is stored as ‘msgtype’. In this case we are talking about propertyschemes. So the msgtype field value is constructed by targetnamespace#propertyname. Because a scheme lives in a .Net BizTalk Assembly there is also another .NET namespace associated with the property. Right! clr.namespace.schema_root_name. Do remember that while this is not the fully qualified name of the property it is the value where the AS2 encoder will look for.

For example, the two rows shown in the picture below will cause the error.

I wrote a sql script to easily find duplicates in the bt_DocumentSpec table.

SELECT clr_namespace + ‘.’ + schema_root_name as shortName, COUNT(*)
FROM [dbo].[bt_DocumentSpec]
WHERE xsd_type <>
GROUP BY clr_namespace + ‘.’ + schema_root_name

If you find duplicate properties you have to rename the clr_namespace. Do this by opening the propertylist of the propertyschema you want to modify (from within visual studio). There you will find the .Net namespace. Try to keep this namespace unique for all your BizTalk projects.



4 comments on “AS2 and context properties

  1. Gou Jun says:

    Hi Cnext

    I deployed a schema project with two different versions 1 and 2. Consequently there are some duplicates as stated in your post above.

    Version 1 is useless anymore from functional perspective, but I’m not able to remove it directly from Biztalk Admin Console, because it is referenced by other artifacts still.

    How can I delete those records related to version 1 from bt_DocumentSpec, given simple deletion in query analyzer failed for foreign key collision?

    Any idea would be highly appreciated.

    Gou Jun

    • Cnext says:

      Hi Gou Jun,

      I think it is not recommended to delete version 1 of your schema directly from the bt_DocumentSpec.
      If this is possible anyway, without making the database inconsistent.
      You should try to remove all references to the old version of your schema, delete schema 1 from Biztalk Admin Console,
      and rebuild and redeploy all BizTalk artifacts with the new version.

      If you have any further questions please do not hesitate to reply.


  2. Gou Jun says:

    Cnext, thanks for your response. In our particular case, references to version 1 shouldn’t be cleared, even though it’s useless anymore.

    Given this fact, I set the field xsd_type of version 1 to empty string. It’s a workaround.

    Seems it could be deleted directly from database, which is weird because I failed several weeks ago under an extremely similar situation. However, I’d better not risk production server.

    Gou Jun

  3. […] Googled the error message and it leads to this very helpful blog post.  I confirmed that error only occurs when Transmit file name in MIME header option is checked. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s