Custom Flat File Disassembler

Home Page Forums BizTalk 2004 – BizTalk 2010 Custom Flat File Disassembler

Viewing 0 reply threads
  • Author
    Posts
    • #25648

      There is a requirement in my project where I need to handle exceptions in the pipeline.

      For ex: If there any error in the input flat file  then I need to catch that error and log into the event log and move that invalid file into a folder.

      For that I’m have written a custom flat file disassemble component.   It works for invalid file.  It catch the exception in GetNext().

      But for valid file it still throws the error in the GetNext().   

      The error I’m getting is “unexpected data found while looking for ‘~’”.  But when I try to validate below sample text file against schema there is no issues. 


      For example: Below is sample valid file (4 records) .

      Schema structure At Root Level:  Child Delimiter 0xD 0xA , child order :Infix

      Schema structure At Child Level:  Child Delimiter ~, child order :Infix ,

      10220~38448~Tim~393939~2892929~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929
      10221~38448~Tim~393939~2892929~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929
      10223~38448~Tim~393939~2892929~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929
      10224~38448~Tim~393939~2892929~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929-~393939~2892929

      I have tried base.DocumentSpecName = this.DocumentSpecName  (in the Disassemble method).

      I’m not sure GetNext() is processing single record at a time.  When I try to debug the above message the while loop (in GetNext()) is executed only 3 times not four.  I’m bit confused.   Any help will be appreciated!!!!. 

       

      Below is the code (straight forward nothing complex):

       public new void Disassemble(IPipelineContext pContext,IBaseMessage pIngMsg)
      {
         try
         {

          if (pIngMsg !=null)
          {
         
         if ( pIngMsg.BodyPart != null)
                {

          Stream originalStrm = pIngMsg.BodyPart.Data;     
          streamreader = new StreamReader(originalStrm);
          stringBuildler.Append(streamreaderreader.ReadToEnd())
         }
          }
                        streamreader.BaseStream.Position = 0;
         
          base.Disassemble(pContext,pIngMsg)
         }
         catch(Exception exp)
         {

           //error
         }


      }

        public new IBaseMessage GetNext(IPipelineContext pContext)
              {
                  IBaseMessage baseMess = null;
                  try
                  {


                     

                      while ((baseMess = base.GetNext(pContext)) != null)
                      { }
                  }
                  catch (XmlException exp)
                  {
                      System.Diagnostics.EventLog.WriteEntry(“Application”, exp.Message.ToString());

                     
                     
                     
                      string fileName = @”C:\Temp\Out\Out” + Guid.NewGuid() + “.txt”;
                      StreamWriter ws = new StreamWriter(fileName);

                      ws.Write(strBuild.ToString());
                      ws.Close();

                     

                  }
                  catch (Exception exp)
                  {
                     
                    
                     
                      string fileName = @”C:\Temp\Out\Out” + Guid.NewGuid() + “.txt”;
                      StreamWriter ws = new StreamWriter(fileName);

                      ws.Write(strBuild.ToString());
                      ws.Close();

                     

                  }
                  finally
                  {

                  }
                  return baseMess;
                  //if ( baseMess == null && !blnStatus  )
                  //  return base.GetNext(pContext);
                  //else
                  //  return baseMess;
              }
       


       

       

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