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

Dynamic Call of flow services

  • 1.  Dynamic Call of flow services

    Posted Wed May 21, 2003 09:48 AM

    How to call Flow services dynamically within other Flow services.

    Thanks…


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


  • 2.  RE: Dynamic Call of flow services

    Posted Wed May 21, 2003 10:07 AM

    Write a java service for com.wm.app.b2b.server.Service.doInvoke API. Use this java service to dynamically invoke any other service by passing the service name.


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


  • 3.  RE: Dynamic Call of flow services

    Posted Wed May 21, 2003 02:40 PM

    Any other way out without using JAVA…

    I am able to call dynamically, but by a REMOTE INVOKE, where the local BC server is created as a REMOTE server.

    Still looking around for other way outs !!!

    James : Could you post the code for the solution you gave. Thanks…

    Bhavani Shankar


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


  • 4.  RE: Dynamic Call of flow services

    Posted Wed May 21, 2003 05:00 PM

    Bhavani,

    If you are working with Ver 6.0, they have a new package WMUtilities. Look for the Javautilities folder, it has a service called ‘localinvoke’. You can use this for dynamic invoke.

    If you dont have this package, I can send you the code for it.

    Manohar


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


  • 5.  RE: Dynamic Call of flow services

    Posted Wed May 21, 2003 08:04 PM

    If you want to receive the output of that invoked service add this code.

    IData myDateConversion = IDataFactory.create();
    IDataCursor tmpHashCursor = myDateConversion.getCursor();
    tmpHashCursor.last();
    tmpHashCursor.insertAfter(“inString”, inString);
    tmpHashCursor.insertAfter(“currentPattern”, currentPattern);
    tmpHashCursor.insertAfter(“newPattern”, newPattern);
    tmpHashCursor.destroy();
    IData outIData = Service.doInvoke(“pub.date”, “dateTimeFormat”, myDateConversion);
    tmpHashCursor = outIData.getHashCursor();
    tmpHashCursor.first (“value”);
    inString = (String) tmpHashCursor.getValue();
    tmpHashCursor.destroy();

    HTH,
    Muru.


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


  • 6.  RE: Dynamic Call of flow services

    Posted Wed May 21, 2003 08:13 PM

    May be I am over enthu, I didnt look at what merge was doing. I am sorry about that.

    Thanks,
    Muru.


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


  • 7.  RE: Dynamic Call of flow services

    Posted Wed May 21, 2003 08:54 PM

    Just a little heads up. The position of the cursor when a positioning method fails is not defined, so if there ever could be a situation when “value” does not exist in the pipeline, the following code could return unexpected results:

    tmpHashCursor.first (“value”);
    inString = (String) tmpHashCursor.getValue();

    should be:

    if (tmpHashCursor.first (“value”))
    inString = (String) tmpHashCursor.getValue();

    or:

    inString = IDataUtil.getString(tmpHashCursor, “value”);


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


  • 8.  RE: Dynamic Call of flow services

    Posted Thu May 22, 2003 09:11 PM

    Manohar,

    Where does the WMUtilities package come from? I do not seem to have it in my installation…

    Thanks


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


  • 9.  RE: Dynamic Call of flow services

    Posted Fri May 23, 2003 08:00 AM

    The service is available in WMEDI package under the following location.

    wm.b2b.edi.util:invoke

    Thanks for all the help given…

    Cheers!
    Bhavani Shankar


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


  • 10.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 04:18 PM

    Hi

    How do I invoke a remote service using Service.doInvoke? How to specify the remote server name?

    Thanks
    Venkat


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


  • 11.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 06:09 PM

    Venkat,
    You don’t :-), at least not directly. I’d suggest you use Service.doInvoke to call pub.remote:Invoke. You can pass it a remote server alias, your service’s name and inputs. HTH.


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


  • 12.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 06:54 PM

    Michael,

    Can you provide usage code snippet for me? I’m confused with the parameters for the Service.doInvoke

    Thanks,
    Venkat


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


  • 13.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 06:59 PM

    Venkat,

    Check this out:
    IData output = Service.doInvoke(folderName, serviceName, pipeline).

    This is just a sample snippet.

    HTH.


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


  • 14.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 07:32 PM

    RMG,

    IData output = Service.doInvoke(“pub.remote”,“Invoke”,pipeline)

    Now where do I specify the server name alias and myremotefolder.remoteServiceName.

    Can someone throw ray of light !!

    Thanks
    Venkat


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


  • 15.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 07:47 PM

    I am not sure about how the remote invocation works in your case.

    The code snippet which i have posted above will work dynamically calling the service on local server.

    And please take a look into the webMethods JavaAPI reference and check under the Service class,which will show up all kinds of doInvoke().

    HTH.


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


  • 16.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 08:31 PM

    Ah, I see. I haven’t done this in Java, only in Flow. But you’d need to explicitly specify the input for pub.remote:Invoke, instead of “pipeline”. Not quite sure how to do that in Java, since there would be multiple inputs in one parameter. Maybe create a string variable to hold the inputs?:

    String remInvokeInputs = “<remote>, <folder.folder:service>”;
    IData output = Service.doInvoke(“pub.remote”, “Invoke”, remInvokeInputs);

    Anybody know if that would work?


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


  • 17.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 09:06 PM

    I think the correct way would be to use the com.wm.app.b2b.client.TContext class to establish the connection to the remote server and do your invocation. Basically, you want your server to act as a client to the remote server.

    I do not have a code sample, but this should help.


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


  • 18.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 09:27 PM

    David,

    You are right !!

    I found the sample code in http://advantage.webmethods.com and I’m pasting the same here.

    For those who want to invoke a remote service using webM Java API
    ////////////////////////////

    String host = “remoteserver:5555”;
    String user = “remoteuser”;
    String pass = “password”;
    String ifc = “folder”;
    String svc = “serviceName”;

    Context c = null;
    try {
    c = new Context();

    c.connect(host, user, pass);

    ValuesEmulator.put(pipeline, “result”, c.invoke(ifc, svc, IDataFactory.create()));

    c.disconnect();

    } catch (Exception e) {
    if (c != null) {
    try {
    c.disconnect();
    } catch (Exception ee) {
    // ignore this…
    }
    }
    throw new ServiceException("Error during invoke: " + e.getMessage());
    }

    ///////////////////////////
    This code doesn’t fetch output from the remote service.

    Hope this helps…

    Thanks everybody !!
    Venkat


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


  • 19.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 09:31 PM

    Take a quick look at the 5th and 6th postings on this thread. This will give you the generic form of how to set pipeline variables for a service invocation. The only other thing that you would need to do is take a look at the service signature your target service (i.e. pub.remote:invoke).

    Inputs that appear at the top level are inserted directly into your new pipeline. Nested inputs need to be contained in another IData container. There’s a sample of creating a nested IData input for a service in the WmSamples package; take a look in the folder sample.idata at the service createNestedIData.

    hth


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


  • 20.  RE: Dynamic Call of flow services

    Posted Thu October 02, 2003 10:18 PM

    Using the Context class is fine too. No transactions though… The code should look quite the same…


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