Last night, I attempted to upload my ZK app at GoDaddys's shared hosting servers. I've planned to do this for a long time already but I just kept on postponing a possibly dreadful experience. I don't like the idea of waiting 24 hours between restarts of its Tomcat service.
So, how long is 24 hours? It's long enough to compel me to look for another webhosting service. In an hour or so, I was already up and running at EATJ web hosting solutions.
EATJ offers a free account for first-time users. For free accounts, the Tomcat JVM is shut down 4 times daily in order to save on server resources. Your Tomcat server, however, can be restarted easily within 30 secs via your control panel. The paid plans enjoy 24x7 monitoring for continuous server uptime.
I registered for a free account and got my control panel in just a couple of minutes. This guide will help you get started and ready to deploy your own app. I created my own zk307.war file containing the ZK 3.0.7 jars as well as my ZK app and dependencies by executing the command jar cvf ..\zk307.war * in the zk307 directory.
The war file is rather chunky at 21mb (the free account allows for 50mb) and uploading it seemed to be the most challenging chore of all. I had to retry once for the two uploads I did. Here's the listing of the webapps directory contents in the remote server.
Restart the Tomcat server and taadaaaa... my ZK app remotely-hosted at http://rexjun.s43.eatj.com/zk307/k3soap.zul!
If you happen to catch my Tomcat service down, don't wait for me to restart it.. instead, create your own in under an hour!
Tuesday, August 5, 2008
ZK / Tomcat Hosting at EATJ
Posted by
pipoltek
at
7:30 PM
2
comments
Sunday, August 3, 2008
ZK Version 3.0.7 released
The ZK front-end app to KnowledgeTree was developed using version 3.0.6. The newer version 3.0.7 was released on August 1 and I had the chance to install ZK from scratch and run the ZK front-end app successfully.
Here are the steps:
- download zk-bin-3.0.7.zip from sourceforge.net
- copy the MyApp directory (from the demo package) under the webapps directory of Apache Tomcat. Rename it to accordingly (I used zk307 in this example).
- Create the WEB-INF/lib sub-directory. Place here all the jars found under the dist/lib directory of the zk-bin-3.0.7 package. Copy the jars under the ext and zkforge directories also but omit the directories - place all jars under WEB-INF/lib
- Add the ktws.jar and the jars required by Apache Axis (see previous blog entry)
Fire up Tomcat and point your browser to http://localhost:8080/zk307/ktlogin.zul
There are over 9 new features and 22 bug fixes under this new release. Read more about the new ZK release here.
Posted by
pipoltek
at
4:44 PM
1 comments
Labels: Ajax, KnowledgeTree, RIA, SOAP, ZK
Saturday, August 2, 2008
ZK + SOAP + KnowledgeTree
Here's a working ZK app that performs a SOAP login to KnowledgeTree's web services.
I've uploaded the source code to a KnowledgeTree repository and can be downloaded using the KT-Gadget.
- ZK front-end app (ktlogin.zul)
- ZK include script (ktlogin.zk)
My testbed:
- Apache Tomcat Version 5.5.26
- ZK 3.0.6
- Windows XP Prof Service Pack 2
- Mozilla Firefox 3.0
Posted by
pipoltek
at
9:52 AM
0
comments
Labels: Ajax, KnowledgeTree, SOAP, ZK
Sunday, July 20, 2008
Using KnowledgeTree SOAP Services from Java apps
I'm making a front-end to KnowledgeTree using the ZK Ajax framework so I eventually dipped my fingers into KT's web service integration from a Java app. My previous SOAP projects involved a Tcl client and a Google gadget using the javascript/php combo.
KnowledgeTree's wiki article on Web Service integration using Java has been most helpful. Since I'm doing my development work on Windows, I've adapted the procedures slightly. And since ZK uses the Beanshell interpreter to execute the Java code, I also modified the tester client application accordingly.
What's needed:
- Apache Axis 1.4
- Beanshell interpreter
- Java SE Runtime Environment (JRE)
- proxy classes in a jar file (ktws.jar)
set CP=axis-1_4/lib/axis.jar;axis-1_4/lib/commons-discovery-0.2.jar
set CP=%CP%;axis-1_4/lib/commons-logging-1.0.4.jar;axis-1_4/lib/jaxrpc.jar
set CP=%CP%;axis-1_4/lib/log4j-1.2.8.jar;axis-1_4/lib/saaj.jar
set CP=%CP%;axis-1_4/lib/wsdl4j-1.5.1.jar
java -cp %CP% org.apache.axis.wsdl.WSDL2Java -c T1 -p com.pipoltek.ktws http://docs.pipoltek.com/ktwebservice/webservice.php?wsdl
"%JAVA_HOME%\bin\javac" -d . -classpath %CP% com/pipoltek/ktws/*.java
"%JAVA_HOME%\bin\jar" cvf ktws.jar .\com\pipoltek\ktws\*.class
Here's the Beanshell script to execute a login via SOAP.
/*
filename: ktsoaptest.bsh
to run, type from the command-line:
java -cp bsh-2.0b4.jar bsh.Interpreter ktsoaptest.bsh
*/
// add axis classes
addClassPath ("./axis-1_4/lib/axis.jar");
addClassPath ("./axis-1_4/lib/axis-ant.jar");
addClassPath ("./axis-1_4/lib/jaxrpc.jar");
addClassPath ("./axis-1_4/lib/commons-logging-1.0.4.jar");
addClassPath ("./axis-1_4/lib/commons-discovery-0.2.jar");
addClassPath ("./axis-1_4/lib/log4j-1.2.8.jar");
addClassPath ("./axis-1_4/lib/wsdl4j-1.5.1.jar");
addClassPath ("./axis-1_4/lib/saaj.jar");
// knowledgetree proxy classes
addClassPath ("./ktws.jar");
// others
addClassPath ("./lib/activation.jar");
addClassPath ("./lib/mail.jar");
import com.pipoltek.ktws.KnowledgeTreeBindingStub;
import com.pipoltek.ktws.Kt_response;
import com.pipoltek.ktws.Kt_folder_contents;
import com.pipoltek.ktws.Kt_workflow_transitions_response;
import org.apache.axis.client.Service;
import java.net.URL;
import com.pipoltek.ktws.Kt_folder_item;
URL url = new URL("http://kt352c.pipoltek.com/ktwebservice/webservice.php");
KnowledgeTreeBindingStub stub = new KnowledgeTreeBindingStub(url, new Service());
System.out.println("Logging into KnowledgeTree");
Kt_response response = stub.login("rexjun","cabanilla","127.0.0.1");
int status_code=response.getStatus_code();
String session;
if (status_code == 0) {
session = response.getMessage();
System.out.println("Session: " + session);
} else {
System.out.println("Status Code: " + status_code);
System.out.println("Session: " + response.getMessage());
return;
}
I'll be using this piece of code to invoke SOAP services from my ZK app. More on this later..
Posted by
pipoltek
at
3:13 AM
1 comments
Labels: Ajax, Beanshell, Java, KnowledgeTree, SOAP, Web Services, ZK
Friday, June 20, 2008
KnowledgeTree document download via Google Gadget
This is an installment feature for the KT-Gadget, a widget for KnowledgeTree, an open-source document management system.
As mentioned in the previous post, I employed an application proxy to act as a bridge between a Google Gadget and KnowledgeTree's SOAP services. Originally, the application proxy responses were formatted in XML. Moving forward, I decided to adopt the JSON format instead of XML owing to simpler methods in handling JSON feeds from both PHP and (of course) Javascript worlds.
The application proxy's SOAP client is based on PHP and converting an associative array of response items to JSON format is implemented simply by using PHP's json_encode function. At the gadget side, the requests for remote data are invoked using Google's _IG_FetchContent function. Using Javascript's eval() function, the returned JSON text response is converted to an object whose members can be easily accessed using dot or subscript operators.
Here are the details.. To download a document, KT-Gadget sends a request to the helper application by invoking the url:
http://kt-gadget.pipoltek.com/pipoltek.com/json/?oid=download_document&sid=rsop4e364ptf4slkp2a2vtvb96&did=4
The JSON response by the application proxy is of the form:
{"response":{"status_code":0,"message":"http:\/\/docs.pipoltek.com\/ktwebservice\/download.php?code=d2db2c0868ab0c9cd053fe2e43ab9926d1bcf94c&d=4&u=6a0j9qqpqc11de6nju6o0ej5o7"}}
The relevant block of KT-Gadget code is reproduced hereunder:
var url = "http://kt-gadget.pipoltek.com/pipoltek.com/json/?oid=get_folder_contents&sid=" + sessionID__MODULE_ID__ + "&fid=6";
_IG_FetchContent(url, function (jsonFeed) {
var jsonData = eval('(' + jsonFeed + ')');
if (jsonData.response.status_code != 0) {
alert ('Error in retrieving document!');
} else{
dd_link = jsonData.response.message;
_gel("ktg-lnk").innerHTML = '<a href="' + dd_link + '">@';
}
})
Once the application proxy has responded, the JSON text response (jsonFeed) is converted to an object (jsonData) using the eval() function. The response contains the download URL the value of which can be referenced as jsonData.response.message.
Where did the Session-ID (sid) and Document-ID (did) used as URL parameters come from? The Session-ID is assigned during login and the Document-ID, together with the rest of the document details, is returned by a call to get_folder_contents.
Here's the login invocation:
http://kt-gadget.pipoltek.com/pipoltek.com/json/?oid=login&uid=rexjun&pwd=cabanilla
The invocation to get_folder_contents:
http://kt-gadget.pipoltek.com/pipoltek.com/json/?oid=get_folder_contents&sid=0j8jkhjn55t7r3b0rshbcchpn1&fid=6
If you get a "Session is invalid" error, it's because the link is using an ID of an expired session. Change the URL parameter (sid) to a fresh Session-ID returned by the login call to get better results.
You may try out KT-Gadget by adding it to your iGoogle page or view the gadget source code here.
Posted by
pipoltek
at
9:15 AM
3
comments
Labels: Google Gadget, Javascript, JSON, KnowledgeTree, KT-Gadget, SOAP, XML