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 “http://192.168.254.163:5081/BTSHTTPReceive.dll”
http://192.168.244.153:5081/BTSHTTPReceive.dll”
” is suspended. Error details: There was a failure executing the send pipeline: “Microsoft.BizTalk.EdiInt.DefaultPipelines.AS2Send, Microsoft.BizTalk.Edi.EdiIntPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” Source: “AS2 encoder” Send Port: “sp_As2ToACC” URI: http://192.168.254.163:5081/BTSHTTPReceive.dll

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
HAVING COUNT(*) > 1

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.



 

Advertisements

AS2 Configuration on BizTalk 2009 Group

Last week I was working on an AS2 configuration on BizTalk 2009.
The AS2 messages needed to be encrypted and signed.

Previously I went through an AS2 configuration upon BizTalk 2006 and as I expected everything looked familiar to me.
Setting up the encryption was an easy job. Nevertheless, the second requirement, message signing, wasn’t as straightforward as I hoped.

After configuring and enabling a certificate to sign the messages, I received the following error:

Error: The Signing Certificate has not been configured for AS2 party.”

I checked and double checked every known issue that i could bing. As there are…

  • Install the certificate used for signing in the personal certificate store of the appropriate BizTalk host service account.

    This installation has to be done while you are logged on with this service account. Otherwise the certificate will be imported in the wrong personal store.

  • Avoid enabling strong private key protection in the certificate during import in the personal store.

    And be sure that the certificate has the private key included.


None of these well known problems solved my error. Searching for new inspiration I repeated the installation on a clean standalone development machine. And yes, here I got more success! The signing and encryption both worked. After comparing the two installations I didn’t find any difference in the configuration of the necessary certificates. So if my AS2 configuration is the same then what makes the difference?

An SQL Trace brought the answer. I asked the dba to capture the SQL activity while BizTalk was trying to send an AS2 message. In the trace we found the following sql-statement:

declare @p3 nvarchar(256)
set @p3=NULL
declare @p4 nvarchar(256)
set @p4=N”
exec admsvr_GetGroupSigningCert
@nvcGroupName=N’BizTalk Group’,@nvcHostName=N’BizTalkServerApplication’,
@nvcGroupSignCertName=@p3 output,
@nvcHostSignCertName=@p4 output
select @p3, @p4

This statement wouldn’t have looked wrong to me, if I wouldn’t have changed the name of the BizTalk group.
Because most of the time I maintain different biztalkgroups from one BizTalk administration console.
I rename the different BizTalk groups for easy recognition (Dev. group, Acc. Group and Prod. group).
In the above statement we see that the default groupname “BizTalk Group” is still being used. Hence, no certificate
can be found. On my clean development machine the installation succeeded because I didn’t changed the groupname.
After renaming the groupname back to “BizTalk Group” the problem was solved.

This means that the AS2 pipeline component is using the default groupname “BizTalk Group” hardcoded to search for the signing certificate.
And therefore you cannot rename the BizTalk groupname if you want to make use of AS2 with message signing enabled.