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.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Referencing child strings of a document list

  • 1.  Referencing child strings of a document list

    Posted Fri March 07, 2014 11:35 AM

    Hi All,
    I’m new to webMethods and I am stuck at something very basic.

    I want to loop around the output of wm.server.ns:getPackages which is a document list and assign the pkg_name to a string. The loop works but although I can see the package names in the variables window I cant seen to get at the string values. I guess I need to map the Packages[i] to a document but have tried many attempts unsuccesfully. I must be missing something obvious.

    Any help would be much appreciated.

    Thanks,
    Frank.


    #Integration-Server-and-ESB
    #webMethods-General
    #webMethods


  • 2.  RE: Referencing child strings of a document list

    Posted Fri March 07, 2014 02:24 PM

    Welcome to SAG webMethods :slight_smile:

    Can you let me know the version of webMethods you are using (I can provide you some start off tips)

    Can you let me know you are requirement in brief? so that I can help you.

    Flow logic should be something like

    inputs: NA
    output: Doc list (packages) under this you can have two string variables pkg_name and pkg_type

    Call wm.server.ns:getPackages
    Loop over /packages
    Inside loop you can have a MAP step (Map output of wm.server.ns:getPackages to your output)

    I hope it wont be clear but anyways feel free to ask us anytime :slight_smile:


    #webMethods
    #Integration-Server-and-ESB
    #webMethods-General


  • 3.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 06:18 AM

    Hi Manesh,
    Thanks for replying.

    webMethods 8.2
    I’ve attached a word doc with some screen shots.

    I had coded the flow service as you suggested and I can see the repeating ‘packages’ nodes, each with it’s two child nodes but no matter what format of path I use (in a debug step) or element I try to map I cannot get at the values. As you can see in the variables window, the values are there.

    I’ve tried %pkg_name%, %packages/pkg_name% and %/packages/pkg_name% and checked ‘variable substitution’ but I always see the name of the variable and not the value. 2nd screen shot is of the server logs.

    Please try it yourself and if you can get a degub or a map to work let me know either the path or format of duocument you’ve had to create to map the packages nodes to.
    Thanks again for your help.
    Frank.

    screenshots.docx (426 KB)


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 07:06 AM

    Hi,
    Can you let me know you are requirement in brief?

    I mean after you get the package name what are you trying to do with that?


    #Integration-Server-and-ESB
    #webMethods-General
    #webMethods


  • 5.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 07:12 AM

    I’d be happy for now just to get the name of the package in a string so I can debug to the logs or put it in a document I can refer to later.

    Over time I’d like to write a service which iterates over packages and output some basic details. I’m using this to learn more about flow and how to navigate over data structures.

    Do I have to map the packages data to a document before I can get access to it? If so what would the document look like. I’v tried several shapes but after the MAP statement it does not appear in the output pipeline or it does but it’s empty.


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 6.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 07:29 AM

    If you directly use the path of the document element as an input for another service, you need to set the “Enable Variable substituion” check box, other wise (of if the value of the element is empty) the name of the variable will remain in the string.

    The correct path of the element can be evaluated by right clicking on the desired element and select “Copy”.
    After that you can paste it into the string where it should appear and surround it with “%” as a marker for a variable.

    If the source is a list, i.e. packages, you will need to loop over it to get access to each element in it.

    If you exactly know which element you need you can reference it as %packages[index]/pkg_name%, by index starting with 0.

    Regards,
    Holger.


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB


  • 7.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 07:44 AM

    I did that. I am looping over /packages and have a debug step within my loop.

    when I right click and COPY the variable it returns this:-

    packages/packages[0]/pkg_name

    so my debug message input looks like this:-

    %$iteration% %packages/packages/pkg_name%

    but on the log output I get:-

    2014-03-10 10:36:40 GMT [ISP.0090.0003C] 1 %packages/packages/pkg_name%
    2014-03-10 10:36:42 GMT [ISP.0090.0003C] 2 %packages/packages/pkg_name%
    2014-03-10 10:36:43 GMT [ISP.0090.0003C] 3 %packages/packages/pkg_name%

    and I have ticked ‘perform variable substitution’.

    I must be doing something wrong?


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB


  • 8.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 07:58 AM

    Try the COPY action inside the Loop not outside, then it should return the correct path.

    Are you sure about the packages-Structure returned by the first service invocation?

    I just jecked with Developer 7.1.3:

    There the field which contains the name of the packages is only named “name”.

    So the variable should read as %packages/name%

    Regards,

    Holger


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 08:43 AM

    Hi Holger,
    Thanks for helping.
    Please have a look at the attachment. I’ve added a 4th screen shot. In the 1st screen shot variables window you can see the child nodes of ‘packages’ named ‘pkg_name’ and ‘pkg_type’.

    I understand what you say about getting the path from within the loop but when I right click in the variables window on the child ‘pkg_name’ node during Debug there is only a ‘Copy Variable’ option which is not what I want. In the Pipeline window when I expand the ‘packages’ node it is empty so I cannot right click the expected child node.

    I’m sorry if this is very basic I just don’t understand why I can see the child nodes and values in the Variables window but not in the pipeline window?
    Thanks again.
    Frank.


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 08:44 AM


  • 11.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 08:46 AM


  • 12.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 10:08 AM

    Hi,

    unfortunately these services are not documented to public as they are part of the (usually hidden) WmRoot-Package.

    Please try wm.server.packages:packagesList instead, this service works for me.


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 13.  RE: Referencing child strings of a document list

    Posted Mon March 10, 2014 10:30 AM

    Holger - that worked first time!

    There must be something different about the output from the previous service I was using.

    Thank you very much for the alternative.
    Frank.


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB