My lovely (BizTalk) error message

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

Sometimes I have a feeling that every second message in the BizTalk server sound like:

"The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the BizTalk Administration console to troubleshoot this failure."

Because of that there are probably many reasons which cause such failure during routing of the message.

My favorite reasons for this error are following:

  1. The importing message is not of expected schema. To be sure that this cause your problem go to properties of the schema file bound to the port which should receive this message and set the "Input Instance Output Type" to the XML file, which represents importing message. After that validate this instance (Right mouse click on the schema and then Validate Instance).
  2. The importing message contains the XML header: "<?xml version="1.0" encoding="utf-16" ?>"
  3. The message is of invalid encoding.
  4. The stream of importing message is not on position 0. This happen mostly during implementing of the custom adapter or pipeline.
  5. The writer of the message stream is not flushed. This also happen mostly during implementing of the custom adapter or pipeline.
  6. Last but not least: Required properties have not been promoted.

To illustrate what properties have to be promoted see following example, which shows how to create from the scratch a fresh new message with all required properties:

private IBaseMessage createMessage(IPipelineContext pContext,
Stream message, string namespaceURI,
string rootElement, IBaseMessage pInMsg)
{
  
IBaseMessage msg;
   try
  
{
         string sysProps = 
         http://schemas.microsoft.com/BizTalk/2003/system-properties;


         msg = pContext.GetMessageFactory().CreateMessage();
         msg.AddPart("body",
         pContext.GetMessageFactory().CreateMessagePart(),
         true);

         msg.Context.Promote("MessageType",
         sysProps, namespaceURI + "#" + rootElement.Replace("ns0:", ""));

        
string transpProp = 
         pInMsg.Context.Read("InboundTransportLocation",
         sysProps) as string;

         msg.Context.Promote("InboundTransportLocation",
         sysProps, transpProp);

        
string rcvProp = pInMsg.Context.Read("ReceivePortID",
         sysProps) as string;
         msg.Context.Promote("ReceivePortID", sysProps, rcvProp);

         string rcvNmProp =
         pInMsg.Context.Read("ReceivePortName", sysProps) as string;
        
msg.Context.Promote("ReceivePortName", sysProps, rcvNmProp);

        
pContext.ResourceTracker.AddResource(msg);

        
msg.BodyPart.Data = message;

        
return msg;
    }
    catch (Exception ex)
    {

    }
}


While implementing for example the custom pipeline of any type following properties should be promoted:

  1. MessageType
  2. InboundTransportLocation
  3. ReceivePortName
  4. ReceivePortID

    As shown in example above the values of required properties are contained in the original message IBaseMessage pInMsg . The only property which cannot be copied from the original message is MessageType.
    One example of this property is: http://Daenet.DataPipeline.Somechema/2007/07#Measurements. It is consisted of the namespace of the message and the name of the root node with "#" in between.
    The namespace of the message can be copied from the schema file, which would in this case look as shown below:

<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns
="http://Daenet.DataPipeline.SomeSchema/2007/07"
elementFormDefault
="qualified"
targetNamespace
="http://Haerter.DataPipeline.OgpSchema/2007/07"
xmlns:xs
="http://www.w3.org/2001/XMLSchema">

<xs:element name="Measurements">
<xs:complexType>


Hope these can help you in one of painful moments in the live of BTS developer.


Posted Jul 26 2007, 11:27 PM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.