The series so far has been as follows:
- Using Java web services to connect J2ME app to the internet: Part 1
- J2ME and Web Services:Part 2 – Configuring Apache Tomcat
- Creating a simple J2ME app: Part 3 of Java web services
- Creating the Login: Java web services part 4
In this tutorial we are going to do a simple thing; generate the web service and make sure it is working fine. We therefore don’t need to install anything as we have all we need.
1. Navigate to your project folder in Eclipse and right click on the java file you created that has the login code. For my case the file is Login.java.
2. Select the “Web Services” tab and click on “Create Web Service”. You should be presented with an interface similar to the screenshot below
3. All the configurations should be set correctly before you can proceed to the next step i.e. Server: Tomcat <your version>, Web service runtime: Apache Axis, Service project: <your project name>.
4. Check on “Publish the Web Service” and “Monitor the web Service” checkboxes and then click on “Finish”.
5. If all goes well you will be presented with a screen similar to the one shown in the screenshot below. It shows the operations your web service is exposing and how they are accessed.
6. To test the web service we are going to see the WSDL file which was generated by the web service. Right click on the project folder and select “Run As” and then click on “Run On Server”. You will be presented with a screen similar to the screenshot below;
7. Click on the “wsdl/” link and you will be presented with the available WSDL files, for my case I have Login.wsdl. On clicking it you should be presented with the wsdl file which is similar to the screenshot below;
8. As you can see it is basically an XML document specifying the services our web services is exposing.
That will be all for today, in the next tutorial we are going to consume the web services we have just created. Till then cheers!!