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
  • 1.  exit and signal failure in java

    Posted Tue May 08, 2007 04:28 PM

    I would like to : exit and signal failure in a java service.

    Any one knows how to do that in java instead of flow?

    Thanks


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


  • 2.  RE: exit and signal failure in java

    Posted Tue May 08, 2007 04:56 PM
     
    
    //throwing exception in an if-then-else block
    if (<some condition>) {
    //do stuff
    } else {
    throw new ServiceException("Some error occurred: <details>");
    }
    //throwing exception in try-catch block
    try {
    //do stuff that might cause exception
    } catch (Exception ex) {  //use generic Exception or more specific one
    throw new ServiceException("Some exception occured:  " + ex);     
    }    

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


  • 3.  RE: exit and signal failure in java

    Posted Tue May 08, 2007 05:00 PM

    Thanks but are you sure this works?
    I have this now but no exit and signal failure

      message = "Error:SyntaxCheck................... ";
    try {
    Values vv = new Values ();
    vv.put ("message", message);
    vv.put ("function", "LOGOP");
    vv.put ("level", 4);
    Service.doInvoke ("pub.flow", "debugLog", vv);
    } catch (Exception elog) { throw new ServiceException (message );}
    

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


  • 4.  RE: exit and signal failure in java

    Posted Tue May 08, 2007 11:06 PM

    What precisely are you seeing? And what do you expect to happen?


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


  • 5.  RE: exit and signal failure in java

    Posted Wed May 09, 2007 12:25 PM

    my message is written in the serverlog, thats all I see

    when I use the flow commands EXIT with the option “signal failure”
    then control goes to the catch block, that good.
    but there fore I have to add a branch and an exit command after my java service.

    I do not think that is elegant, I rather would like to
    program the functionality: “exit with signal failure” as java statements so I do not have to add 2 flow commands after my java service.

    I added a screenShot as an attachmant, not sure how you can get it
    wm1000031.jpg


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


  • 6.  RE: exit and signal failure in java

    Posted Wed May 09, 2007 02:15 PM

    Perhaps you would find the ExceptionHandling examples in the WmSamples package useful. Starting with IS 6.5, you have to download that package from Advantage.

    Mark


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


  • 7.  RE: exit and signal failure in java

    Posted Wed May 09, 2007 04:07 PM

    This conversation is a bit muddled, but i think that gerarddoets is looking for something a bit odd.

    gerarddoets, if you want it to always signal failure and exit, try this:

    message = "Error:SyntaxCheck… ";
    Values vv = new Values ();
    vv.put (“message”, message);
    vv.put (“function”, “LOGOP”);
    vv.put (“level”, 4);
    Service.doInvoke (“pub.flow”, “debugLog”, vv);
    throw new ServiceException (message );

    Good luck, i may not be understanding exactly what you are trying to do. Give it a try, if it does what you want, great! If not, let us know more details about what you are trying to accomplish.

    Thanks!
    -greg


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


  • 8.  RE: exit and signal failure in java

    Posted Wed May 09, 2007 05:40 PM

    “but there fore I have to add a branch and an exit command after my java service”

    Your branch and exit flow and signal failure are never executed because the testGerard step is throwing an exception and exiting your FLOW service right then and there.

    Calling a Java service is no different than calling any other service (FLOW or Java). If the service can throw an exception, and you want to catch it, use a try/catch structure.

    SEQUENCE (Exit on SUCCESS)
    …SEQUENCE (Exit on FAILURE)
    …testGerard (may throw ServiceException)
    …SEQUENCE (Exit on DONE)
    …pub.flow:getLastError (lastError holds ServiceException info)
    …(do anything else)

    Given the Java code snippet you posted, I have to ask why you’re writing a Java service? Can what you’re doing in Java be done using FLOW?


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


  • 9.  RE: exit and signal failure in java

    Posted Thu May 10, 2007 11:01 AM

    at first I did not see your mods but after then,
    works fine now
    Thx


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