none
Ignoring special character (0x92) RRS feed

  • Question

  • A trading partner sent a single right quote rather than an apostrophe. The receive pipeline is set for UTF8. This character causes the transaction to fail, is there a way to configure the pipeline to ignore it or translate it as an apostrophe?
    Tuesday, December 16, 2014 4:12 PM

Answers

  • No, they are different characters.

    If it's the Trading Partner, they need to fix and resubmit from their end.

    If you expect to handle this regularly, you would have to use a Pipeline Component to replace the character in the Decode Stage.

    • Proposed as answer by ArvindC Thursday, December 18, 2014 4:28 AM
    • Marked as answer by Angie Xu Tuesday, December 23, 2014 3:05 AM
    Tuesday, December 16, 2014 4:27 PM
  • You can do pre-processing using a custom pipeline component. Leonid Ganeline has a pre-built one on CodePlex. Here is a link to information on it: http://geekswithblogs.net/LeonidGaneline/archive/2007/08/22/114895.aspx. He uses it with EDI in some of the same ways you need. 

    Rachit

    Tuesday, December 16, 2014 4:34 PM
    Moderator
  • Best way is to let client know about the issue so that it can be fixed from source system. If they cant they you need  to build the custom receive pipeline component to replace the single quote with empty value .

    The sample code for Execute will be like below

    public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
    {
    
    	IBaseMessagePart bodyPart = inmsg.BodyPart;
            Stream sOriginalStream = bodyPart.GetOriginalDataStream();
            if (sOriginalStream != null)
            {
                MemoryStream memStream = new MemoryStream();
                try
                {
                    Regex reReplaceChar = new Regex("''", RegexOptions.None);
                    StreamReader sReader = new StreamReader(sOriginalStream);
                    StringBuilder sBuilder = null;
                    byte[] byteArray = new byte[sOriginalStream.Length];
                    while (sReader.Peek() != -1)
                    {
                        sBuilder = new StringBuilder(sReader.ReadLine());
                        sBuilder = new StringBuilder(reReplaceChar.Replace(sReader.ReadLine().ToString(), ""));
                        byteArray = System.Text.Encoding.ASCII.GetBytes(sBuilder.ToString());
                        memStream.Write(byteArray, 0, byteArray.Length);
                    }
                    bodyPart.Data = memStream;
                    memStream.Position = 0;
                    inmsg.BodyPart.Data = bodyPart.Data;
                    pc.ResourceTracker.AddResource(memStream);
                }
    		return inmsg;
    	}
    }

    Thanks

    Abhishek

    Tuesday, December 16, 2014 4:43 PM

All replies

  • No, they are different characters.

    If it's the Trading Partner, they need to fix and resubmit from their end.

    If you expect to handle this regularly, you would have to use a Pipeline Component to replace the character in the Decode Stage.

    • Proposed as answer by ArvindC Thursday, December 18, 2014 4:28 AM
    • Marked as answer by Angie Xu Tuesday, December 23, 2014 3:05 AM
    Tuesday, December 16, 2014 4:27 PM
  • You can do pre-processing using a custom pipeline component. Leonid Ganeline has a pre-built one on CodePlex. Here is a link to information on it: http://geekswithblogs.net/LeonidGaneline/archive/2007/08/22/114895.aspx. He uses it with EDI in some of the same ways you need. 

    Rachit

    Tuesday, December 16, 2014 4:34 PM
    Moderator
  • Best way is to let client know about the issue so that it can be fixed from source system. If they cant they you need  to build the custom receive pipeline component to replace the single quote with empty value .

    The sample code for Execute will be like below

    public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
    {
    
    	IBaseMessagePart bodyPart = inmsg.BodyPart;
            Stream sOriginalStream = bodyPart.GetOriginalDataStream();
            if (sOriginalStream != null)
            {
                MemoryStream memStream = new MemoryStream();
                try
                {
                    Regex reReplaceChar = new Regex("''", RegexOptions.None);
                    StreamReader sReader = new StreamReader(sOriginalStream);
                    StringBuilder sBuilder = null;
                    byte[] byteArray = new byte[sOriginalStream.Length];
                    while (sReader.Peek() != -1)
                    {
                        sBuilder = new StringBuilder(sReader.ReadLine());
                        sBuilder = new StringBuilder(reReplaceChar.Replace(sReader.ReadLine().ToString(), ""));
                        byteArray = System.Text.Encoding.ASCII.GetBytes(sBuilder.ToString());
                        memStream.Write(byteArray, 0, byteArray.Length);
                    }
                    bodyPart.Data = memStream;
                    memStream.Position = 0;
                    inmsg.BodyPart.Data = bodyPart.Data;
                    pc.ResourceTracker.AddResource(memStream);
                }
    		return inmsg;
    	}
    }

    Thanks

    Abhishek

    Tuesday, December 16, 2014 4:43 PM
  • Create a custom pipeline to convert message encoding or handle special character in decode stage and convert it back in encode stage.  
    Thursday, December 18, 2014 4:54 AM
  • Hi,

    As already pointed out above , ideally you should let the trading partner aware about the standard and the way data to be sent. But if that is not feasible/possible due to some reason, then you need to handle it on your end.

    The best option is to write a custom pipepeline component (preprocessor) which will make the correction. Following is the link to a preprocessor sample - BizTalk Server:PreProce​ssing of EDI Message Custom pipeline component

    __________________________________________________________________

    Maheshkumar S Tiwari|User Page|Blog|BizTalk Server: Multiple XML files to Single FlatFile Using File Adapter

    Friday, December 19, 2014 5:01 AM