locked
Remove Breakpoint in the XML -Biztalk RRS feed

  • Question

  • Hey ,

    I have a situation where I get XML input which comes from a internal ERP which I need to convert to Flat file and send that to a FTP location. The Input Xml has a breakpoint in one particular field(Highlighted Bold in below sample) , because of that my whole output changes.I cant do any changes in xml so I have to change something in BizTalk side.Below are the sample which I have,

    Input XML as follows:

    <Name>BOOLCHAND PESSOOMAL (B.E) B.V</Name>
          <NameAlias>BOOLCHAND PESSOOMAL</NameAlias>
          <PartyNumber>001501743</PartyNumber>
          <PrimaryAddressLocation>41000008645</PrimaryAddressLocation>
          <PrimaryContactFax>5637190349</PrimaryContactFax>
          <PrimaryContactPhone>5637190347</PrimaryContactPhone>
          <RecId>5637191078</RecId>
          <RecVersion>1920779873</RecVersion>
          <DirPartyPostalAddressView class="entity">
           <Address>Freezone Block D-I # 1 Curacao ANT</Address>
           <City>Curacao</City>
           <CountryRegionId>ANT</CountryRegionId>
           <IsLocationOwner>Yes</IsLocationOwner>
           <ISOcode>AN</ISOcode>
           <IsPrimary>Yes</IsPrimary>
           <IsPrivate>No</IsPrivate>
           <Location>5637212086</Location>
           <LocationName>BOOLCHAND PESSOOMAL (B.E) B.V-1310000BOO1000-11</LocationName>
           <Party>001501743</Party>
           <PartyLocation>5637191082</PartyLocation>
           <PostalAddress>5637203080</PostalAddress>
           <RecId>5637191082</RecId>
           <Roles>Invoice</Roles>
           <Street>Freezone Block D-I # 1</Street>
           <TimeZone xsi:nil="true" />
           <ValidFrom>2015-04-25T22:44:14Z</ValidFrom>
           <ValidTo>2154-12-31T23:59:59Z</ValidTo>
          </DirPartyPostalAddressView>
          <DirPartyPostalAddressView class="entity">
           <Address>50 Front Street
    PHILIPSBURG, ST. MAARTEN
    ANT</Address>
           <City>PHILIPSBURG, ST. MAARTEN</City>
           <CountryRegionId>ANT</CountryRegionId>
           <IsLocationOwner>Yes</IsLocationOwner>
           <ISOcode>AN</ISOcode>
           <IsPrimary>No</IsPrimary>
           <IsPrivate>No</IsPrivate>
           <Location>5637212088</Location>
           <LocationName>BOOLCHAND PESSOOMAL (B.E) B.V</LocationName>
           <Party>001501743</Party>
           <PartyLocation>5637191083</PartyLocation>
           <PostalAddress>5637203081</PostalAddress>
           <RecId>5637191083</RecId>
           <Roles>Delivery</Roles>
           <Street>50 Front Street</Street>
           <TimeZone xsi:nil="true" />
           <ValidFrom>2015-04-25T22:44:14Z</ValidFrom>
           <ValidTo>2154-12-31T23:59:59Z</ValidTo>
          </DirPartyPostalAddressView>
          <DirPartyPostalAddressView class="entity">
           <Address>HAVENSTRAAT 25 PO BOX 170
    ORANJESTAD, ARUBA
    ANT</Address>

    Expected Output:

    4300000MEDLAB26|Medical Laboratory Services|||95 Eastern Main Road|St. Augustine|Trinidad|||||
    4310TST26|TALK MOBILE|||CORNER ELEANOR ST & SMR|CHAGUANAS||||TT||
    4310TSTCMTH26|CM Technologies|||Ground Floor|Edan's Center Mall ,|Upper High St , San Fernando|||||
    4310TSTCP108926|NOVA QUANTUM LIMITED|||PIARCO INTERNATIONAL AIRPORT|PIARCO||||TT||
    4310TSTCP109026|LET'S TALK CELLULAR OUTLET|||137 SOUTHERN MAIN ROAD|AROUCA||||TT||

    Result I get because of that breakpoint:

    |BERMUDA DIGITAL COMMUNICATIONS|||5 Reid Street Kitson Building, 2nd Floor
    HAMILTON,HM 11
    BMU||HAMILTON||HM 11|BMU|Invoice|
    |BERMUDA DIGITAL COMMUNICATIONS|||5 Reid Street Kitson Building, 2nd Floor
    HAMILTON,HM 11
    BMU||HAMILTON||HM 11|BMU|Delivery|
    |BLACKBERRY|||295 PHILLIP STREET
    WATERLOO,ONN2L 3W8
    CAN||WATERLOO|ON|N2L 3W8|CAN|Invoice|
    |BLACKBERRY|||295 PHILLIP STREET
    WATERLOO,ONN2L 3W8

    Kindly help me out with this.


    ashwin

    Wednesday, August 12, 2015 2:26 PM

Answers

  • All you want to do is remove the linefeed characters from the address.

    In the Map, connect the source and destination through a Scripting Functoid with code such as:

    public string replaceLF(string input)
    {
         return System.Text.RegularExpressions.Regex.Replace(input, @"\r\n?|\n", String.Empty);
    }
    

    • Marked as answer by sukra1234 Wednesday, August 12, 2015 4:02 PM
    Wednesday, August 12, 2015 3:50 PM
    Moderator

All replies

  • Hi Ashwin ,

    The solution is to modify the incoming message in Pipeline component .

    For this you need to create a pipeline component which would replace e fields with understandable values.

    Create a custom pipeline component which has the execute method implemented as per below and drop this component in the decode stage of your receive pipeline.

    Below is the sample code

    You need to modify the Xpath and the field element by debugging the Pipeline component

     public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { 
    
    if (pInMsg == null || pInMsg.BodyPart == null || pInMsg.BodyPart.Data == null)
    {
    throw new ArgumentNullException("pInMsg");
    }
    
    var xmlDoc = new XmlDocument();
    pInMsg.BodyPart.GetOriginalDataStream().Seek(0, SeekOrigin.Begin);
    xmlDoc.Load(pInMsg.BodyPart.GetOriginalDataStream());
    try
    {
    
    XmlNode statusNode = xmlDoc.SelectSingleNode("/*[local-name()='Applications' and
    
    namespace-uri()='http://Company.Project.BT.Schemas.SchemaName_v1_0']/*[local-name()='Application'
    
    and namespace-uri()='']/*[local-name()='StageFlag' and namespace-uri()='']");
    
    if (statusNode != null)
    {
    
    Trace.WriteLine("Checking if StageFlag node is empty...");
    if (string.IsNullOrEmpty(statusNode.InnerText))
    {
    
    statusNode.InnerText = "new value";
    
    var ms = new MemoryStream();
    xmlDoc.Save(ms);
    ms.Seek(0, SeekOrigin.Begin);
    pInMsg.BodyPart.Data = ms;
    
    }
    
    }
    
    //this is required or else the next component will fail.
    
    pInMsg.BodyPart.GetOriginalDataStream().Seek(0, SeekOrigin.Begin);
    
    }
    
    catch (Exception ex) { throw; }
    
    return pInMsg;
    }

    Thanks

    Abhishek

    Wednesday, August 12, 2015 3:09 PM
  • All you want to do is remove the linefeed characters from the address.

    In the Map, connect the source and destination through a Scripting Functoid with code such as:

    public string replaceLF(string input)
    {
         return System.Text.RegularExpressions.Regex.Replace(input, @"\r\n?|\n", String.Empty);
    }
    

    • Marked as answer by sukra1234 Wednesday, August 12, 2015 4:02 PM
    Wednesday, August 12, 2015 3:50 PM
    Moderator
  • Thanks John ,

    Its working perfectly now.


    ashwin

    Wednesday, August 12, 2015 4:02 PM