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
Expand all | Collapse all

How to unhide the built-in java services.

  • 1.  How to unhide the built-in java services.

    Posted Mon March 28, 2011 04:31 PM

    Hi all, please let me know how can I unhide the built in java services in webMethods Developer.

    I know something should be made “False”, can you please let me know the exact steps to make it happen.

    Thanks,
    Venkat.


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


  • 2.  RE: How to unhide the built-in java services.

    Posted Mon March 28, 2011 04:39 PM


  • 3.  RE: How to unhide the built-in java services.

    Posted Mon March 28, 2011 07:22 PM

    Hi Reamon, thanks for your reply, please let me know why shouldn’t I unhide it.

    I want to know what code is there in those built-in java services because it might help me code my own java services.

    I am trying to invoke a built-in java service like below

    context.invoke(“pub.file”,“getFile”,fileName);

    and take it’s output and giving to my java service. In this case I dont know how can I give the output of the built-in java service to my java service.

    Please let me know how can I code to retrieve that data.

    Thanks,
    Venkat.


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


  • 4.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 03:12 AM

    Output of pub.file:getFile service is nothing but content of the file in Object format… The output attribute name - you can see it from Developer though you cannot see the code… I am not getting, whats the issue in knowing the output of the java service…

    Senthil


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


  • 5.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 03:01 PM

    Hi Senthil, I can see the output but when I am trying to retrieve the data of the output from “getFile” I am getting null. Thats my problem.

    This is the code

    try {
    string=context.invoke(“pub.file”,“getFile”,fileName);
    } catch(Exception e) {
    e.printStackTrace();
    throw new ServiceException(“\n”+“Could not invoke the file”);
    }
    try {
    if(pipeLineCursor.first(“body”)) {
    body=IDataUtil.getIData(pipeLineCursor,“body”);
    bodyCursor=body.getCursor();
    if(bodyCursor.first(“string”)) {
    string=IDataUtil.getIData(bodyCursor,“string”);
    stringCursor=string.getCursor();
    xmlFileData=(String) stringCursor.getValue();
    }
    }
    /if(pipeLineCursor.first(“body”) && bodyCursor.first(“string”)) {
    xmlFileData=(String) stringCursor.getValue();
    }
    /
    } catch(Exception e) {
    e.printStackTrace();
    throw new ServiceException(“\n”+“Could not retrieve data from the file”);
    }

    Please let me know if I did anything wrong in retrieving it.

    Thanks,
    Venkat.


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


  • 6.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 03:18 PM

    Why are you writing this using a Java service? Why not use FLOW?


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


  • 7.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 05:05 PM

    It was told to me that I should write java service because this java service contains “Ehcache” logic for caching. In this case I am creating the cache xml file and trying to read this file with the “getFile” java service.

    I am not getting the getFile service data, it is null. I dont know what is the problem in it.

    And just now my Team lead told to complete it today itself.

    I have attached the code, please check it.

    Please do help me out.

    Thanks,
    Venkat.
    Webmethod Cache Code.txt (4.17 KB)


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


  • 8.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 05:47 PM

    You’re using the wrong pipeline cursor to retrieve the pipeline values returned by the getFile call. The “string” variable (which should be renamed because it is not a string–it is an IData object) is separate from the “pipeline” var defined for the service and pipeLineCursor is referring to the “pipeline” pipeline not the “string” pipeline.

    Also, getFile does not return a variable named “string”. Refer to the Built-In Services Reference for what it does return.

    You may want to go over this with your lead as these are pretty basic things.

    Additionally, I’m not entirely certain that using the Context class is necessary/advisable in this situation.


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


  • 9.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 06:34 PM

    Hi Raemon, I see what you are saying, but we are using webMethods 8.0 which has the outputs for “getFile” java service as

    body - Document

    under this

    bytes - object
    stream - object
    reader - object
    string - String

    So here we can use anything to get the data of the file using “loadAs=any of the four”.

    So I have changed the code a little bit but still the problem exists, please let me know what you think.


    IData loadAs=IDataFactory.create();
    IDataCursor loadAsCursor=loadAs.getCursor();
    loadAsCursor.setValue(((Object) “string”));
    try {
    context.invoke(“pub.file”,“getFile”, loadAs);
    body=context.invoke(“pub.file”,“getFile”,fileName);
    } catch(Exception e) {
    e.printStackTrace();
    throw new ServiceException(“\n”+“Could not invoke the file”);
    }
    try {
    bodyCursor=body.getCursor();
    if(bodyCursor.first(“string”)) {
    string=IDataUtil.getIData(bodyCursor,“string”);
    stringCursor=string.getCursor();
    xmlFileData=(String) stringCursor.getValue();
    }
    /if(pipeLineCursor.first(“body”)) {
    body=IDataUtil.getIData(pipeLineCursor,“body”);
    bodyCursor=body.getCursor();
    if(bodyCursor.first(“string”)) {
    string=IDataUtil.getIData(bodyCursor,“string”);
    stringCursor=string.getCursor();
    xmlFileData=(String) stringCursor.getValue();
    }
    }
    /
    /if(pipeLineCursor.first(“string”)) {
    string=IDataUtil.getIData(bodyCursor,“string”);
    stringCursor=string.getCursor();
    xmlFileData=(String) stringCursor.getValue();
    }
    /
    /if(pipeLineCursor.first(“body”) && bodyCursor.first(“string”)) {
    xmlFileData=(String) stringCursor.getValue();
    }
    /
    } catch(Exception e) {
    e.printStackTrace();
    throw new ServiceException(“\n”+“Could not retrieve data from the file”);
    }

    Thanks,
    Venkat.


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


  • 10.  RE: How to unhide the built-in java services.

    Posted Tue March 29, 2011 09:36 PM

    Sorry on the getFile parameters. I didn’t know about the changes in 8.0.

    You need one more level of IData retrieval/cursor. The call to getFile returns a pipeline that contains “body”.

    [highlight=java]
    try {
    context.invoke(“pub.file”,“getFile”, loadAs);
    result=context.invoke(“pub.file”,“getFile”,fileName);
    } catch(Exception e) {
    e.printStackTrace();
    throw new ServiceException(“\n”+“Could not invoke the file”);
    }

    try {
    resultCursor = result.getCursor();
    body = IDataUtil.getIData(resultCursor,“body”);
    bodyCursor=body.getCursor();
    xmlFileData=IDataUtil.getIData(bodyCursor,“string”);
    }
    …[/highlight]
    Hope this helps. If you need additional help with reading IData hierarchies please get with your project lead. As I mentioned, this is pretty basic stuff that the lead should be able to show you fairly quickly.

    P.S. Don’t forget to destroy your cursors.


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


  • 11.  RE: How to unhide the built-in java services.

    Posted Wed March 30, 2011 12:51 AM

    Hi Reamon, please find the code and exception that is occuring attached.
    Please open this code in the “Eclipse” and you will know what is the exception.

    I am getting

    [SIZE=2][COLOR=#000080]com.wm.app.b2b.server.ServiceException

    exception[COLOR=#000080]

    When we give the “fileName” variable to built-in service “getFile”, the exception is happening here. I dont know why it is saying that

    [SIZE=2][SIZE=2][COLOR=#ff0000]Missing Parameter: filename
    [COLOR=#ff0000]
    I have no idea what is wrong in this.

    Please open this code in “Eclipse” you will know about exception.

    Thanks,
    Venkat.
    [/COLOR][/COLOR][/SIZE][/SIZE][/COLOR][/COLOR][/SIZE]
    Exception.txt (2.17 KB)
    Cache Code.txt (5.62 KB)


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


  • 12.  RE: How to unhide the built-in java services.

    Posted Wed March 30, 2011 04:16 PM

    The code isn’t setting the IData objects properly to pass to the getFile service. Is noone else on your team available to help you with this?


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


  • 13.  RE: How to unhide the built-in java services.

    Posted Wed March 30, 2011 04:21 PM

    Do you have access to Developer or someone that does? If so, use the generate code feature to create the code that can call the service from a Java client. You can merge the generated code into your existing code to call getFile successfully.


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


  • 14.  RE: How to unhide the built-in java services.

    Posted Wed March 30, 2011 10:49 PM

    Hi Reamon, thanks for helping me out but unfortunately I have one problem. When I am invoking the built-in service, it is not getting the data from that file, here is the code

    IData loadAs=IDataFactory.create();
    [SIZE=2]

    String s=[/size]“string”[SIZE=2];

    loadAsCursor.setValue(((Object) s));[/size]

    try {
    context.invoke(“pub.file”,“getFile”, loadAs);
    result=context.invoke(“pub.file”,“getFile”,fileName);
    } catch(Exception e) {
    e.printStackTrace();
    thrownew ServiceException(“\n”+“Could not invoke the file”);

    }

    try {
    if(resultCursor.first(“body”)) {
    body=IDataUtil.getIData(resultCursor,“body”);
    bodyCursor=body.getCursor();
    if(bodyCursor.first(“string”)) {
    xmlFileData=IDataUtil.getString(bodyCursor,“string”);
    }
    }
    } catch(Exception e) {
    e.printStackTrace();
    throw new ServiceException(“\n”+“Could not retrieve data from the file”);
    }

    The exception is

    [SIZE=2]com.wm.app.b2b.server.ServiceException

    : [ISS.0086.9249] Missing Parameter: filename[SIZE=2][COLOR=#ff0000]

    at pub.CommonUtils.getRequiredObjParam(

    [/COLOR][/SIZE]

    CommonUtils.java:85)[SIZE=2][COLOR=#ff0000]

    at pub.CommonUtils.getRequiredStrParam(

    [/COLOR][/SIZE]

    CommonUtils.java:51)[SIZE=2][COLOR=#ff0000]

    at pub.file.getFile(

    [/COLOR][/SIZE]

    file.java:956)[SIZE=2][COLOR=#ff0000]

    at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(

    [/COLOR][/SIZE]

    DelegatingMethodAccessorImpl.java:25)[SIZE=2][COLOR=#ff0000]

    at java.lang.reflect.Method.invoke(

    [/COLOR][/SIZE]

    Method.java:597)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.JavaService.baseInvoke(

    [/COLOR][/SIZE]

    JavaService.java:439)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.InvokeManager.process(

    [/COLOR][/SIZE]

    InvokeManager.java:635)[SIZE=2][COLOR=#ff0000]

    at codecoverage.base.CodeCoverageProcessor.process(

    [/COLOR][/SIZE]

    CodeCoverageProcessor.java:191)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(

    [/COLOR][/SIZE]

    ReservationProcessor.java:46)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(

    [/COLOR][/SIZE]

    StatisticsProcessor.java:44)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(

    [/COLOR][/SIZE]

    ServiceCompletionImpl.java:238)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.ValidateProcessor.process(

    [/COLOR][/SIZE]

    ValidateProcessor.java:51)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.PipelineProcessor.process(

    [/COLOR][/SIZE]

    PipelineProcessor.java:171)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.ACLManager.process(

    [/COLOR][/SIZE]

    ACLManager.java:272)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.DispatchProcessor.process(

    [/COLOR][/SIZE]

    DispatchProcessor.java:30)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.AuditLogManager.process(

    [/COLOR][/SIZE]

    AuditLogManager.java:399)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.InvokeManager.invoke(

    [/COLOR][/SIZE]

    InvokeManager.java:539)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.invoke.InvokeManager.invoke(

    [/COLOR][/SIZE]

    InvokeManager.java:384)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.ServiceManager.invoke(

    [/COLOR][/SIZE]

    ServiceManager.java:234)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.ServiceManager.invoke(

    [/COLOR][/SIZE]

    ServiceManager.java:109)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.HTTPInvokeHandler._process(

    [/COLOR][/SIZE]

    HTTPInvokeHandler.java:150)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.InvokeHandler.process(

    [/COLOR][/SIZE]

    InvokeHandler.java:110)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.HTTPDispatch.handleRequest(

    [/COLOR][/SIZE]

    HTTPDispatch.java:190)[SIZE=2][COLOR=#ff0000]

    at com.wm.app.b2b.server.Dispatch.run(

    [/COLOR][/SIZE]

    Dispatch.java:350)[SIZE=2][COLOR=#ff0000]

    at com.wm.util.pool.PooledThread.run(

    [/COLOR][/SIZE]

    PooledThread.java:131)[SIZE=2][COLOR=#ff0000]

    at java.lang.Thread.run(

    [/COLOR][/SIZE]

    Thread.java:619)[SIZE=2][COLOR=#ff0000]

    [/color][/size][U][SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]com.wm.app.b2b.client.ServiceException

    [/color][/size][/COLOR][/SIZE][/u]

    : [SIZE=2][COLOR=#ff0000]

    Could not invoke the file
    at com.dish.cache.Cache.main(

    [/COLOR][/SIZE]

    Cache.java:138)[SIZE=2][COLOR=#ff0000]

    Exception in thread “main”

    [/COLOR][/SIZE]

    java.lang.NullPointerException[SIZE=2][COLOR=#000080]

    [/color][/size][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]at com.dish.cache.Cache.main(

    [/color][/size][/COLOR][/SIZE]

    Cache.java:189)

    I cannot ask any of my team mates because they are very busy, I did asked one guy and he is so busy that I cannot even talk to him. I am sorry about that, and sorry about these problems.

    Please help me on this.

    Thanks,
    Venkat.
    [/SIZE]


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


  • 15.  RE: How to unhide the built-in java services.

    Posted Wed March 30, 2011 11:45 PM

    The following code should help you figure out how to successfully call the service.
    [highlight=java]
    IData input = IDataFactory.create();
    IDataCursor inputCursor = input.getCursor();
    IDataUtil.put(inputCursor, “filename”, yourFilenameVar);
    IDataUtil.put(inputCursor, “loadAs”, “string” );
    inputCursor.destroy();

    IData output = null;

    try{
    output = context.doInvoke( “pub.file”, “getFile”, input );
    } catch( Exception e){
    throw new ServiceException(“\n”+“Error calling getFile”);
    }

    IDataCursor outputCursor = output.getCursor();

    IData body = IDataUtil.getIData( outputCursor, “body” );
    if (body != null)
    {
    IDataCursor bodyCursor = body.getCursor();
    String string = IDataUtil.getString( bodyCursor, “string” );
    bodyCursor.destroy();
    }
    outputCursor.destroy();[/highlight]


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


  • 16.  RE: How to unhide the built-in java services.

    Posted Thu March 31, 2011 12:58 AM

    Hi Reamon, this time it is giving me the “FileNotFoundException”, can you check by giving some file that you have in this code.

    Most amazing thing is that if I run the “getFile” java service with the file name that I am giving, it is giving me the file data, but if I invoke the same java service it is giving me the exception.

    I know this will be annoying.

    Also I have asked my team mate about it but he couldn’t find it too.

    Please check the code attached.

    Thanks,
    Venkat.
    Cache Code.txt (4.15 KB)


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


  • 17.  RE: How to unhide the built-in java services.

    Posted Thu March 31, 2011 04:34 PM

    Can you provide the exact filename used when using getFile and when using your Java service?


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


  • 18.  RE: How to unhide the built-in java services.

    Posted Thu March 31, 2011 04:49 PM

    Hi Reamon, this is the file name path

    [SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]/apps/wm/ENT_IS2/webMethods80/IntegrationServer/packages/DeveloperPOC/config/ehcache.xml

    Thanks,
    Venkat.
    [/COLOR][/size][/COLOR][/SIZE]


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