You are here: Using SOAP > v2006.1 services > Tutorials and samples > Using Glue (Java) with ArcWeb Services v2006.1

T U T O R I A L

Using Glue (Java) with ArcWeb Services v2006.1

The purpose of this tutorial is to demonstrate how to access ArcWeb Services with webMethods Glue. Glue is a distributed computing platform for Java. 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 a validation token prior to accessing any 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.

NOTE: Separate WSDLs are available for Glue users. This is due to webMethods' diminished support for its Glue toolkit.

Requirements

This tutorial assumes you have the following:

Overview

Download the sample code.

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 Services user. Use this token to access Address Finder Web Service.

In the second request, you call Address Finder Web Service 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 correspond to the input argument.

NOTE TO UNIX USERS: You need to change the directory paths from "\" to  "/".  

How to use Glue (Java)

  1. Add the glue.jar file to your classpath so Java can find Glue:

<Glue Installation Directory>\lib\GLUE-all.jar

  1. Add a \bin directory to your classpath:

<Glue Installation Directory>\bin

  1. Create a directory named "awgluesamples".
  2. From within the awgluesamples directory you created in step 3, run the wsdl2java against the Authentication Web Service WSDL URL. The wsdl2java command line tool generates a Java interface, helper class, data structures, and a .map file from the WSDL. See the Glue User Guide for more information on Glue and the wsdl2java tool.

wsdl2java https://www.arcwebservices.com/services/v2006_1/glue_ssl/Authentication.wsdl -p esri.aws.v2006_1 -g

This creates the following files in the esri/aws/v2006_1 directory:

  1. From within the awgluesamples directory you created in step 3, run the wsdl2java against the Address Finder Web Service WSDL URL. This creates a stub from the AddressFinder.wsdl file.

wsdl2java http://www.arcwebservices.com/services/v2006_1/glue/AddressFinder.wsdl -p esri.aws.v2006_1 -g

This creates the following files:

  1. Create a new AddressFinderClient.java file by copying the following client code or downloading the AddressFinderClient.java file to the awgluesamples directory.
import esri.aws.v2006_1.* ;/**
 * 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 ESRI Global Account user name/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 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 include x,y coordinates 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());        }    } }
  1. Replace USERNAME and PASSWORD in the AddressFinderClient.java code with your ESRI Global Account user name and password.

    NOTE: Your account must be activated for ArcWeb Services.

  2. Compile all the .java files in the esri/aws/v2006_1 directory and the AddressFinderClient.java file in the awgluesamples directory.   

c:\awgluesamples>cd esri\aws\v2006_1
c:\awgluesamples\esri\aws\v2006_1>javac *.java
c:\awgluesamples\esri\aws\v2006_1>cd ..\..\..\
c:\awgluesamples>javac *.java -classpath %classpath%;.

  1. Run the client. For example:

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.

ArcWeb site | ArcWeb support | support.esri.com

Copyright © ESRI