Async Web Service Call - Oracle 10g JDeveloper - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Async Web Service Call - 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.

DatabaseServiceBkupAll.java

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/DatabaseServiceBkupAll-DatabaseServiceBkupAll-context-root/DatabaseServiceBkupAllSoapHttpPort?DatabaseServiceBkupAllSoapHttpPortstub.html, under the Method Summary, it has:

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.bkupAllDB()" to "myPort.bkupAllDBAsync(something)" 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.

Comments

  • dlc9sdlc9s Posts: 2Member
    : 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.
    :
    : DatabaseServiceBkupAll.java
    :
    : 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-Data
    : baseServiceBkupAll-context-
    : root/DatabaseServiceBkupAllSoapHttpPort");
    : exitVal = myPort.bkupAllDB();
    : } catch (Exception e) {
    : e.printStackTrace();
    : }
    :
    : When I go to
    : http://localhost:6688/DatabaseServiceBkupAll-DatabaseServiceBkupAll-c
    : ontext-root/DatabaseServiceBkupAllSoapHttpPort?DatabaseServiceBkupAll
    : SoapHttpPortstub.html, under the Method Summary, it has:
    :
    : 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.bkupAllDB()" to
    : "myPort.bkupAllDBAsync(something)" 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.

    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() {
    DatabaseServiceBkupSoapHttpPortClient myPort = null;
    try {
    myPort = new DatabaseServiceBkupSoapHttpPortClient();
    System.err.println("Calling " + myPort.getEndpoint());
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    try {
    myPort.setEndpoint("http://localhost:6688/DatabaseServiceBkup-
    DatabaseServiceBkup-context-root/DatabaseServiceBkupSoapHttpPort");
    int temp = myPort.bkupAllDB();
    setExitVal(temp);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    In working.jsp:


    <% if ( threadbean.getStillAlive() == 0 ) { %>

    Process is Complete.


    Press the button to continue.


    <% } else { %>

    Working...

    Do not interrupt the process.

    When the Continue button appears, the process is complete.

    <% } %>


Sign In or Register to comment.