webMethods

webMethods

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.  Loop service statement confusion

    Posted Tue August 21, 2012 09:24 AM

    Greetings,

    My company started using webMethods (7.1.2) and I have quite a confusion with the loop statements. I’m trying to create a service that creates a list from a book catalog.
    I have and XSD schema included in my package as a Document Reference; with the following xml structure:[INDENT]Request[/INDENT]

    Books

    Book → Array.

    [INDENT=4]@id
    Author
    Title
    Genre
    Price
    Pub_Date
    Review[/INDENT]
    What I’m trying to do is quite simple. I’m trying to iterate through on each book with a look statement like:
    LOOP over ‘/Request/books/book’
    And here I want to append each author to a StringList like:Ű
    pub.list:appendToStringList

    MAPPING:

    [INDENT=2]Request/books/book/author → fromItem
    Result (added as output to the flow service with stringList type) → toList
    appendToStringList service out toList → Result.[/INDENT]
    What happens is, when I execute my service I have only the first author is filled and every other is null.

    Any help would be great.

    Thank you in advance.
    Regards,
    Joe


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


  • 2.  RE: Loop service statement confusion

    Posted Tue August 21, 2012 01:48 PM
    • Make sure you mapped from the correct input (check if the list has become a single item within the loop). If you made the map before adding the loop, webMethods doesn’t change the existing used list to a single item but adds a new reference. If you have one version mapped with the list and another with a single item, remove the map line, select another step and go back to the map step. The doublette will be gone and cou can no map the correct item (Hope this makes sense but the pipeline has some strange behaviours if you are not used to it).
    • if you use append to list in a loop, make sure to drop the document or string your are apping from at the end of the loop- Otherwise you get the same item all over again.
    • if the list you wwant to generate get the same amount of items as the list your are getting from, you do not need to use append to list. Just map into a single text element (or document) and place it’s name into the output array field of the loop step. Is will automatically generate a list as loop output.

    Regards

    Martin


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


  • 3.  RE: Loop service statement confusion

    Posted Wed August 22, 2012 08:17 AM

    You were right. Inside the loop statement my StringList has became a simple string. Taking out the Stringlist from the output array property of the loop and adding the string list directly to the pipeline (instead of I/O params) solves the problem. Thank you very much for your help.


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