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
- 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();
- }
Expand|Select|Wrap|Line Numbers
- DatabaseServiceBkupAllSoapHttpPort_bkupAllDB
- int DatabaseServiceBkupAllSoapHttpPort_bkupAllDB ();
- DatabaseServiceBkupAllSoapHttpPort_bkupAllDBAsync
- void DatabaseServiceBkupAllSoapHttpPort_bkupAllDBAsync (function callback(int));
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.