IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to convert a string of values into a list of values

    Posted Thu March 24, 2022 01:23 AM

    Hi,
    I’m trying to convert this string: {1,2,3,4,5,6,7,8,9} into a list of values 1 2 3 4 5 6 7 8 9.
    I have created a java service, but I am getting these brackets as well, could you please help me out?
    here is what i have done, your advice is always beneficial.
    Thanks in advance.


    this is the java service which is getting a string and returning a list

    this is the first map of my flow service

    this is the 2nd map of my flow service

    and this is the result i’m getting

    Regards
    hmafzal


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #Service-Designer


  • 2.  RE: How to convert a string of values into a list of values

    Posted Thu March 24, 2022 02:04 AM

    Hi @hmafzal ,
    Have you tried checking the built in services especially the pub.string services , https://documentation.softwareag.com/webmethods/integration_server/pie10-5/10-5_Integration_Server_Built_In_Services_Reference.pdf,
    You may not need to write a java service.
    You can use the pub.string:substring to remove the { symbol at the first index , followed by pub.string:tokenize passing , as an delimiter.

    -NP


    #Service-Designer
    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: How to convert a string of values into a list of values



  • 4.  RE: How to convert a string of values into a list of values

    Posted Thu March 24, 2022 02:06 AM

    Hi @hmafzal,

    This could be solved in many ways, it is on the logic that you want to get your string converted to a list of elements.

    If you are sure that every time your input is going to within { } then you could trim that off in your java service, just like this input = input.substring(1, input.length()-1);

    Try and let me know if it works as per your expectation.

    Thanks,
    Sree


    #webMethods
    #Flow-and-Java-services
    #Service-Designer
    #Integration-Server-and-ESB


  • 5.  RE: How to convert a string of values into a list of values

    Posted Thu March 24, 2022 03:20 AM

    Hi Sreekhanth
    I’m really thankful for your reply.
    it is working like a charm.
    Regards
    hmafzal


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #Service-Designer
    #webMethods


  • 6.  RE: How to convert a string of values into a list of values

    Posted Thu March 24, 2022 03:51 PM

    Glad to see you used split instead of tokenize. The tokenize method has behaviors that you likely do not want.

    Regarding calling demoStrToChars is there a reason to call that using a transformer? Not an issue per se, but often people use transformers thinking it has behaviors that do not exist. We have a convention where if the transformer is the only item in the MAP step, don’t use a transformer. Just invoke the service. Improves readability.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods
    #Service-Designer