Connecting Tech Pros Worldwide Forums | Help | Site Map

Async Web Service - Oracle 10g JDeveloper

Newbie
 
Join Date: Dec 2008
Posts: 3
#1: Dec 5 '08
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
Expand|Select|Wrap|Line Numbers
  1. public int bkupAllDB() { 
  2. int exitVal = -1;
  3. try {
  4. Runtime rt = Runtime.getRuntime();
  5. Process p = rt.exec("/auto/touchBash1.sh");
  6. p.waitFor();
  7. exitVal = p.exitValue(); 
  8. } catch (Exception e) {
  9. System.out.println(e);
  10. return exitVal;
  11. }
  12. 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. 
  13.  
  14. DatabasePortlet.java
  15. DatabaseServiceBkupAllSoapHttpPortClient myPort = null;
  16. try {
  17. myPort = new DatabaseServiceBkupAllSoapHttpPortClient();
  18. System.err.println("Calling " + myPort.getEndpoint());
  19. } catch (Exception ex) {
  20. ex.printStackTrace(); 
  21. }
  22.  
  23. try {
  24. myPort.setEndpoint("http://localhost:6688/DatabaseServiceBkupAll-DatabaseServiceBkupAll-context- 
  25. root/DatabaseServiceBkupAllSoapHttpPort");
  26. exitVal = myPort.bkupAllDB();
  27. } catch (Exception e) {
  28. e.printStackTrace();
  29. }
  30.  
When I go to http://localhost:6688/DatabaseServic...pPortstub.html, under the Method Summary, it has
Expand|Select|Wrap|Line Numbers
  1. DatabaseServiceBkupAllSoapHttpPort_bkupAllDB
  2. int DatabaseServiceBkupAllSoapHttpPort_bkupAllDB ();
  3. DatabaseServiceBkupAllSoapHttpPort_bkupAllDBAsync
  4. void DatabaseServiceBkupAllSoapHttpPort_bkupAllDBAsync (function callback(int));
  5.  
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.

Dököll's Avatar
Moderator
 
Join Date: Nov 2006
Location: Upstate NY - US
Posts: 2,268
#2: Dec 8 '08

re: Async Web Service - Oracle 10g JDeveloper


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:-)
Newbie
 
Join Date: Dec 2008
Posts: 3
#3: Dec 9 '08

re: Async Web Service - Oracle 10g JDeveloper


Thank you for the tutorial. I did read it, but it uses BPEL which I cannot use (project restraint).
Newbie
 
Join Date: Dec 2008
Posts: 3
#4: Dec 21 '08

re: Async Web Service - Oracle 10g JDeveloper


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:
<meta http-equiv="Refresh" content="3">
<!--Web Service is Done-->
<% if ( threadbean.getStillAlive() == 0 ) { %>
<p>Process is Complete.<br><br>
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>
<% } %>
Dököll's Avatar
Moderator
 
Join Date: Nov 2006
Location: Upstate NY - US
Posts: 2,268
#5: Dec 21 '08

re: Async Web Service - Oracle 10g JDeveloper


Dino-mite, dlc9s!

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

Happy coding:-)

Dököll
Reply