NAVTEQ MapTP Web Services for JavaTM Client Applications
Download client stubs and wrapper classes: map24wsclientsaxis.zip (608 KB)
Follow the instructions below for an easy start with MapTP Web Services. One way to create Web service client applications is by using client stubs that are generated from WSDLs. This is not the only way but it is common and fairly straight forward. With this getting started guide we provide client stubs for the most recent MapTP Web Services WSDL version. The stubs have been generated with Apache Axis 1.4 using the Sun JDK 1.5. The zip file also contains wrapper classes that facilitate the creation of the most common Map24 Web Service requests. The zip file also contains demo clients for the MapTP Geocoder 5.1 Service, MapTP MapletRemoteControl Service, MapTP Routing Service, MapTP ReverseGeocoder Service, and MapTP MGI Service. Follow the steps in the Getting Started section below to run a demo client.
Getting Started
Prerequisites: Valid Map24 ID, Apache Axis 1.4 (or lower), Sun JDK 1.5 (or higher)
Follow the steps described here to create and run a small client application. The application sends a geocoding request to the MapTP Web Services and prints out the geocoded addresses to the console:
- Download the zip file with the client stubs and wrapper classes:
map24wsclientsaxis.zip
- Unzip the file. The following directory structure is created on your disk:
- Client stubs:
- src\main\java\com\mapsolute\map24webservices15\clients\axis\stubs
- Wrapper classes:
- src\main\java\com\mapsolute\map24webservices15\clients\axis\wrappers
- Demo client (FreeSearchDemo.java):
- src\main\java\com\mapsolute\map24webservices15\clients\customer\geocoder51demo
- Test file for running the demo client (AppTest.java):
- src\test\java\com\mapsolute\map24
- Edit the FreeSearchDemo.java:
- Open FreeSearchDemo.java in a text editor. The content of this file is shown in the listing below.
- Replace the MapTP server URL in the geocoder51ServicePort parameter (http://maptp12.map24.com) with the MapTP server URL that you received with your Map24 ID.
- Replace the dummy Map24 ID (***) with your Map24 ID.
- The address to geocode is hard coded in the address member. Especially if you are working with map data outside of Europe you have to change the address. Otherwise nothing will be found.
- Run the test:
- A Maven2 project file and a Ant build file is provided in the root directory map24wsclientsaxis. Choose whichever you prefer.
- Run the test either with the command mvn test or ant test.
- That's it. You see the result of the geocoding request printed to the console. The compiled classes are generated in target\classes and target\test-classes.
Ant user:
AXIS_HOME must be set. Either set that variable in your environment or open build.xml in a text editor and change the line
<property name="axis.home" value="$"/>
according to your environment. For example,
<property name="axis.home" value="c:\dev\axis-1_4"/>
Listing: FreeSearchDemo.java
package com.mapsolute.map24webservices15.clients.customer.geocoder51demo;
import com.mapsolute.map24webservices15.clients.axis.stubs.*; import com.mapsolute.map24webservices15.clients.axis.wrappers.*;
public class FreeSearchDemo { // Service URL. Note that the MapTP server address (here maptp12) might be different for you. public String geocoder51ServicePort = "http://maptp12.map24.com/map24/webservices1.5?soap=Map24Geocoder51"; // Map24ID for authentication public String map24ID= "***"; // Unique client ID public String clientID= "sid1234"; // Address to be geocoded public String address = "Pariser Platz Berlin"; /** * Starts the demo client. * * The args parameter is not interpreted. */ public static void main(String[] args) { new FreeSearchDemo().geocode(); }
public int geocode() { return geocode(address); }
public int geocode(String address) { int numResults = 0;
try { // Geocode the given address. Since the MapTP Geocoder can provide more than one result for a // given address, the MaxNoOfAlternatives parameter is used to define the maximum number of // returned results. MapSearchResponse response= Map24Geocoder51Wrapper.SearchFree(geocoder51ServicePort, map24ID,
clientID, address, /*MaxNoOfAlternatives*/ 3);
numResults = response.getAlternatives().length; System.out.println("SearchFree response length is: "+numResults);
// Print all found results to the console for (int j= 0; (j < numResults); j++) { System.out.println("Alternative["+j+"]:");
MapSearchAlternative alternative= response.getAlternatives()[j];
Property[] Properties = alternative.getPropertiesMajor();
for (int i= 0; (i < Properties.length); i++) { System.out.println("Property["+i+"]: "+Properties[i].getKey()+"
"+Properties[i].getValue()); }
System.out.println("Coordinate: ("+alternative.getCoordinate().getLongitude()+",
"+alternative.getCoordinate().getLatitude()+")"); System.out.println(); }
} catch (Exception ex) { ex.printStackTrace(); }
return numResults;
}// main }
Running Further Demo Clients
For running a different demo client, simply comment out the call of the geocoder demo in the test file (AppTest.java) and enable the desired demo client by removing the comment signs (//). Example for running the routing demo client:
// int numResults = new FreeSearchDemo().geocode(); //Disable geocoder demo // assertTrue( numResults == 3 ); new RoutingDemoClient().calculateRoute(); //Enable routing demo
Afterwards, perform steps 3 and 4 of the getting started guide above for the desired demo client.
Note that some demo clients allow to directly show the results of the request on the map. The downloaded zip file contains a Map24 Applet. Learn how to Control the Applet with MapletRemoteControl (MRC) Commands.
Generating Web Service Client Stubs
You can generate the client stubs yourself. This can be necessary if you want to use an older version of the MapTP Web Services WSDLs or if you want to use a different Web services toolkit than Axis 1.4. Not having JDK 1.5 installed can be another reason for generating the stubs yourself. However, the only reason why the provided stubs require JDK 1.5 is because some of them use auto (out-)boxing. You can easily spot these places in the source code and make the necessary changes so that the code compiles with JDK 1.4. Read more about generating stubs here.
|