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.  webMethods 10.7 trial - java service issue

    Posted Sun May 30, 2021 12:10 AM

    Hi Friends,

    I am trying to exploring 10.7 trial version and while using the java service I am facing a weird exception or issue

    I have created a java service with below details
    Java service —start
    with in put - inputInts (string list) and output - testInt
    public static final void sumOfMarks(IData pipeline) throws ServiceException {
    IDataCursor pipelineCursor = pipeline.getCursor();
    String inputInts = IDataUtil.getStringArray( pipelineCursor, “inputInts” );

    		int ttestInt=0;
    
    for (int i=0;i<inputInts.length;i++)
    {
    ttestInt=ttestInt+Integer.valueOf(inputInts[i]);
    }
    IDataUtil.put( pipelineCursor, "testInt", ttestInt);
    pipelineCursor.destroy();
    

    The java service is working fine and giving the expected results
    the issue is when I am calling this java service in an IS service / flow

    here the branch condition is working fine (testInt >5, here testInt is the output of java service) and when I am passing the same value to addInts service I am getting the exception as shown in picture parameter num1 is missing.

    Not only with this service, I have created another couple of java services but facing the same issue. Please suggest.

    thanks,
    Madhava


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


  • 2.  RE: webMethods 10.7 trial - java service issue

    Posted Mon May 31, 2021 05:10 AM

    Hi,

    can you provide the input/output Signature of the servie test please?

    Did you try to debug the service test to see at which step it fails?

    I assume that your service test has a mandatory input named num1 which is not set when running the service.

    Regards,
    Holger


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


  • 3.  RE: webMethods 10.7 trial - java service issue

    Posted Wed June 09, 2021 11:46 AM

    HI
    You need to convert the integer to string in output ,make the changes in the java service as below.

                                      int ttestInt=0;		        
    for (int i=0;i<inputInts.length;i++)
    {
    ttestInt=ttestInt+Integer.valueOf(inputInts[i]);
    }
    String s =String.valueOf(ttestInt);
    IDataUtil.put( pipelineCursor, "testInt", s);
    pipelineCursor.destroy();
    

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


  • 4.  RE: webMethods 10.7 trial - java service issue

    Posted Wed June 09, 2021 12:21 PM

    Can simplify:

    int ttestInt=0;		        
    for (int i=0;i<inputInts.length;i++)
    {
    ttestInt=ttestInt+Integer.valueOf(inputInts[i]);
    }
    IDataUtil.put( pipelineCursor, "testInt", ttestInt+""); // This will convert the int to a string
    pipelineCursor.destroy();
    

    Side note: I know you’re just using this to explore, but adding a list of numbers does not need to be done in Java. You can do it with FLOW very much the same way.


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