MyEclipse Logo

MyEclipse Web Service Client Tutorial


Table of Contents

  1. Introduction
  2. Suggested Audience
  3. System Requirements
  4. Web Service Client Generation
  5. Conclusion
  6. Feedback

1. Introduction

Welcome to the MyEclipse Terra Server web service client demonstration. This tutorial is going to show you how to use MyEclipse to generate a web service client that can be used to communicate with the Terra Server web service.

The project that was used for this demonstration is available from the Examples on Demand repository, accessible from the MyEclipse menu:


The project is also included with the tutorial here for your reference if you would like to download it. You can then import it into your workspace using File > Import... > General > Existing Projects into Workspace > Archive.

2. Suggested Audience

This tutorial is intended for developers who are somewhat familiar with either MyEclipse or Eclipse so you are expected to recognize navigation and understand some of the more common concepts like "Views" within the IDE.  The tutorial also assumes at least a basic understanding of web services.

3. System Requirements

This tutorial was created with MyEclipse 5.1 using this project. If you are using a another version of MyEclipse, most of these screens and instructions should still be very similar.

If you are using a newer version of MyEclipse and notice portions of this demonstration looking different than the screens you are seeing, please let us know and we will make sure to resolve any inconsistencies.

4. Web Service Client Generation

To get started generating a web service client, you first need a Java Project (or compatible projects, such as Web Project, Web Service Project, etc.) to generate the client into. Let's start by creating a new project:

Figure 1. Creating a new Java Project for our web service client

After our project has been created the next thing we need to do is let MyEclipse generate our web service client for us. In this step we are having MyEclipse connect to the web service, retrieve it's WSDL and then in our project, generate all the classes and stubs required to communicate with that web service. In this case the URL we are going to point MyEclipse at is http://terraserver.microsoft.com/TerraService2.asmx?WSDL

So let's do that now:

Figure 2. Have MyEclipse generate the web service client

After the web service client code has been generated, the last step for us to do is customize the code to do what we want. By default MyEclipse will generate all the code necessary to get access to the stub that is used to communicate with the service, but it is up to the implementor to write business logic to do something with that stub.

In this case, we are going to use the generated Place object to create a query about Dallas, TX and have the web service ask Terra Server to convert the location of Dallas, TX to it's longitude and latitude coordinates and return those to us. Let's have a look:

Figure 3. Use the web service client to ask Terra Server about Dallas, TX

You can see the only code we had to write after generating the client was:

// Setup query
Place place = new Place();
place.setCity("Dallas");
place.setState("Texas");
place.setCountry("United States");

// Process result
LonLatPt result = terraServiceSoap.convertPlaceToLonLatPt(place);
System.out.println("City: " + place.getCity() + ", " + place.getState() + ", " + place.getCountry());
System.out.println("Latitude = " + result.getLat() + "  Longitude: " + result.getLon());
Figure 4. Custom web service client code

Which is straight forward and easy to follow. As you may have noticed, after typing the terraServiceSoap object in and hitting auto-complete, there are other methods that the web service exposes that the generated client can perform. In this demonstration we simply covered the convertPlaceToLonLatPt only.

5. Conclusion

Getting started with web services in MyEclipse is quick and easy. Even if you haven't developed a web service before, you can see from the demonstration above that utilizing all the existing web services out there can be painless and quick. Don't forget if you want to play with the project we generated in the demonstration above, you can download that MyEclipse project here and import that into your existing workspace using File > Import... > General > Existing Projects into Workspace > Archive.

6. Feedback

We would like to hear from you! If you liked this demonstration, have some suggestions or even some corrections for us please let us know. We track all user feedback about our learning material in our Documentation Forum.  Please be sure to let us know which piece of MyEclipse material you are commenting on so we can quickly pinpoint any issues that arise.