Apr 102011
 

I had a business requirement to catch all web service exceptions and include them in an email.

Here’s how to do it:

Put the Web Service Call and Response inside a scope with an Exception Handler.  You don’t have to make it transactional.  You won’t be able to put both the send and receive shapes in an atomic scope.  I left it as “None”. You’ll need to add a reference to System.Web.Services.dll assembly to your project. Right-click on your scope and select Add New Exception Handler.
Select the exception handler you just added and open the properties window.

Configure the following properties:
Property    Value
Exception Object Type    System.Web.Services.Protocols.SoapException
Exception Object Name    ex_MyException

Inside of the exception handler you can do what you need by accessing ex_MyException.Details.  Be careful about terminating the orchestration inside of the exception handler, illness as it might cause zombies.

Apr 042011
 

I have a trading partner who sends in invalid characters within a REF03 in an X12 850.  In the following example, viagra 40mg my element separator is *, no rx and the customer is sending in a * within the REF03.  I’m wanting to remove that invalid character before it hits the EDI pipeline component.

Example X12 850:

DTM*010*20110329~
PO1*10547090*1*EA*67.5**BP*PG7058SP—-~
PID*F****LDY FAITH INDIVIDUAL IRON~
REF*TC**HEREISMYINVALIDCHARACTER*~

I first captured all the TC Qualified Ref Segments into named groups (pre, text, and post) with the following Regular Expression.

@”(?<pre>REF*TC**)(?<text>.*?)(?<post>~)”

Using a method I am able to capture all the REF*TC segments, evaluate each one, and within each “text” group replace the errant * with “ “.  Note the use of the MatchEvaluator delegate within the Replace method.

private string myGoodString(string strBadString, string strSegmentTerminator)
        {
            string strRegex = @”(?<pre>REF*TC**)(?<text>.*?)(?<post>”+strSegmentTerminator+”)”;
            RegexOptions myRegexOptions = RegexOptions.None;
            Regex myRegex = new Regex(strRegex, myRegexOptions);

            string result = myRegex.Replace(strBadString, delegate(Match m)
            {
                return String.Join(String.Empty, new String[]{
                m.Groups[“pre”].Value,
                m.Groups[“text”].Value.Replace(“*”,” “),
                m.Groups[“post”].Value
            });

            });
            return result;
        }

Here is the resulting X12 850 snippet.

DTM*010*20110329~
PO1*10547090*1*EA*67.5**BP*PG7058SP—-~
PID*F****LDY FAITH INDIVIDUAL IRON~
REF*TC**HEREISMYINVALIDCHARACTER~