Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2013-05-02T14:32:51Z by RalexRdz
RalexRdz
RalexRdz
7 Posts
ACCEPTED ANSWER

Pinned topic How to get rowCount of web service response

‏2013-04-26T20:38:41Z |

How can I get the number of rows that a webservice responds. I'm using a Web Service Call builder, fetching the services from a WSDL?

 

Thanks

  • kevintap
    kevintap
    746 Posts
    ACCEPTED ANSWER

    Re: How to get rowCount of web service response

    ‏2013-04-26T20:52:46Z  in response to RalexRdz

    There are a few ways that you can obtain a row count.  You may need to experiment to see if any of these suggestions perform better for your application.

    The response from the web service is a WEF IXml object.

    One option is to use the Transform Aggregate builder.  This builder provides a way to apply aggregate functions to a repeating XML structure.  You can use the count operator to obtain a row count.  This is probably the most high level option and wouldn't require writing any Java code.

    Alternatively, if you're comfortable with Java code and/or you already have a LJO class that is working with the result data in some way, one of the following options may be more convenient.

    You can write a method in a Method builder or LJO class to iterate through the IXml object using IXml.getFirstChildElement()/IXml.getNextSiblingElement() and incrementing a counter variable for each time through the loop.

    Also in a Method builder or LJO class, you can call IXml.getChildren() which provides a java.util.List object.  You can call the size() method on the List object to get a count of children in the XML.

     

    • RalexRdz
      RalexRdz
      7 Posts
      ACCEPTED ANSWER

      Re: How to get rowCount of web service response

      ‏2013-04-30T16:21:36Z  in response to kevintap

      Thanks! I've tried to used the Transform Aggregate builder, but I can't find the way to get the value of the count function. I didn't get completely what does the inputs mean. I keep getting the same results as it was the response, without any modifications. Do you have an example of how to use this builder?

      I will also try the Java method and I let you know.

      Thanks!

      • RalexRdz
        RalexRdz
        7 Posts
        ACCEPTED ANSWER

        Re: How to get rowCount of web service response

        ‏2013-05-02T14:32:51Z  in response to RalexRdz

        I found a way around. I do all the parameter assignment in an AL and I send the paremeters as arguments to a method, where I do the IXml processing to count.

        Hope it works for someone else