An internal server error was encountered while attempting to transmit the message

Home Page Forums BizTalk 2004 – BizTalk 2010 An internal server error was encountered while attempting to transmit the message

Viewing 1 reply thread
  • Author
    Posts
    • #24831

      Hi

      I am in the process of developing a custom pipeline component that will intercept the WCF SQL Response to check whether response any records based on the resultset promote a context propery to True or false.

      I have wrote this custom component in the decode stage and when I receive the WCF SQL response it is throwing the error as “An internal server error was encountered while attempting to transmit the message” and getting suspended.

      In the eventviewer it has error message pertaining to the pipeline (see below in red) saying Object reference not set to an instance of an object

      There was a failure executing the response(receive) pipeline: “OutBoundIntegratedTransactions.OBIT_Generic_PP, OutBoundIntegratedTransactions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c2a2547952fc6d13” Source: “Pipeline ” Send Port: “OutBoundIntegratedTransactions_1.0.0.0_OutBoundIntegratedTransactions.orc_OutBoundIntegratedTransactions_Req_Res_OBIT_c2a2547952fc6d13” URI: “mssql://BTS2006TST03//BTS_TestDB?” Reason: Object reference not set to an instance of an object.

      So I tried to debugging the custom componenet I have placed in decode stage in which my Execute method went through fine and somehow this error is occuring when the orchestration is receving the message.

      I a not sure where I am going wrong. Below is the pipeline code I have developed.

      And help in this issue will be of much help to me.

              #region IComponent Members
              public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
              {
                  bool HasRecords = false;

                  try
                  {
                      System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, pInMsg.Context.Read(“Action”, “http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties”).ToString(), System.Diagnostics.EventLogEntryType.Information);

                      using (System.IO.Stream Msg = pInMsg.BodyPart.GetOriginalDataStream())
                      {
                          if (Msg != null && Msg.Length > 0)
                          {
                              System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();

                              xdoc.Load(Msg);

                              System.IO.File.WriteAllText(@”E:\2010\POC\OBIT_new\Archive\” + pInMsg.MessageID.ToString() + “.txt”, xdoc.InnerXml);

                              if (xdoc.ChildNodes.Count > 1)
                              {
                                  System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, xdoc.ChildNodes.Count.ToString(), System.Diagnostics.EventLogEntryType.Information);
                                  HasRecords = true;
                              }
                          }

                          if (pInMsg.Context.IsPromoted(“HasRows”, “http://OutBoundIntegratedTransactions.OBIT_PropertySchema“))
                          {
                              System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, “HasRows is already promoted”, System.Diagnostics.EventLogEntryType.Information);
                              pInMsg.Context.Write(“HasRows”, “http://OutBoundIntegratedTransactions.OBIT_PropertySchema“, HasRecords);
                          }
                          else
                          {
                              System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, “HasRows is now promoted”, System.Diagnostics.EventLogEntryType.Information);
                              pInMsg.Context.Promote(“HasRows”, “http://OutBoundIntegratedTransactions.OBIT_PropertySchema“, HasRecords);
                              System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, “HasRows is now promoted – 2”, System.Diagnostics.EventLogEntryType.Information);
                          }
                      }

                      System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, HasRecords.ToString(), System.Diagnostics.EventLogEntryType.Information);
                  }
                  catch (Exception e)
                  {
                      System.Diagnostics.EventLog.WriteEntry(“BatchProcessing”, e.Message, System.Diagnostics.EventLogEntryType.Error);
                  }
                  return pInMsg;
              }
              #endregion

      – Sathish

    • #24833

      You code is not throwing the exception, it is wrapped in a try/catch block.
      However your component does read thru the incoming stream and leave the stream position at the end of the message. So when the next component or end point manager receives the message it is effectively empty.
      You need to rewind the stream back to the beginning  – stream.Seek(0, SeekOrigin.Begin); before you return from your Execute method.

      • #24834

        Also change
        using
        (System.IO.Stream Msg = pInMsg.BodyPart.GetOriginalDataStream())

        to
        System.IO.Stream Msg = pInMsg.BodyPart.GetOriginalDataStream()

        when you exit the using block the stream will be disposed

        • #24984

          One thing that just caught us.  You probably should use System.IO.Stream Msg = pInMsg.BodyPart.Data (not GetOriginalDataStream() because exiting the component will dispose of the stream in some cases before the next component can read it.  Using.Data will clone the incoming message.

          John

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.