Async Web Service - Oracle 10g JDeveloper

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dlc9s
    New Member
    • Dec 2008
    • 3

    #1

    Async Web Service - Oracle 10g JDeveloper

    Hi All,

    I have a JSR 168 portlet that I need to call a J2EE 1.4 JAX-RPC Web Service. I'm using Oracle 10g JDeveloper. (I don't have a choice about this). It works when I call the sync method, but it won't recognizine the async method.

    I'm thinking I have to use the async method of the WS because the WS takes a while to do it's thing and return. If it doesn't take a while, everything works fine. If it does take a while, my portlet becomes unavailable.

    To create my WS, I wrote a java class, and used JDeveloper's "Create J2EE Web Service" wizard to create a J2EE 1.4 JAX-RPC WS. All my WS does is use a system call to execute a bash script. If the bash script just touches a file and returns, everything works great. If the bash script touches a file and then sleeps for a while, my portlet becomes unavailable.

    DatabaseService BkupAll.java
    Code:
    public int bkupAllDB() { 
    int exitVal = -1;
    try {
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("/auto/touchBash1.sh");
    p.waitFor();
    exitVal = p.exitValue(); 
    } catch (Exception e) {
    System.out.println(e);
    } 
    return exitVal;
    }
    Currently, my call to the WS is the following and it works just fine. I used the JDeveloper Web Service Proxy wizard to do it. 
    
    DatabasePortlet.java
    DatabaseServiceBkupAllSoapHttpPortClient myPort = null;
    try {
    myPort = new DatabaseServiceBkupAllSoapHttpPortClient();
    System.err.println("Calling " + myPort.getEndpoint());
    } catch (Exception ex) {
    ex.printStackTrace(); 
    }
    
    try {
    myPort.setEndpoint("http://localhost:6688/DatabaseServiceBkupAll-DatabaseServiceBkupAll-context- 
    root/DatabaseServiceBkupAllSoapHttpPort");
    exitVal = myPort.bkupAllDB();
    } catch (Exception e) {
    e.printStackTrace();
    }
    When I go to http://localhost:6688/DatabaseServic...pPortstub.html, under the Method Summary, it has
    Code:
    DatabaseServiceBkupAllSoapHttpPort_bkupAllDB
    int DatabaseServiceBkupAllSoapHttpPort_bkupAllDB ();
    DatabaseServiceBkupAllSoapHttpPort_bkupAllDBAsync
    void DatabaseServiceBkupAllSoapHttpPort_bkupAllDBAsync (function callback(int));
    To me that means the async version is out there and that I should be able to change "exitVal = myPort.bkupAllD B()" to "myPort.bkupAll DBAsync(somethi ng)" and everything should work. That's not the case. It doesn't recognize bkupAllDBAsync. Even if my "something" parameter isn't correct, I would at least think it would give me a different error.

    Also, my other thought is maybe I needed to create the WS differently. For 11g JDeveloper, when you use the "Create J2EE Web Service" wizard, there's a step that asks you if you want to create it asynchronously, but that's not the case for 10g.

    Maybe there's another solution, besides calling the WS asychronously, to make my portlet still be available while it waits for the WS to return. I was thinking threads, but if it's a timeout problem, I don't think threads would help, would it?

    Any guidance would be greatly appreciated. This is my first project involving portlets and web service.
    Last edited by Nepomuk; Dec 5 '08, 11:38 PM. Reason: Please use [CODE] tags
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there partner!

    Sorry I could not help you too much with this one... But I did find you a link to an Oracle Tutorial, give it a look:

    Calling an Asynchronous Web Service

    Not too much info in my results, perhaps someone passing thorugh has an idea...

    Sorry for your troubles:-)

    Comment

    • dlc9s
      New Member
      • Dec 2008
      • 3

      #3
      Thank you for the tutorial. I did read it, but it uses BPEL which I cannot use (project restraint).

      Comment

      • dlc9s
        New Member
        • Dec 2008
        • 3

        #4
        I got it to work using a thread. I'm not sure why my thread doesn't die, but it doesn't.

        In DatabasePortlet .java:
        private ThreadBean myThreadBean;
        myThreadBean = new ThreadBean();
        new Thread( myThreadBean ).start();

        In ThreadBean.java :
        public void run() {
        try {
        setStillAlive(1 );
        setExitVal(1);
        runScript();
        setStillAlive(0 );
        } finally {
        }
        }

        private void runScript() {
        DatabaseService BkupSoapHttpPor tClient myPort = null;
        try {
        myPort = new DatabaseService BkupSoapHttpPor tClient();
        System.err.prin tln("Calling " + myPort.getEndpo int());
        } catch (Exception ex) {
        ex.printStackTr ace();
        }
        try {
        myPort.setEndpo int("http://localhost:6688/DatabaseService Bkup-
        DatabaseService Bkup-context-root/DatabaseService BkupSoapHttpPor t");
        int temp = myPort.bkupAllD B();
        setExitVal(temp );
        } catch (Exception e) {
        e.printStackTra ce();
        }
        }

        In working.jsp:
        <meta http-equiv="Refresh" content="3">
        <!--Web Service is Done-->
        <% if ( threadbean.getS tillAlive() == 0 ) { %>
        <p>Process is Complete.<br><b r>
        Press the button to continue.</p>
        <!--Web Service is Busy-->
        <% } else { %>
        <p>Working... </p>
        <p><font color="#ff0000" >Do not interrupt the process.</font></p>
        <p>When the Continue button appears, the process is complete.</p>
        <% } %>

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Dino-mite, dlc9s!

          Good job getting it to work, and posting your finding...

          Happy coding:-)

          Dököll

          Comment

          Working...