The purpose of this tutorial is to demonstrate how to access ArcWeb Services with webMethods Glue. Glue is a distributed computing platform for Java. This tutorial assumes you have one of the editions of webMethods Glue version 5.0.2 toolkit running on your machine and an activated ArcWeb account. It also assumes you have a program to unzip the sample code.
You can obtain an evaluation version of Glue by contacting webMethods.
The sample uses Authentication Web Service and Address Finder Web Service as examples of how to use Glue to call ArcWeb services. ArcWeb Authentication Web Service requires that you send it a request for an validation token prior to accessing an ArcWeb service. You then use this returned token to send your geocoding request to Address Finder Web Service. In this sample, a user enters a series of addresses to be geocoded until the authentication token expires, at which point, the client requests a new token from the Authentication Web Service.
|
|
The following steps guide you through sending two requests to ArcWeb Services.
In the first request, you call Authentication Web Service with the following method:
getCustomExpirationToken(username:string, password:string, expiration:integer):string
Included in your request is your user name (username), password (password) and the minutes until the token should expire (expiration). Authentication Web Service returns a token (string) that validates you as an authorized ArcWeb user. Use this token to access Address Finder Web Service.
In the second request, you call Address Web Finder with the following method:
findLocationByAddress(address:Address, addressFinderOptions:AddressFinderOptions, token:string):GeocodeInfo
Included in your request are two objects (Address and AddressFinderOptions) and the token from the Authentication Web Service. Address Finder Web Service returns a list of geocoded matches for the address that match the input argument.
Note to UNIX users: You need to change the directory paths from "\" to "/".
<Glue Installation Directory>/lib/glue.jar
<Glue Installation Directory>/bin
wsdl2java https://www.arcwebservices.com/services/v2006/Authentication.wsdl -p esri.aws.v2006 -g
This creates the following files in the esri/aws/v2006
directory:
IAuthentication.java and AuthenticationHelper.java
wsdl2java http://www.arcwebservices.com/services/v2006/AddressFinder.WSDL -p esri.aws.v2006 -g
This creates the following files.
In the awgluesamples directory:
AddressFinder.map
In the esri/aws/2006 directory:
IAddressFinder.java, AddressFinderHelper.java, GeocodeInfo.java, ResultSetRange.java,
KeyValue.java, Point.java, Address.java, GeocodeCandidate.java, AddressFinderOptions.java,
AddressFinderInfo.java, CoordSys.java, and Envelope.java
import esri.aws.v2006.* ;/** * This is an ESRI ArcWeb Services sample. * This class gives the address location information for the given valid token and address. */
class AddressFinderClient {
/** * returns address location for the specified address. */public static void main(String args[]) { try { //Replace the [USERNAME] and [PASSWORD] with a valid username/password.String username = "[USERNAME]" ; String password = "[PASSWORD]" ; int expiration = 60; // in seconds
String housenumber = "380"; String street = "New York st" ; String city = "Redlands" ; String state = "CA" ; String postalCode = "92373" ; String country_code= "US" ;
String dataSource = "ArcWeb:TA.Streets.US" ;
//To log GLUE uncomment the following OR use glue-config.xml // read more http://www1.webmethods.com/docs/glue/guide/config/configfile.html //electric.util.log.Log.startLogging("RESOURCES"); //electric.util.log.Log.startLogging("MAPPING"); //electric.util.log.Log.startLogging("HTTP");
// read the mapping files from WEB-INF/maps, required for mapping Java to/from XML
//electric.xml.io.Mappings.readMappings("f:\\awgluesample\\AddressFinder.map");
// --------------Bind to Authentication Web services ----------- IAuthentication authentication = AuthenticationHelper.bind();
// --------------Call to Authentication Web Services and get the token--------- String token = authentication.getCustomExpirationToken(username,password,expiration);
// --------------bind to AddressFinder Web services ----------- IAddressFinder addressFinder = AddressFinderHelper.bind();
// Populate the address object with user input. Address address = new Address(); address.setHouseNumber(housenumber) ; address.setStreet(street) ; address.setCity(city) ; address.setStateProvince(state) ; address.setPostalCode(postalCode) ; address.setCountry(country_code) ;
// set AddressFinderOptions AddressFinderOptions addressFinderOptions = new AddressFinderOptions(); addressFinderOptions.setDataSource(dataSource) ;
//--------------Call to AddressFinder Web Service ----------- GeocodeInfo geocodeInfo = addressFinder.findLocationByAddress(address,addressFinderOptions,token);
//-------------Display Results---------------- //Get the candidates GeocodeCandidate[] candidates = geocodeInfo.getCandidates();
//candidates includes x,y coordiates and the complete address description // Print first candidate System.out.print(candidates[0].getDesc1()); System.out.print(" (" + candidates[0].getPoint().getX() + "," + candidates[0].getPoint().getY() + ")"); } catch (Exception e) { System.out.println("Error : " + e.getMessage()); } } }
c:\awgluesamples>cd esri\aws\v2006
c:\awgluesamples\esri\aws\v2006>javac *.java
c:\awgluesamples\esri\aws\v2006>cd ..\..\..\
c:\awgluesamples>javac *.java
c:\awgluesamples> java AddressFinderClient -cp %classpath%;.
[STARTUP] Glue Standard 5.0.2 build 77 (c)
2001-2004 webMethods, Inc.
380 New York St, Redlands, CA 92373 (-117.195533,34.057058)
TIP: If you receive the error “Could not find method for proxy invocation. Please check that you are reading in map files” the Glue client did not read the .map file. The .map file is required for mapping Java to and from XML. Add .map files to your classpath or add the following line of code in the AddressFinderClient.java file:
electric.xml.io.Mappings.readMappings("C:\\<locationofMapfile> ");
Visit the Feedback page to give comments or suggestions about the ArcWeb Developer's Guide.