Send As SMS

Friday, August 11, 2006

Deploy Eclipse Web Service To Tomcat Axis

This tutorial is based upon how to deploy a developed web service in Eclipse to Apache Tomcat Server with Axis SOAP.

1) From Eclipse select the project that contains the Web Service and then highlight the source directory. Right click on the source directory and select Export->Java Jar file and then click Next.
2) The Web Service should be selected and verify that the "Export generate class files and resources" and "Export java source files and sources" check boxes are checked. Under options make sure the "Compress the contents of the jar file" and "Add directory entries" are checked". You can the select the directory and file name that you want this jar to placed. Click Finish button.
3) Copy the exported jar flie to the Axis lib directory within Apache Tomcat (ex: C:\Program Files\Apache Software Foundation\Tomcat 5.5.15\webapps\axis\WEB-INF\lib)

In addition to the web service jar file any other jars that the web service calls need to be copied into this directory.

4) Now we need to deploy the service. Start->Run->cmd

Navigate to the directory within the Web Service project where the deploy.wsdd (Web Service Deployment Descriptor) is located. (In a project like BASS there may be more than one wsdd file. Once per service.) The deploy.wsdd is created and exists within the web service project within Eclipse.

5) Startup Apache Tomcat server. (The server must be started for the Web Service to be deployed or else an error will occur.)

6) Type the following command: java org.apache.axis.client.AdminClient deploy.wsdd (deploy.wsdd would be the wsdd file name for the service that you want to deploy. In addition, if you are not in the folder where the wsdd is located you will need to add the path name as well.)

Startup the Tomcat Server. This is how Tomcat will pickup the changes that you made.)
->Manager->/axis->/view and the Web Services that you deployed should be present.

rmi tutorial and setup

In order to get a rmi server to run. In the following example three rmi sample files were created: ServerPublishInstanceData, PublishInstanceData, and ClientPublishInstanceData. In this exapmle they code was created using Eclipse but the deployment was done through the cmd prompt. The code was created under project rmiPublishInstanceData with the package name being org.rmi.publish.

The following tutorial may be used as a reference: http://java.sun.com/j2se/1.5.0/docs/guide/rmi/index.html

1. The rmiPublishInstanceData project folder was copied from the Eclipse work space and pased into a root directory folder called "RMI".
2. Eclipse has two options turned on. (1) It has the auto generate class option turned on so we do not have generate the classes for the java code. (2) My version of Eclipse has the rmi plugin and will auto generate the stub files. If you don't have the plugin you canuse the rmic command to generate the stub flies.
3. Start the rmiregistry this is performed by typing: start rmiregistry

When the rmi registry strat a different command window will open but no messages will be displayed if everything started correctly.

If the registry will not start make sure that the java directory is in the path and classpath environment variables.

4. Next you must start the rmiserver.

In my example I navigate to the c:\RMI\rmiPublishInstanceData\bin folder. Because I copied the entire project folder from Eclipse in the my RMI directory I will have a bin and a src folder. The src folder will contain the java code. The bin folder if the auto generate classes is turned on will contain the class files.

5. From the specified folder above I start the rmi server by typing the following: start java -classpath . org.rmi.publish.ServerPublishInstanceData

This should start a different window that has the server running in it. When ever the server writes anything to system out it will be written to this window.

At this point the rmi server is running.

6. If you have created a test client to run the server such as the ClientPublishInstanceData that I have created then you can follow the following steps to run the client. From the same folder as you started the server type the following: java -Djava.security.policy=c:\wideopen.policy ClientInstanceData serverNave stringValue

In this example the client took in two variables, the name of the server that it is running on and the a string value to write to a file. Also, to start the client you need to specify the policy file. In this example the policy file is located at the root of the C drive.

This example will read the string and in a loop write the string value with the count appended to it 10 times to the file. In addition, it will write the string to the output file.

The code for this example can be found on both babbage and hopper.

Thursday, August 10, 2006

Web Service Client

How to create a Web Service Client from the Web Service that was created.

1) Within the Web Service project got to WebContent->wsdl and you should see a new soap wsdl file generated from the wsdl file to create the web service.
2) Right click on the new wsdl file and select new->other->Web Services->Web Service Client (hit next)
3) On the Clicent slider select "Test Client" the top leve. In addition, select the "Monitor the Web service" check box. Click the next button.
4) Continue to click the next button until the until no longer available and then hit the Finish button.

Web Service

Setting up simple Web Service Project in Eclipse:
1) New->Other->Web->Dynamic Web Project
2) Project name and default should be valid (Finish)
3) Copy WSDL file into the WebContent folder
4) In Eclipse open project go to WebContent folder and right click on it and select new->other->Web Services->Web Service
5) Accept defaults, set Web Service slider to be "Start Service". Don't bother setting client service slider yet. Select "Publish the Web service" and "Monitor the Web Service" check boxes. Hit "Next".
6) Continue to hit "Next" button until you reach the "Web Service Publicagtion" screen and uncheck the two "Launch" buttons. Click "Finish"

Congratulations!!! You now have a Web Service

Resource Out of Synce with File System

When starting the Tomcat server from Eclipse and you receivce the message "Resources out of sync with file system" you should high light your projects and press f5 and your resources will be insync and ready to run.

Friday, August 04, 2006

Java FileWriter, XML and UTF-8

The java.io.FileWriter class doesn’t use UTF-8 by default. This causes a problem when using FileWriter to save XML, some XML parsers/editors are tolerant of the difference, some are not. Using OutputStreamWriter as follows fixes the problem:


OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(path),"UTF-8");

Credit goes to the blog on the website Angus Thinks… which provided this solution.

Thursday, April 13, 2006

Change Port # for Tomcat

This example shows how to change the port # from 8080 to 80 but can be used to change the port # to anything.

1. Open the folder tomcat\conf on your computer

2. Now with a text editor you have to open and modify server.xml. Here you have to identify the following line (line 184) and you modify it so that changes from:

port="8080"

to:

port="80"

3. Startup the web server and access it now using:

http://localhost/

Sunday, February 12, 2006

Java and MySQL

After you download and install MySQL you will need to copy the mysql-connector-java-3.1.8-bin.jar file from the C:\Program Files\MySQL\MySQL Java Connector\mysql-connector-java-3.1.8 directory and place it into the C:\Program Files\Java\jdk1.5.0_06\jre\lib\ext directory. Without doing this you will not be able to run Java applications without an error.

Saturday, February 11, 2006

Install Eclipse 3.1.1 with WTP 1.0 Release

Eclipse 3.1.1 and WTP 1.0 are major releases and solve many of the Web Tools Project problems.

1) Download and extract the wtp-all-in-one-sdk-1.0-win32.zip file from the Eclipse website: http://www.eclipse.org/webtools/ This is an all inclusive install. It contains both the Eclipse 3.1.1 IDE as well as the WTP 1.0 plugins. This is the cleanest and easiest way to do this.

2) Download and extract into your new Eclipse project plugins the VE-runtime-1.1.0.1.zip plugins. This file can be downloaded from the Eclipse Visual Editor website: http://download.eclipse.org/tools/ve/downloads/drops/R-1.1.0.1-200509071822/index.html

3) Download and extract into your new Eclipse project plugins the com.myspotter.wsdl2java.zip plugin. It contains the jar files needed to build a Eclipse Java standalone client from a WSDL file. The file can be downloaded from the https://sourceforge.net/projects/wsdl2javawizard

4) Download and extract into your new Eclipse project plugins the net.sourceforge.sqlexplorer_2.2.4.zip plugin. This plugin is needed for query/schema viewer and can be downloaded from http://sourceforge.net/projects/eclipsesql

This is all the plugins that need to be downloaded an installed to setup Eclipse 3.1.1 with WTP 1.0

Once Eclipse is setup you can open it and set the Preferences by going to Windows->Preferences. If you already have an existing version of Eclipse you may just want to open both versions of Eclipse and just copy visually your settings from the older version to the newer version. If you don't have an older version or you are not comfortable copying your old version these are the changes that I applied to my perferences:
1) General->Web Browser (I check Default system Web Browser)
2) General->Workspace->Build Order (Setup the project build order)
3) Ant->Runtime: Add the following Global properties name:
(Name)catalina.home (Value)${Tomcat Home}
(Name)manager.password (Value) Apache Tomcat Password
(Name)manager.url (Value)http://localhost:8080/manager
(Name)manager.username (Value) Apache Tomcat Username
4) Java->Build Path->Classpath Variables: Add the following Classpath Variables:
ECLIPSE_HOME - Value: c:/Eclipse/Eclilpse 3.1.1 WTP 1.0/eclipse (directory where you installed Eclipse)
JUNIT_HOME - c:/Eclipse/Eclilpse 3.1.1 WTP 1.0/eclipse/plugins/org.junit_3.8.1
ORG_APACHE_AXIS - C:/Program Files/Apache Software Foundation/axis-1_2_1
TOMCAT_HOME - C:/Program Files/Apache Software Foundation/Tomcat 5.5.15
5) Java->Compiler (Compiler compliance level: 5.0) We are assuming JDK 1.5
6) Java->Installed JRE's (You can search your system by we are assuming jdk1.5.0_06)
7) Java->Run/Debug->TCP/IP Monitor (Add the ones you want to use for monitoring)
8) Server->Installed Runtimes (Search but assume Tomcat 5.5.15) Select and edit it, should have JRE jdk1.5.0_06 (assuming JDK 1.5)
9) Web Services->Server and Runtime (Server Tomcat v5.5 Server) Assuming Tomcat 5.5 upgrade. Web service runtime: Apache Axis
TOMCAT_HOME

Thursday, February 09, 2006

Using the TCP/IP Monitor to test Web services

When generating the top-down web service from a WSDL file, the option to monitor is no longer valid for Tomcat 5.0 or newer: http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jst.ws.axis.ui.doc.user/tasks/ttomcatserv.html (Section: Creating a Web Service and Java bean skeleton from WSDL)

Send the Web service traffic through the TCP/IP Monitor, which allows you to watch the SOAP traffic generated by the Web service and to test this traffic for WS-I compliance. Note that this is only supported for Tomcat v4.0 and v4.1. If you are using Tomcat v5.0 and want to monitor the Web service traffic, you need to manually set up a TCP/IP monitor as described in Using the TCP/IP Monitor to test Web services