Biz(Talk)2

Talk, talk and more talk about BizTalk

Invalid content type for AS2 messages

Recently I ran into an issue with the Http ContentType used when sending messages using the As2EdiSend pipeline.

Using the standard out-of-the-box pipeline, the web content type will be set to “application/EDI-EDIFACT“, regardless of the value supplied in the Party as AS2 Receiver configuration.  If your trading partner is using BizTalk as well, this is not an issue, as BizTalk, and probably some other AS2 servers, do not consider the content type before routing the AS2 payload for further parsing by an EDI interpreter.

However, our trading partner uses a specific AS2 server, Axway, that will only route to the EDI sub-system if the content type is, quite correctly, “application/EDIFACT” (note the small difference).  This is the correct value, according to the RFC (link – see Section 4.2).

Our workaround was to add a custom pipeline component in between the EDI Assembler stage and the AS2 Encoder stage in a custom Pipeline.  This custom component only does one thing, clears the IBaseMessage.BodyPart.ContentType property of the current message stream:

IBaseMessagePart bodyPart = pInMsg.BodyPart;
if ((bodyPart != null))
{
// Override the default content type with the one we want to use
pInMsg.BodyPart.ContentType = "";
}
return pInMsg;

By default, the EDI Assemble stage allocates a default value of “application/EDI-EDIFACT”.  The AS2 Encoder will lookup the appropriate content type to use from the Party configuration, but only if the content type has not been supplied.  As the EDI stage has already allocated a value, this “optional” value is rendered useless.  By “clearing” the default value, we allow the AS2 stage to use the appropriate value

Advertisements

November 6, 2009 - Posted by | BizTalk | , ,

3 Comments »

  1. I am currently working on a problem that is similar to this. For one of our trading partners, we sent out the message using the AS2EDISend pipeline without any problems, but when we did some decoupling and had the message go through an EDISend pipeline followed by an AS2Send pipeline, the content-type changed.

    I am assuming this is because it started looking at the party’s default content-type for AS2?

    Comment by Patrick Smith | December 30, 2010 | Reply

    • Patrick, by decoupling the EDI encoding from the AS2 transport, I assume you have separated the two steps by use of an intermediary file-drop location, or similar. While this seems untidy, and you do lose any context properties that may be set during prior processing, it does allow the AS2Send pipeline to correctly pick up the default content-type as specified in the Party config.
      Another advantage of this type of decoupling is it allows for better “perceived” up-time. Even if you need to stop your processing Orchestrations, you can still accept documents from your trading partners, the AS2 components will still send their MDN’s, and processing can commence uninterrupted once you restart your Orchestrations.

      Comment by Brett | January 4, 2011 | Reply

  2. Thanx for this solution, It has been bugging me for days.
    This post saved my live 🙂

    I had the problem I had to send the content-type application\edi-x12 to our trading partner but it was sending the content type text/xml. In my party I had it configured to send application\edi-x12 and also I had it as an override on my send port, but it kept sending the text\xml content type.

    We only had the problem with sending an orderconfirmation, not with an acknowledgement. The only difference between those two is that the acknowledgement uses an orchestration and the orderconfirmation is just a mapping, My guess is that since the input of the mapping is xml it somehow takes that as the content type.

    Comment by Maurice Jonas | September 26, 2013 | Reply


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: