The Eclipse development environment is very powerful, so I figured I would create a simple SOAP client in it from a given WSDL file. As it turns out, it's a little painful, so I wanted to write up the steps I had to go through.
I used
Eclipse 3.3.2 (Europa) JEE: Eclipse 3.3.2 (Europa) JEE on Windows XP in a VM
I started with an empty Java project named "FirstJava".
First import your WSDL file into your project.
- Select the "src" folder of your proejct, right-click and select "Import"
- Choose General/File System
- Select the folder containing your file and click OK
- now place a check mark next to your WSDL file and click OK
Now download Tomcat. There is a built-in "J2EE Preview" that works for
some things, but not for this.
Now create a new Target Runtime and server associated with Tomcat.
- Select the project and select Project->Properties, then select "Targeted Runtimes" on the left of the dialog.
- Click the "New" button
- Select Apache->Tomcat 5.5 AND ALSO CHECK "Also create new local server"
- Input the appropriate values as needed.
- Select the newly-create runtime
- Click OK to save the properties.
Create a new Web Services Client
- Right-click your WSDL file name and select New->Other..., then in the dialog displayed, select Web Services->Web Service Client).
- Your WSDL file name should be filled in at the top of the dialog
- In this dialog, use the slider underneath "Client Type" to specify "Test client" (move it all the way to the top).
- Click Finish.
- This will create a bunch of new code in your current project, plus it will create a new project (named "FirstJavaSample" in my case) with the JSPs you'll be able to (hopefully) run to test your client.
- This will give you an error about the JSP not supporting org.apache.axis.message.MessageElement[]. Just click OK several times until the error box goes away. We'll fix that later.
If all went well, you should see something like the following:
Now we have to fix the errors.
Create a JAR file named FirstJava.jar containing the contents of the bin directory of your FirstJava project.
Copy that file to the Tomcat "Common/lib" folder (C:/Apache/Tomcat5.5/Common/lib on my system).
You will additionally need to find these files under the eclipse/plugins directory and copy them to the Tomcat Common/Lib folder:
axis.jar
saaj.jar
jaxrpc.jar
javax.wsdl15_1.5.1.v200705290614.jar
wsdl4j-1.5.1.jar
(If you can't find them on your system, use Google to find and download them. One of them - I don't recall which - was tricky to find for me because it was actually in another JAR file.)
Now stop the Tomcat server by selecting it in the "Servers" view and clicking the stop (red square) button.
Now re-run your application by opening the FirstJavaSample project and finding the file named "TestClient.jsp". Right-click that file and select Run As->Run On Server, select your Tomcat server and click Finish.
You should now see that things are working correctly.
You may need to edit the generated JSP files to add input fields and such, but that's specific to your particular file.
Good luck, and happy coding.