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
Expand all | Collapse all

Integration Server (IS) cannot subtract resource from path

  • 1.  Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 06:43 AM

    Hi guys, I have the following path url/records/848669637/names/1756

    I need to substring 1756 as resource, how can I achieve this? transformer substring doesn’t seem to have indexOf to select my start, the lenght could change and it does not work.

    e.g /^names/:SEQUENCE

    then get 1756


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


  • 2.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 07:16 AM

    pub.string:substring does allow you to specify the indices (begin and end), but you need to manipulate the position as follows -

    1. Get the length of your desired string (i.e., /names/)
    2. Use the pub.string:indexOf service to get the index of your desired string (i.e., /names/) in your inputString
    3. Add the value from step 2 with the length from step 1, to arrive at a new beginIndex
    4. Pass beginIndex to the substring service along with your inputString and it pops out “1756” as shown below

    KM


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


  • 3.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 07:46 AM


  • 4.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 08:29 AM

    Not necessarily easier (mainly a matter of taste) but another option is to use

    pub.string:tokenize

    which you can use to get all parts delimited by a specific character (e.g. /) as a string list. You just need to get the last entry of the list. This comes in handy especially if you need more parts than only one.


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


  • 5.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 08:50 AM

    I was going to suggest tokenize as an alternative, but the array index of the last element varies dynamically depending on the number of resources in the URL, so a static map will be a problem.

    KM


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


  • 6.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 09:04 AM

    A lastIndexOf service would have been quite useful , lastIndexOf(“/”) , followed by a subString would have done the trick quite easily. @Martin_Wroblinski , @Venkata_Kasi_Viswanath_Mugada1 - have you seen such a requirement many other times?

    -NP


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


  • 7.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 09:15 AM

    I’m quite sure, everybody faced this and just worked around, as it is quite easy, nevertheless I agree, as getting the last part (like filename or extension) is a really common use case.

    About the list out of the tokenize service: pub.list:sizeOfList gives you the size of the list, so just substract one and do an index map (you probably know this, but for the others):

    When mapping from a list to a single element, you can click the mapping line and enter an index, to select one element to be mapped. This index can be a runtime variable.


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


  • 8.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 09:24 AM

    You are right of course, @Martin_Wroblinski; I was only referring to tokenize as a standalone step :slight_smile:

    @Nagendra_Prasad, yes I’ve had numerous requirements for string manipulation utilities that I had to build.

    The most frequent one that I’ve used is a “search” type functionality to capture the number of ALL occurrences and positions, of a given substring (across multiple language encodings) in a single execution (link).

    KM


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


  • 9.  RE: Integration Server (IS) cannot subtract resource from path

    Posted Wed July 28, 2021 11:07 AM

    In general, I avoid tokenize and instead use split. tokenize has some behaviors that may not be desired, depending on the specific needs. I won’t list the differences here – plenty of good material on the web covers that.

    WmPublic does not have a split service. But it is trivial to create one in your own “public” package.

    Other useful services for your own public package would be splitPath, leveraging java.nio.file.Paths and Path classes to do the work. And splitURL, leveraging java.net.URL.


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