|
|
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.
|
|
|
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.
|
|
This tutorial was created with MyEclipse using this project.
If you 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.
|
|
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:
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:
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:
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.
|
|
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.
|
|
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.
|