S A M P L E S

 

Java code examples for Proxy Methods

This page contains Java code examples for ArcGIS Server SOAP proxy class methods and the value objects used for input and output types.  The samples apply to both desktop and Web applications.  By default, the name for the SOAP proxy class is the name of the service used to generate it plus the service type.
 For example, if a SOAP proxy class is generated dynamically using a map service named "NorthAmerica", the proxy class name will be "NorthAmerica_MapServer".   For the purposes of the example code, the proxy class names will be ServiceName_<service type>.  


Methods
 

Catalog
MapServer

GeocodeServer

GPServer

GeoDataServer

GeometryServer

ImageServer

NAServer

 

Catalog

   

GetFolders
 

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

String[] folders = catalogServer.GetFolders();

String foldername;

for (int index = 0; index < folders.Length; index++)

foldername = folders[index];

     

 

GetMessageFormats

 

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

System.out.println("Message Formats: " + catalogServer.getMessageFormats());

 

GetMessageVersion

 

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

System.out.println("Version: " + catalogServer.getMessageVersion());

 

GetServiceDescriptions

 

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

 

ServiceDescription[] sds = catalogServer.getServiceDescriptions();

for (int i = 0; i < sds.length; i++) {

ServiceDescription sd = sds[i];

System.out.println("Service Name: " + sd.getName());

System.out.println("Service Capabilities: " + sd.getCapabilities());

System.out.println("Service Type: " + sd.getType());

}

 

GetServiceDescriptionsEx
 

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

ServiceDescription[] servicedescriptions = catalogServer.GetServiceDescriptionsEx("SecureDirectory");

foreach (ServiceDescription servicedesc in servicedescriptions)

{

String name = servicedesc.getName();

String type = servicedesc.getType();

String parenttype = servicedesc.getParentType();

String capabilities = servicedesc.getCapabilities();

String url = servicedesc.getUrl();

}

   
GetTokenServiceURL

  

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

System.out.println ("TokenServiceURL: " + catalogServer.getTokenServiceURL());

 

RequiresTokens
 

String endpointURL = "http://MyAGSServer:8399/arcgis/services";

ServiceCatalogBindingStub catalogServer = new ServiceCatalogBindingStub(endpointURL);

System.out.println ("requiresTokens: " + catalogServer.requiresTokens());

 

MapServer

 

ComputeDistance

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

 

PointN pnt0 = new PointN();

pnt0.setX(-120.0);

pnt0.setY(30.0);

 

PointN pnt1 = new PointN();

pnt1.setX(-110.0);

pnt1.setY(35.0);

 

double distance = mapservice.computeDistance(mapname, pnt0, pnt1, EsriUnits.esriMiles);
 

ComputeScale

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);
 

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

double scale = mapservice.computeScale(mapdesc, imgdisp);
 

ExportMapImage

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);
 

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageType imgtype = new ImageType();

imgtype.setImageFormat(EsriImageFormat.esriImagePNG);

imgtype.setImageReturnType(EsriImageReturnType.esriImageReturnURL);

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

ImageDescription imgdesc = new ImageDescription();

imgdesc.setImageDisplay(imgdisp);

imgdesc.setImageType(imgtype);

 

MapImage mapimg = mapservice.exportMapImage(mapdesc, imgdesc);

 

ExportScaleBar

 

import org.apache.axis.types.UnsignedByte;

...

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

// Define scale bar properties

AlternatingScaleBar scalebar = new AlternatingScaleBar();

 

// Define Unit label

scalebar.setUnits(EsriUnits.esriMiles);        

TextSymbol unittextsymbol = new TextSymbol();            

unittextsymbol.setSize(20);

unittextsymbol.setFontName("Arial");

unittextsymbol.setText("Mile");

unittextsymbol.setMaskStyle(EsriMaskStyle.esriMSNone);

unittextsymbol.setTextDirection(EsriTextDirection.esriTDHorizontal);

unittextsymbol.setTextCase(EsriTextCase.esriTCNormal);

unittextsymbol.setTextPosition(EsriTextPosition.esriTPNormal);

unittextsymbol.setHorizontalAlignment(EsriTextHorizontalAlignment.esriTHACenter);

unittextsymbol.setVerticalAlignment(EsriTextVerticalAlignment.esriTVATop);

 

scalebar.setUnitLabelSymbol(unittextsymbol);

scalebar.setUnitLabelPosition(EsriScaleBarPos.esriScaleBarAfterBar);

scalebar.setUnitLabelGap(10.0);

 

// Define bar display

scalebar.setBarHeight(8.0);

scalebar.setDivision(4.0);

scalebar.setDivisionMarkHeight(18.0);

scalebar.setSubdivisions((short)10);

scalebar.setMarkPosition(EsriVertPosEnum.esriBottom);    

 

SimpleFillSymbol fillsymbol = new SimpleFillSymbol();

RgbColor fillcolor = new RgbColor();

fillcolor.setRed(new UnsignedByte(255));

fillcolor.setGreen(new UnsignedByte(0));

fillcolor.setBlue(new UnsignedByte(0));

 

fillsymbol.setColor(fillcolor);

fillsymbol.setStyle(EsriSimpleFillStyle.esriSFSSolid);

scalebar.setFillSymbol1(fillsymbol);

 

// Define division labels

TextSymbol textsymbol = new TextSymbol();

textsymbol.setSize(20.0);

textsymbol.setFontName("Arial");

textsymbol.setTextDirection(EsriTextDirection.esriTDAngle);

textsymbol.setAngle(45.0);

textsymbol.setText("|");

textsymbol.setMaskStyle(EsriMaskStyle.esriMSNone);

textsymbol.setTextCase(EsriTextCase.esriTCNormal);

textsymbol.setTextPosition(EsriTextPosition.esriTPNormal);

textsymbol.setHorizontalAlignment(EsriTextHorizontalAlignment.esriTHACenter);

textsymbol.setVerticalAlignment(EsriTextVerticalAlignment.esriTVATop);

 

scalebar.setLabelSymbol(textsymbol);

scalebar.setLabelPosition(EsriVertPosEnum.esriAbove);

scalebar.setLabelFrequency(EsriScaleBarFrequency.esriScaleBarDivisions);

 

// Define map properties (MapDescription and ImageDisplay)

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdispmap = new ImageDisplay();

imgdispmap.setImageWidth(500);

imgdispmap.setImageHeight(500);

imgdispmap.setImageDPI(96);

 

// Define scale bar image properties (ImageDescription)

ImageType imgtype = new ImageType();

imgtype.setImageFormat(EsriImageFormat.esriImagePNG);

imgtype.setImageReturnType(EsriImageReturnType.esriImageReturnURL);

 

ImageDisplay imgdispscalebar = new ImageDisplay();

imgdispscalebar.setImageHeight(75); //pixels

imgdispscalebar.setImageWidth(400); //pixels

 

ImageDescription imgdescscalebar = new ImageDescription();

imgdescscalebar.setImageDisplay(imgdispscalebar);

imgdescscalebar.setImageType(imgtype);

 

// Define background color

RgbColor backcolor = new RgbColor();

backcolor.setRed(new UnsignedByte(255));

backcolor.setGreen(new UnsignedByte(255));

backcolor.setBlue(new UnsignedByte(255));

 

// Create scale bar image

ImageResult imgresult = mapservice.exportScaleBar(scalebar, mapdesc, imgdispmap, backcolor, imgdescscalebar);
 

Find

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);
 

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

String searchstring = "Washington";

boolean contains_searchstring = true;

 

String fieldname = ""; // all fields

 

EsriFindOption findoption = EsriFindOption.esriFindAllLayers;

 

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();
int[] layerids = new int[layerdescriptions.length];

for (int i=0; i< layerdescriptions.length; i++){

  layerids[i] = layerdescriptions[i].getLayerID();

}

 

MapServerFindResult[] findresults = mapservice.find(mapdesc, imgdisp, searchstring, contains_searchstring, fieldname, findoption, layerids);
 

FromMapPoints

 

import com.esri.arcgisws.holders.ArrayOfIntHolder;

...
 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

MultipointN multipoint = new MultipointN();

 

PointN[] points = new PointN[1];

 

PointN pnt0 = new PointN();

pnt0.setX(-120.0);

pnt0.setY(35.0);

 

points[0] = pnt0;

 

multipoint.setPointArray(points);

 

ArrayOfIntHolder screenx = new ArrayOfIntHolder();

ArrayOfIntHolder screeny = new ArrayOfIntHolder();

 

mapservice.fromMapPoints(mapdesc, imgdisp, multipoint, screenx, screeny);
 

GetCacheName

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

  

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

  

for (LayerDescription layerdesc: layerdescriptions)

{

if (mapservice.hasLayerCache(mapname, layerdesc.getLayerID()))

{

String layercachename = mapservice.getCacheName(mapname, layerdesc.getLayerID());

}

}
 

GetDefaultMapName

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);
 

String mapname = mapservice.getDefaultMapName();
 

GetDocumentInfo

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

PropertySet documentproperties = mapservice.getDocumentInfo();

PropertySetProperty[] propertyarray = documentproperties.getPropertyArray();

 

for (PropertySetProperty documentprop : propertyarray)

{

String key = documentprop.getKey();

String value = documentprop.getValue().toString();

}
 

GetLayerTile

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

 

int layerdesc_maxindex = layerdescriptions.length - 1;

 

EnvelopeN mapextent = (EnvelopeN)mapdesc.getMapArea().getExtent();

 

// Use map scale resolution (map units per pixel) to determine tile level

double mapresolution = Math.abs(mapextent.getXMax() - mapextent.getXMin()) / width;

 

// Iterate through layers bottom up.  Polygons on bottom, then lines, then points.

for (int d = layerdesc_maxindex; d >= 0; d--)

{

LayerDescription layerdesc = layerdescriptions[d];

if (mapservice.hasLayerCache(mapname, layerdesc.getLayerID()))

{

TileCacheInfo tci = mapservice.getTileCacheInfo(mapname);

LODInfo[] tcis = tci.getLODInfos();

 

// Map units per pixel

double tileresolution = 0;

 

// Scale level

int tilelevel = 0;

for (LODInfo ldi : tcis)

{

double ldi_resolution = ldi.getResolution();

tileresolution = ldi_resolution;

tilelevel = ldi.getLevelID();

if (mapresolution >= ldi_resolution)

{

    break;

}

}

    
// Measured from the origin

double minx = mapextent.getXMin();

double miny = mapextent.getYMin();

double maxx = mapextent.getXMax();

double maxy = mapextent.getYMax();

 

// Origin of the cache (upper left corner)

double xorigin = ((PointN)tci.getTileOrigin()).getX();

double yorigin = ((PointN)tci.getTileOrigin()).getY();

 

// Get minimum tile column

double minxtile = (minx - xorigin) / (tci.getTileCols() * tileresolution);

 

// Get minimum tile row

// From the origin, maxy is minimum y

double minytile = (yorigin - maxy) / (tci.getTileRows() * tileresolution);

 

// Get maximum tile column

double maxxtile = (maxx - xorigin) / (tci.getTileCols() * tileresolution);

 

// Get maximum tile row

// From the origin, miny is maximum y

double maxytile = (yorigin - miny) / (tci.getTileRows() * tileresolution);

 

// Return integer value for min and max, row and column

int mintilecolumn = (int)Math.floor(minxtile);

int mintilerow = (int)Math.floor(minytile);

int maxtilecolumn = (int)Math.floor(maxxtile);

int maxtilerow = (int)Math.floor(maxytile);

TileImageInfo tii = mapservice.getTileImageInfo(mapname);

 

// for each row in the map extent

for (int row = mintilerow; row <= maxtilerow; row++)

    {

    // for each column in the row, in the map extent

    for (int col = mintilecolumn; col <= maxtilecolumn; col++)

    {

    // Return the byte array of the tile image

    byte[] tileByteArray = mapservice.getLayerTile(mapname, layerdesc.getLayerID(), tilelevel, row, col, tii.getCacheTileFormat());

    }

}

}

}

 

GetLegendInfo

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageType imgtype = new ImageType();

imgtype.setImageFormat(EsriImageFormat.esriImagePNG);

imgtype.setImageReturnType(EsriImageReturnType.esriImageReturnURL);

 

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

 

int[] layerids = new int[layerdescriptions.length];

int i = 0;

for(LayerDescription layerdesc:layerdescriptions)

{

layerids[i++]= layerdesc.getLayerID();

}

 

MapServerLegendPatch legendpatch = new MapServerLegendPatch();
legendpatch.setImageDPI(96);

legendpatch.setHeight(24);

legendpatch.setWidth(24);

 

MapServerLegendInfo[] legendinfo = mapservice.getLegendInfo(mapname, layerids, legendpatch, imgtype);
 

GetMapCount

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

int mapcount = mapservice.getMapCount();
 

GetMapName

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

int mapcount = mapservice.getMapCount();

for (int i = 0; i < mapcount; i++)

{

String mapname = mapservice.getMapName(i);

}
 

GetMapTile

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

EnvelopeN mapextent = (EnvelopeN)mapdesc.getMapArea().getExtent();

 

// Use map scale resolution (map units per pixel) to determine tile level

double mapresolution = Math.abs(mapextent.getXMax() - mapextent.getXMin()) / width;

if (mapservice.hasSingleFusedMapCache(mapname))

{

TileCacheInfo tci = mapservice.getTileCacheInfo(mapname);

LODInfo[] tcis = tci.getLODInfos();

// Map units per pixel

double tileresolution = 0;

// Scale level

int tilelevel = 0;

for (LODInfo ldi : tcis)

{

    double ldi_resolution = ldi.getResolution();

    tileresolution = ldi_resolution;

    tilelevel = ldi.getLevelID();

    if (mapresolution >= ldi_resolution)

    {

    break;

    }

}

 

// Measured from the origin

double minx = mapextent.getXMin();

double miny = mapextent.getYMin();

double maxx = mapextent.getXMax();

double maxy = mapextent.getYMax();

 

// Origin of the cache (upper left corner)

double xorigin = ((PointN)tci.getTileOrigin()).getX();

double yorigin = ((PointN)tci.getTileOrigin()).getY();

 

// Get minimum tile column

double minxtile = (minx - xorigin) / (tci.getTileCols() * tileresolution);

 

// Get minimum tile row

// From the origin, maxy is minimum y

double minytile = (yorigin - maxy) / (tci.getTileRows() * tileresolution);

 

// Get maximum tile column

double maxxtile = (maxx - xorigin) / (tci.getTileCols() * tileresolution);

 

// Get maximum tile row

// From the origin, miny is maximum y

double maxytile = (yorigin - miny) / (tci.getTileRows() * tileresolution);

 

// Return integer value for min and max, row and column

int mintilecolumn = (int)Math.floor(minxtile);

int mintilerow = (int)Math.floor(minytile);

int maxtilecolumn = (int)Math.floor(maxxtile);

int maxtilerow = (int)Math.floor(maxytile);

 

TileImageInfo tii = mapservice.getTileImageInfo(mapname);

 

// for each row in the map extent

for (int row = mintilerow; row <= maxtilerow; row++)

{

// for each column in the row, in the map extent

for (int col = mintilecolumn; col <= maxtilecolumn; col++)

{

// Return the byte array of the tile image

byte[] tileByteArray = mapservice.getMapTile(mapname, tilelevel, row, col, tii.getCacheTileFormat());

 

//  If Tile was found, add it to the consolidated image graphic

if (tileByteArray != null)

{

FileOutputStream newFile = new FileOutputStream("E:\\SOAP\\" + row + col + ".jpg");

System.out.println("E:\\SOAP\\" + row + col + ".jpg");

newFile.write(tileByteArray);

newFile.close();

}

}

}

}

 

GetServerInfo

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);
 

GetServiceConfigurationInfo
 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

PropertySet serviceproperties = mapservice.getServiceConfigurationInfo();

PropertySetProperty[] propertyarray = serviceproperties.getPropertyArray();

 

for (PropertySetProperty serviceprop : propertyarray)

{

String key = serviceprop.getKey();

String value = serviceprop.getValue().toString();

}

 

GetSQLSyntaxInfo

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

 

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

for(LayerDescription layerdesc:layerdescriptions)

{

SQLSyntaxInfo sqlsyntaxinfo = mapservice.getSQLSyntaxInfo(mapname, layerdesc.getLayerID());

}

 

GetSupportedImageReturnTypes

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

// Mime or Url

EsriImageReturnType imgreturntype = mapservice.getSupportedImageReturnTypes();
 

GetTileCacheInfo

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

if (mapservice.hasSingleFusedMapCache(mapname))

{

TileCacheInfo tilecacheinfo = mapservice.getTileCacheInfo(mapname);

}
 

GetTileImageInfo

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

if (mapservice.hasSingleFusedMapCache(mapname))

{

TileImageInfo tileimageinfo = mapservice.getTileImageInfo(mapname);

}
 

GetVirtualCacheDirectory

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

String mapname = mapservice.getDefaultMapName();

 

// Use -1 for fused caches                

String virtualcachedirectory = mapservice.getVirtualCacheDirectory(mapname, -1);

 

HasLayerCache

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

  

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

  

for (LayerDescription layerdesc: layerdescriptions)

{

if (mapservice.hasLayerCache(mapname, layerdesc.getLayerID()))

{

String layercachename = mapservice.getCacheName(mapname, layerdesc.getLayerID());

}

}

 

HasSingleFusedMapCache

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

if (mapservice.hasSingleFusedMapCache(mapname))

{

String fusedcachename = mapservice.getCacheName(mapname, -1);

}

 

Identify

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

PointN inputpoint = new PointN();

inputpoint.setX(-110.0);

inputpoint.setY(35.0);

 

int tolerance = 3;

 

EsriIdentifyOption identifyoption = EsriIdentifyOption.esriIdentifyAllLayers;

 

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

 

int[] layerids = new int[layerdescriptions.length];

int i = 0;

for(LayerDescription layerdesc:layerdescriptions)

{

layerids[i++]= layerdesc.getLayerID();

}

 

MapServerIdentifyResult[] identifyresults = mapservice.identify(mapdesc, imgdisp, inputpoint, tolerance, identifyoption, layerids);

 

IsFixedScaleMap

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

  

String mapname = mapservice.getDefaultMapName();

if (mapservice.isFixedScaleMap(mapname))

{

TileCacheInfo tilecacheinfo = mapservice.getTileCacheInfo(mapname);

}

 

QueryFeatureCount

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapLayerInfo[] maplayerinfos = mapinfo.getMapLayerInfos();

int layerid = 0;

String geometryfieldname = "";

 

for (MapLayerInfo layerinfo : maplayerinfos)

{

if (layerinfo.getName().equals("states"))

{

    layerid = layerinfo.getLayerID();

    Field[] fields = layerinfo.getFields().getFieldArray();

    for (Field field : fields)

    {

if (field.getType() == EsriFieldType.esriFieldTypeGeometry)

{

    geometryfieldname = field.getName();

    break;

}

    }

}

}

 

EnvelopeN envelope = new EnvelopeN();

envelope.setXMin(-180.0);

envelope.setYMin(0.0);

envelope.setXMax(180.0);

envelope.setYMax(90.0);

 

SpatialFilter spatialfilter = new SpatialFilter();

spatialfilter.setFilterGeometry(envelope);

spatialfilter.setGeometryFieldName(geometryfieldname);

spatialfilter.setSpatialRel(EsriSpatialRelEnum.esriSpatialRelIntersects);

spatialfilter.setSpatialRelDescription("T***F****");

spatialfilter.setWhereClause("POP1990 > 11881643");

spatialfilter.setSearchOrder(EsriSearchOrder.esriSearchOrderAttribute);

 

int featurecount = mapservice.queryFeatureCount(mapname, layerid, spatialfilter);

 

QueryFeatureCount2

 

QueryFeatureData

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

String mapname = mapservice.getDefaultMapName();

 

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapLayerInfo[] maplayerinfos = mapinfo.getMapLayerInfos();

int layerid = 0;

 

for (MapLayerInfo layerinfo : maplayerinfos)

{

if (layerinfo.getName().equals("states"))

{

    layerid = layerinfo.getLayerID();

}

}

 

QueryFilter queryfilter = new QueryFilter();

queryfilter.setWhereClause("STATE_NAME LIKE '%Ca%'");

 

RecordSet recordset = null;

 

recordset = mapservice.queryFeatureData(mapname, layerid, queryfilter);

 

QueryFeatureData2

 

QueryFeatureIDs

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapname);

MapLayerInfo[] maplayerinfos = mapinfo.getMapLayerInfos();

 

int layerid = 0;

for (MapLayerInfo layerinfo : maplayerinfos)

{

if (layerinfo.getName().equals("states"))

{

    layerid = layerinfo.getLayerID();

}

}

 

QueryFilter queryfilter = new QueryFilter();

queryfilter.setWhereClause("STATE_NAME LIKE '%Ca%'");

 

FIDSet fidset = mapservice.queryFeatureIDs(mapname, layerid, queryfilter);

 

QueryFeatureIDs2

 

QueryHyperlinks
 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

String mapname = mapservice.getDefaultMapName();

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

LayerDescription[] layerdescriptions = mapdesc.getLayerDescriptions();

int[] layerids = new int[layerdescriptions.length];

int i = 0;

 

for (LayerDescription layerdesc : layerdescriptions)

{

layerids[i++] = layerdesc.getLayerID();

}

 

MapServerHyperlink[] hyperlinkresults = mapservice.queryHyperlinks(mapdesc, imgdisp, layerids);

 

ToMapPoints

 

String wsService = "http://localhost:8399/arcgis/services/MapService/MapServer";

MapServerBindingStub mapservice = new MapServerBindingStub(new java.net.URL(wsService), null);

 

MapServerInfo mapinfo = mapservice.getServerInfo(mapservice.getDefaultMapName());

MapDescription mapdesc = mapinfo.getDefaultMapDescription();

 

ImageDisplay imgdisp = new ImageDisplay();

imgdisp.setImageHeight(500); //pixels

imgdisp.setImageWidth(500); //pixels

imgdisp.setImageDPI(96);

 

int[] screenx = new int[1];

int[] screeny = new int[1];

 

screenx[0] = 261;

screeny[0] = 292;

 

MultipointN multipoint = (MultipointN)mapservice.toMapPoints(mapdesc, imgdisp, screenx, screeny); 

 

GeocodeServer

 

FindAddressCandidates  

 

// Get supported fields

Fields fields = geocodeServerStub.getAddressFields();

 

// Setup locator properties

PropertySet propertyMods = geocodeServerStub.getLocatorProperties();

PropertySetProperty[] locatorArray = propertyMods.getPropertyArray();

 

// street,zip,num_of_results

String street = "1 Main St.";

String zip = "94105";

int expectedResultsCount = 1;

 

// Input to FindAddressCandidates

PropertySet address = new PropertySet();

 

// Address to geocode

PropertySetProperty[] inputFields = new PropertySetProperty[fields.getFieldArray().length];

 

for (int index = 0; index < fields.getFieldArray().length; index++) {

// Set the values for the supported fields

Field field = fields.getFieldArray()[index];

PropertySetProperty property = new PropertySetProperty();

property.setKey(field.getName());

 

// Set STREET

if (field.getName().toUpperCase().equalsIgnoreCase("STREET")) {

  property.setValue(street);

  inputFields[index] = property;

  continue;

}

 

// Set zip code

if (field.getName().toUpperCase().equalsIgnoreCase("ZONE")) {

  property.setValue(zip);

  inputFields[index] = property;

  continue;

}

 

// Polulate address

address.setPropertyArray(inputFields);

 

// Change locator property value

for (int index = 0; index < locatorArray.length; index++) {

PropertySetProperty property = locatorArray[index];

if (property.getKey().equalsIgnoreCase("MinimumCandidateScore")) {

  property.setValue("20");

}

 

// FindAddressCandidates

RecordSet candidates = geocodeServerStub.findAddressCandidates(address,null);

 

// Optional parsing of the results

if (candidates != null) {

String fieldsOutput = "";

for (Field field : candidates.getFields().getFieldArray()) {

  fieldsOutput += field.getName();

}

 

for (Record record : candidates.getRecords()) {

  String valuesOutput = "";

  Object[] values = record.getValues();

  for (int index = 0; index < candidates.getFields().getFieldArray().length;index++) {

    valuesOutput += " " + values[index].toString();

  }

}

 

GeocodeAddress

 

      String street = "1 Main St.";

      String zip = "94105";

      int expectedResultsCount = 1;

      PropertySetProperty[] address = new PropertySetProperty[2];

      // Set street

      PropertySetProperty streetProp = new PropertySetProperty();

      streetProp.setKey("STREET");

      streetProp.setValue(street);

      address[0] = streetProp;

      // Set zip

      PropertySetProperty zoneProp = new PropertySetProperty();

      zoneProp.setKey("ZONE");

      zoneProp.setValue(zip);

      address[1] = zoneProp;

      // Input geocode property set

      PropertySet geocodeProp = new PropertySet();

      geocodeProp.setPropertyArray(address);

      // Geocode address

      PropertySet results = geocodeServerStub.geocodeAddress(geocodeProp, null);

 

      for (PropertySetProperty result : results.getPropertyArray()) {

        if (result.getKey().equalsIgnoreCase("Shape")) {

          PointN geocodePoint = (PointN) result.getValue();

          double x = geocodePoint.getX();

          double y = geocodePoint.getY();

        }

      }// for

 

GeocodeAddresses
 

    PropertySetProperty geocodeProp1 = new PropertySetProperty();

    geocodeProp1.setKey("STREET");

    geocodeProp1.setValue("STREET");

 

    PropertySetProperty geocodeProp2 = new PropertySetProperty();

    geocodeProp2.setKey("ZONE");

    geocodeProp2.setValue("ZONE");

 

    PropertySetProperty[] propArray = new PropertySetProperty[2];

    propArray[0] = geocodeProp1;

    propArray[1] = geocodeProp2;

    PropertySet geocodePropSet = new PropertySet();

    geocodePropSet.setPropertyArray(propArray);

 

    // Create a new recordset to store input addresses to be batch geocoded

    RecordSet addressTable = new RecordSet();

    // Create fields for input address table

    Field[] fieldarray = new Field[3];

    // Following field properties are required for batch geocode to work:

    // Length, Name, Type. There also needs to be a field of type OID.

    Field field0 = new Field();

    field0.setName("OID");

    field0.setType(EsriFieldType.esriFieldTypeOID);

    field0.setLength(50);

    fieldarray[0] = field0;

    Field field1 = new Field();

    field1.setName("Street");

    field1.setType(EsriFieldType.esriFieldTypeString);

    field1.setLength(50);

    fieldarray[1] = field1;

    Field field2 = new Field();

    field2.setName("Zone");

    field2.setType(EsriFieldType.esriFieldTypeString);

    field2.setLength(50);

    fieldarray[2] = field2;

    Fields fields = new Fields();

    fields.setFieldArray(fieldarray);

    addressTable.setFields(fields);

   

    // Add records to input address table

    Record[] records = new Record[2];

    Record record1 = new Record();

    Record record2 = new Record();

    record1.setValues (new Object[] {0, "5950 Magnolia Ave.", "92506"});

    record2.setValues (new Object[] {0, "5962 Magnolia Ave.", "92506"});

    records[0]=record1;

    records[1]=record2;

 

    addressTable.setRecords(records);

    // Generate results table

    RecordSet results = geocodeServerStub.geocodeAddresses(addressTable, geocodePropSet, null);

    for (Record record : results.getRecords()) {

      Object[] values = record.getValues();

      int v = 0;

      String valuesoutput = "";

      for (Field field : results.getFields().getFieldArray()) {

        valuesoutput += values[v].toString() + "\t";

        v++;

      }

    }

 

GetAddressFields

 

    // Test GetAddressFields

    Fields addressFields = geocodeServerStub.getAddressFields();

    Set<String> setOfAddressFields = new HashSet<String>();

    for (Field addressField : addressFields.getFieldArray()) {

      setOfAddressFields.add(addressField.getName());

    }

 

GetCandidateFields

 

    // Test GetCandidateFields

    PropertySet propertyMods = geocodeServerStub.getLocatorProperties();

    Fields candidateFields = geocodeServerStub.getCandidateFields(propertyMods);

    Set<String> setOfCandidateFields = new HashSet<String>();

    for (Field candidateField : candidateFields.getFieldArray()) {

      setOfCandidateFields.add(candidateField.getName());

    }

 

GetDefaultInputFieldMapping

 

    // Test GetDefaultInputFieldMapping

    Map<String, String> mapOfFieldMappings = new HashMap<String, String>();

    PropertySet fieldMapProps = geocodeServerStub.getDefaultInputFieldMapping();

    PropertySetProperty[] fieldMapArray = fieldMapProps.getPropertyArray();

    for (PropertySetProperty fieldMapProperty : fieldMapArray) {

      mapOfFieldMappings.put(fieldMapProperty.getKey(),

          (String) fieldMapProperty.getValue());

    }

 

GetIntersectionCandidateFields

 

    // Test GetIntersectionCandidateFields

    PropertySet propertyMods2 = geocodeServerStub.getLocatorProperties();

    Fields candidateFields2 = geocodeServerStub.getIntersectionCandidateFields(propertyMods2);

    Set<String> setOfInterCandiFields = new HashSet<String>();

    for (Field candidateField : candidateFields2.getFieldArray()) {

      setOfInterCandiFields.add(candidateField.getName());

    }

 

GetLocatorProperties
 

    // Test GetLocatorProperties

    PropertySet locatorProps = geocodeServerStub.getLocatorProperties();

    PropertySetProperty[] locatorArray = locatorProps.getPropertyArray();

    Set<String> setOfLocatorProps = new HashSet<String>();

    for (PropertySetProperty locatorProperty : locatorArray) {

      setOfLocatorProps.add(locatorProperty.getKey());

    }

 

GetResultFields

 

    // Test GetResultFields

    PropertySet propertyMods3 = geocodeServerStub.getLocatorProperties();

    Fields resultFields = geocodeServerStub.getResultFields(propertyMods3);

    Set<String> setOfResultFields = new HashSet<String>();

    for (Field candidateField : resultFields.getFieldArray()) {

      setOfResultFields.add(candidateField.getName());

    }

 

GetStandardizedFields

 

    // Test GetStandardizedFields

    Fields standardizedFields = geocodeServerStub.getStandardizedFields();

    Set<String> setOfStdFields = new HashSet<String>();

    for (Field stdField : standardizedFields.getFieldArray()) {

      setOfStdFields.add(stdField.getName());

    }

 

GetStandardizedIntersectionFields

 

    // Test GetStandardizedIntersectionFields

    Fields standInterFields = geocodeServerStub.getStandardizedIntersectionFields();

    Set<String> setOfStdInterFields = new HashSet<String>();

    for (Field stdInterField : standInterFields.getFieldArray()) {

      setOfStdInterFields.add(stdInterField.getName());

    }

 

ReverseGeocode

 

    // Set reverse geocode search parameters

    PropertySetProperty revGeocodeProp1 = new PropertySetProperty();

    revGeocodeProp1.setKey("ReverseDistanceUnits");

    revGeocodeProp1.setValue("Meters");

 

    PropertySetProperty revGeocodeProp2 = new PropertySetProperty();

    revGeocodeProp2.setKey("ReverseDistance");

    revGeocodeProp2.setValue("100");

 

    // Optionally define output spatial reference for reverse geocoded point

    ProjectedCoordinateSystem projectedCoordinateSystem = new ProjectedCoordinateSystem();

    projectedCoordinateSystem.setWKID(54004);

    PropertySetProperty revGeocodeProp3 = new PropertySetProperty();

    revGeocodeProp3.setKey("OutputSpatialReference");

    revGeocodeProp3.setValue(projectedCoordinateSystem);

    PropertySetProperty[] propArray = new PropertySetProperty[] {

        revGeocodeProp1, revGeocodeProp2, revGeocodeProp3 };

    PropertySet revGeocodePropSet = new PropertySet();

    revGeocodePropSet.setPropertyArray(propArray);

 

    // Create point to reverse geocode, define input spatial reference

    GeographicCoordinateSystem geographicCoordinateSystem = new GeographicCoordinateSystem();

    geographicCoordinateSystem.setWKID(4326);

 

    double xCoord = -122.39649504;

    double yCoord = 37.7931136;

    PointN inputPoint = new PointN();

    inputPoint.setX(xCoord);

    inputPoint.setY(yCoord);

    inputPoint.setSpatialReference(geographicCoordinateSystem);

 

    // Reverse geocode

    PropertySet results = geocodeServerStub.reverseGeocode(inputPoint, false, revGeocodePropSet);

 

StandardizeAddress

 

    // Create an address - This is specific to San Francisco

    PropertySetProperty geocodeProp1 = new PropertySetProperty();

    geocodeProp1.setKey("Street");

    geocodeProp1.setValue("1 Main St.");

 

    PropertySetProperty geocodeProp2 = new PropertySetProperty();

    geocodeProp2.setKey("Zone");

    geocodeProp2.setValue("94105");

 

    PropertySetProperty[] propArray = new PropertySetProperty[2];

    propArray[0] = geocodeProp1;

    propArray[1] = geocodeProp2;

    PropertySet geocodePropSet = new PropertySet();

    geocodePropSet.setPropertyArray(propArray);

 

    // StandardizeAddress

    PropertySet standardizedAddress = geocodeServerStub.standardizeAddress(

        geocodePropSet, null);

    PropertySetProperty[] standardArray = standardizedAddress.getPropertyArray();

    Map<String, String> mapOfStandardizedAddr = new HashMap<String, String>();

    for (PropertySetProperty result : standardArray) {

      mapOfStandardizedAddr.put(result.getKey(), (String) result.getValue());

    }

 

GPServer

 

CancelJob

 

        // Set up Server URL

        String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

                        

// Set up input values

        GPString inString = new GPString();

        inString.setValue("test string");

 

        GPDouble inDbl = new GPDouble();

        inDbl.setValue(55.98);

 

        GPValue[] inputValues = {inString, inDbl};

                        

        // input Service Name

        String gpServiceName = "SimpleParamTests";

                        

        // Submit Job

        String submitJobID = gpServerStub.submitJob(gpServiceName, inputValues, null, null);

 

        // Check Job Status

EsriJobStatus jobStat = gpServerStub.getJobStatus(submitJobID);

               

// If the job is submitted, cancel it and get the status again

if (jobStat.getValue().toLowerCase() == EsriJobStatus.esriJobSubmitted.getValue().toLowerCase()) {

gpServerStub.cancelJob(submitJobID);

jobStat = gpServerStub.getJobStatus(submitJobID);

System.out.print ("Job status is " + jobStat.getValue());

}

 

Execute
 

/*Set up Server URL */

String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

                        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

                        

                        /*Set up input values */

                        GPString inString = new GPString();

                        inString.setValue("test string");

 

                        GPDouble inDbl = new GPDouble();

                        inDbl.setValue(55.98);

 

                        GPValue[] inputValues = {inString, inDbl};

                        

                        /* input Service Name */

                        String gpServiceName = "SimpleParamTests";

                        

GPResult result = null;

 

                        /* Submit Job*/

                        String submitJobID = gpServerStub.submitJob(gpServiceName, inputValues, null, null);

 

                        /* Check Job Status */

                        try {

                                    EsriJobStatus jobStat = gpServerStub.getJobStatus(submitJobID);

 

                                    /* Ensure the jobs status is succeed, then you can call the rest of tests */

                                    while (jobStat != EsriJobStatus.esriJobSucceeded)

                                                result = gpServerStub.execute(gpServiceName, inputValues, null, null);

                        } catch (Exception e){

                                    System.out.println("Exception occured: " + e.getStackTrace());

                        }

 

 

 

GetExecutionType

 

String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

GPServerBindingStub gStub = new GPServerBindingStub(ServerURL);

ExecutionType eType = gStub.getExecutionType();

 

GetJobEnvironmentValues
 

GetJobInputValues

 

GPToolInfo ti = new GPToolInfo();

GPParameterInfo[] pis = null;

String[] inParams = null;

GPValue[] values = null;

int rlength = 0;

int n=0;

if (jobStat.toString() == EsriJobStatus.esriJobSucceeded.toString()) {

if (modelNumber == 0 || modelNumber == 1 || modelNumber == 2 || modelNumber == 7 || modelNumber ==8) {

ti  = gStub.getToolInfo(modelName);

int paramLen = ti.getParameterInfo().length;

pis = new GPParameterInfo[paramLen];

pis = ti.getParameterInfo();

if ((jobStat.toString()!= EsriJobStatus.esriJobFailed.toString()) && (jobStat.toString() != EsriJobStatus.esriJobTimedOut.toString()))

{   

n=0;

inParams =  new String[paramLen];

for (int k = 0; k<pis.length; k++)

{

GPParameterInfo pi = pis[k];

if ( (pi.getDirection() == EsriGPParameterDirection.esriGPParameterDirectionInput)){

inParams[n] = pi.getName();

n++;

}

String[] inputParams = new String[n];

for (int s = 0; s<n; s++) inputParams[s] = inParams[s];

values = gStub.getJobInputValues(submitJobID, inputParams);

rlength = values.length;

for (int s = 0; s<rlength; s++)

{

xHelper.Serialize(testType, values, modelNumber, s, testPath + File.separator + "Input", "Layer", ef.getServerName());

} // for s

} // if jobStat    

else {

System.out.print("Cannot get Job Result, Job Status = " + jobStat.toString());

}  //else

}

}  // if

 

GetJobMessages

 

JobMessage[] msgs = gStub.getJobMessages(submitJobID);

 

GetJobResult
 

// Set up Server URL

String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

                        

// Set up input value

GPString inString = new GPString();

inString.setValue("test string");

 

GPDouble inDbl = new GPDouble();

inDbl.setValue(55.98);

 

GPValue[] inputValues = {inString, inDbl};

                        

// input Service Name

String gpServiceName = "SimpleParamTests";

                        

// Submit Job

String submitJobID = gpServerStub.submitJob(gpServiceName, inputValues, null, null);

 

// Ensure the jobs status is succeed

if (jobStat == EsriJobStatus.esriJobSucceeded) {

GPResult result = gpServerStub.getJobResult(submitJobID, null, null);

}

 

GetJobResultMapExtent

 

GetJobResultOptions

 

GPResultOptions gprop = new GPResultOptions();

gprop = gStub.getJobResultOptions(this.submitJobID);

 

GetJobStatus

 

// First job is submitted, then canceled, then use GetJobStatus() to see if the status is cancelled.

// Set up Server URL

String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

                        

// Set up input values

GPString inString = new GPString();

inString.setValue("test string");

 

GPDouble inDbl = new GPDouble();

inDbl.setValue(55.98);

 

GPValue[] inputValues = {inString, inDbl};

                        

// input Service Name

String gpServiceName = "SimpleParamTests";

                        

// Submit Job

String submitJobID = gpServerStub.submitJob(gpServiceName, inputValues, null, null);

 

// Check Job Status

EsriJobStatus jobStat = gpServerStub.getJobStatus(submitJobID);

 

GetJobToolName

 

// if the job is successful, get the job tool name

if (jobStat.toString() == EsriJobStatus.esriJobSucceeded.toString()) {

String toolName = "";

try {

toolName = gStub.getJobToolName(GPSvrPostSubmit.submitJobID);

} catch(Exception e){

e.printStackTrace();

}

}

 

GetResultMapServerName

 

String ServerName = gStub.getResultMapServerName();

 

GetResultWorkspace

 

EsriGDSTransportType gtype = EsriGDSTransportType.esriGDSTransportTypeUrl;

// if the jobStat is success

if (jobStat.toString() == EsriJobStatus.esriJobSucceeded.toString()) {

GDSData gData = gStub.getResultWorkspace(submitJobID,gtype);

}

 

GetTaskInfos

 

        // Setup Server URL

        String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

String[] taskOrInfoNames = null;

 

int Length = gpServerStub.getToolInfos().length;

taskOrInfoNames = new String[Length];

for (int i = 0; i<Length; i++){

taskOrInfoNames[i] = gpServerStub.getTaskInfos()[i].getName();

}

 

GetTaskNames

 

        // Setup Server URL

        String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

String[] taskNames = gpServerStub.getTaskNames();

 

GetToolInfo

 

// Setup Server URL

        String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

                        

        // Obtain tool name

        String toolNames[] = gStub.getToolNames();
     int length = toolNames.length;

            

        GPToolInfo[] ToolInfo = new GPToolInfo[length];

 

        // Call GetToolInfo

        for (int i = 0; i< length; i++) {             

             ToolInfo[length] = gpServerStub.getToolInfo(toolNames[length]);

}

 

GetToolInfos

 

        // Setup Server URL

        String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

String[] taskOrInfoNames = null;

 

int Length = gpServerStub.getToolInfos().length;

taskOrInfoNames = new String[Length];

for (int i = 0; i<Length; i++){

taskOrInfoNames[i] = gStub.getToolInfos()[i].getDisplayName();

}

 

GetToolNames

 

        // Setup Server URL

        String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

        GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

String toolNames[] = gpServerStub.getToolNames();

 

SubmitJob  

 

// Set up Server URL

String ServerURL = "http://localhost/arcgis/services/GP/ByValTools/GPServer";

GPServerBindingStub gpServerStub = new GPServerBindingStub(ServerURL);

                        

// Set up input values

GPString inString = new GPString();

inString.setValue("test string");

 

GPDouble inDbl = new GPDouble();

inDbl.setValue(55.98);

 

GPValue[] inputValues = {inString, inDbl};

                        

//input Service Name

String gpServiceName = "SimpleParamTests";

                        

// Submit Job

String submitJobID = gpServerStub.submitJob(gpServiceName, inputValues, null, null);

 
 

GeoDataServer

 

CompareReplicaSchema

 

CreateReplica

 

ExpandReplicaDatasets

 

ExportAcknowledgement

 

ExportReplicaDataChanges

 

ExportReplicaSchema

 

ExtractData
 

GDSData extractedData = geoDataServer.extractData(null, replicaDesc, exportOpts, transportType);

 

GetDataElements

 

DEBrowseOptions browseOptions = new DEBrowseOptions();

browseOptions.setExpandType(EsriDEExpandType.esriDEExpandChildren);

browseOptions.setRetrieveFullProperties(true);

browseOptions.setRetrieveMetadata(true);

 

DataElement[] ele = geoDataServer.getDataElements(browseOptions);

 

GetDefaultWorkingVersion

 

String defaultWorkingVersion = geodataServerStub.getDefaultWorkingVersion();

 

GetMaxRecordCount

 

// Test GetMaxRecordCount

int maxRecordCount = geodataServerStub.getMaxRecordCount();

 

GetNextResultPortion

 

GDSQueryResultPortion gdsQueryResPortion = geoDataServer.getNextResultPortion(resultInfo);

 

GetReplicas

 

// Test GetReplicas

Set<String> setOfReplicas = new HashSet<String>();

GPReplica[] replicas = geodataServerStub.getReplicas();

for (GPReplica replica : replicas) {

setOfReplicas.add(replica.getName());

}

 

GetVersions

 

GPVersionInfo[] gpVersionInfoss = geodataServerStub.getVersions(); 

 

GetWrappedWorkspaceType

 

// Test GetWrappedWorkspaceType

EsriWorkspaceType workspaceType = geodataServerStub.getWrappedWorkspaceType();

 

ImportAcknowledgement

 

geoDataServer.importAcknowledgement(extractedData);

 

ImportData

 

geoDataServer.importData(extractedData, EsriGDSImportFormat.esriGDSImportFormatFileGDB);

 

ImportReplicaDataChanges

 

ImportReplicaSchemaChanges

 

ReExportReplicaDataChanges

 

TableSearch

 

GDSQueryResultPortion queryResults = geoDataServer.tableSearch(null, "states", qf, resultInfo);

 

UnregisterReplica

 

geoDataServer.unregisterReplica("test");

 

 

GeometryServer

 

Buffer
 

    // Set input spatial reference

    SpatialReference inputSpatialReference = new GeographicCoordinateSystem();

    inputSpatialReference.setWKT("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",

 SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]");

    
    // Set buffer spatial reference

    SpatialReference bufferSpatialReference = new ProjectedCoordinateSystem();

    bufferSpatialReference.setWKID(102004);// USA_Contiguous_Lambert_Conformal_Conic

    // Set output spatial reference

    SpatialReference outputSpatialReference = inputSpatialReference;

    // Input points

    PointN inputPoint1 = new PointN();

    inputPoint1.setX(-110);

    inputPoint1.setY(40);

    PointN inputPoint2 = new PointN();

    inputPoint2.setX(-120);

    inputPoint2.setY(45);

    // Input geometry

    Geometry[] inputGeometry = new Geometry[] { inputPoint1, inputPoint2 };

    // Distance for buffer for each point

    double[] distances = new double[] { 400, 200 };

    // Set the unit

    LinearUnit linearUnit = new LinearUnit();

    linearUnit.setWKID(9035);

    boolean bUnionResults = false;

    // Run the buffer operation

    Geometry[] outputGeometry = geometryServerStub.buffer(

        inputSpatialReference, bufferSpatialReference, outputSpatialReference,

        distances, linearUnit, bUnionResults, inputGeometry);

 

Densify

    // Input spatial reference

    SpatialReference inputSpatialReference = new ProjectedCoordinateSystem();

    inputSpatialReference.setWKID(54004); // World Mercator

    // Points that will form a path

    PointN p1 = new PointN();

    p1.setX(500000);

    p1.setY(500000);

    PointN p2 = new PointN();

    p2.setX(600000);

    p2.setY(50000);

    PointN p3 = new PointN();

    p3.setX(700000);

    p3.setY(50000);

    PointN[] pointsArray = new PointN[] { p1, p2, p3 };

    // Create a path

    Path inputPath = new Path();

    inputPath.setPointArray(pointsArray);

    Path[] paths = new Path[] { inputPath };

    // Create a polyline

    PolylineN inputPolyline = new PolylineN();

    inputPolyline.setPathArray(paths);

    // Input geometry

    Geometry[] inputGeometry = new Geometry[] { inputPolyline };

    // Densify parameters

    double maxSegmentLength = 10000;

    boolean bUseDeviationDensification = false;

    double densificationParam = 0;

    // Densify

    Geometry[] outputGeometry = geometryServerStub.densify(

        inputSpatialReference, inputGeometry, maxSegmentLength,

        bUseDeviationDensification, densificationParam);

 

FindSRByWKID

 

    SpatialReference outputSpatialReference = null;

    // Test FindSRByWKID - Geographic WGS84

    outputSpatialReference = geometryServerStub.findSRByWKID("EPSG", 4326, -1,

        true, true);

    boolean bIsHighPrecision = outputSpatialReference.getHighPrecision();

 

FindSRByWKT

 

    // Test FindSRByWKT - Geographic WGS84

    outputSpatialReference = geometryServerStub

        .findSRByWKT(            "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]",

            "", true, true);

    int expectedWKID = outputSpatialReference.getWKID();

 

FindUnitsByWKID

 

    // Test FindUnitsByWKID - International Meter

    LinearUnit linearUnit = (LinearUnit) geometryServerStub.findUnitsByWKID(

        "EPSG", 9001);

 

FindUnitsByWKT

 

    // Test FindUnitsByWKT - International Meter

    LinearUnit linearUnit2 = (LinearUnit) geometryServerStub

        .findUnitsByWKT("UNIT[\"Meter\",1.0,AUTHORITY[\"EPSG\",9001]]");

 

GetAreasAndLengths

 

    // Test GetAreasAndLength

    SpatialReference inputSpatialReference = geometryServerStub.findSRByWKID(

        "EPSG", 54004, -1, true, true);

    // New PointN array

    PointN pnt1 = new PointN();

    pnt1.setX(100000);

    pnt1.setY(300000);

    PointN pnt2 = new PointN();

    pnt2.setX(100000);

    pnt2.setY(350000);

    PointN pnt3 = new PointN();

    pnt3.setX(900000);

    pnt3.setY(350000);

    PointN[] points1 = new PointN[] { pnt1, pnt2, pnt3 };

    // New PolylineN

    Path path1 = new Path();

    path1.setPointArray(points1);

    Path[] paths1 = new Path[] { path1 };

    PolylineN polylinen = new PolylineN();

    polylinen.setPathArray(paths1);

    // New PolygonN

    Ring ring1 = new Ring();

    ring1.setPointArray(points1);

    Ring[] rings1 = new Ring[] { ring1 };

    PolygonN polygonN1 = new PolygonN();

    polygonN1.setRingArray(rings1);

    PolygonN[] polygonArray1 = new PolygonN[] { polygonN1 };

    // Get areas and length

    ArrayOfDoubleHolder lengthsArray = new ArrayOfDoubleHolder();

    ArrayOfDoubleHolder areasArray = new ArrayOfDoubleHolder();

    geometryServerStub.getAreasAndLengths(inputSpatialReference, polygonArray1,

        lengthsArray, areasArray);

 

GetLabelPoints

 

    // Test GetLabelPoints

    SpatialReference inputSpatialReference2 = geometryServerStub.findSRByWKID(

        "EPSG", 4269, -1, true, true);

    // Setup the geometry

    PointN p1 = new PointN();

    p1.setX(10.0);

    p1.setY(30.0);

    PointN p2 = new PointN();

    p2.setX(10.0);

    p2.setY(40.0);

    PointN p3 = new PointN();

    p3.setX(20.0);

    p3.setY(40.0);

    PointN p4 = new PointN();

    p4.setX(20.0);

    p4.setY(30.0);

    PointN p5 = new PointN();

    p5.setX(10.0);

    p5.setY(30.0);

    PointN[] points2 = new PointN[] { p1, p2, p3, p4, p5 };

    Ring ring2 = new Ring();

    ring2.setPointArray(points2); // COMMENTING THIS LINE CRASHES DISCOVERY

    Ring[] rings2 = new Ring[] { ring2 };

    PolygonN polygonN2 = new PolygonN();

    polygonN2.setRingArray(rings2);

    PolygonN[] polygonArray2 = new PolygonN[] { polygonN2 };

    // GetLabelPoints

    Point[] labelPoints = (Point[]) geometryServerStub.getLabelPoints(

        inputSpatialReference2, polygonArray2);

 

GetLengths

 

    // Test GetLengths

    SpatialReference inputSpatialReference3 = geometryServerStub.findSRByWKID(

        "EPSG", 54004, -1, true, true);

    // Create some points for a polyline

    PointN pt1 = new PointN();

    p1.setX(100000);

    p1.setY(300000);

    PointN pt2 = new PointN();

    pt2.setX(100000);

    pt2.setY(350000);

    PointN pt3 = new PointN();

    pt3.setX(900000);

    pt3.setY(350000);

    PointN[] points3 = new PointN[] { pnt1, pnt2, pnt3 };

    // New PolylineN

    Path path3 = new Path();

    path3.setPointArray(points3);

    Path[] paths3 = new Path[] { path3 };

    PolylineN polylineN3 = new PolylineN();

    polylineN3.setPathArray(paths3);

    PolylineN[] polylineArray3 = new PolylineN[] { polylineN3 };

    // Get the length of the polyline

    double[] lengths3 = geometryServerStub.getLengths(inputSpatialReference3,

        polylineArray3);

 

Project

 

Relation

 

    // Set the input spatial reference

    SpatialReference inputSpatialReference = new GeographicCoordinateSystem();

    inputSpatialReference.setWKID(4326);

    // First input geometry array - 1 polygon

    PointN pnt1a = new PointN();

    pnt1a.setX(10.0);

    pnt1a.setY(30.0);

    PointN pnt2a = new PointN();

    pnt2a.setX(10.0);

    pnt2a.setY(45.0);

    PointN pnt3a = new PointN();

    pnt3a.setX(25.0);

    pnt3a.setY(45.0);

    PointN pnt4a = new PointN();

    pnt4a.setX(25.0);

    pnt4a.setY(30.0);

    PointN pnt5a = new PointN();

    pnt5a.setX(10.00);

    pnt5a.setY(30.0);

    PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };

    Ring ring1 = new Ring();

    ring1.setPointArray(pnts1a);

    Ring[] rings = new Ring[] { ring1 };

    PolygonN polygon1 = new PolygonN();

    polygon1.setRingArray(rings);

    Geometry[] inputGeometry1 = new Geometry[] { polygon1 };

    // Second input geometry array - 3 points

    PointN pnt1b = new PointN();

    pnt1b.setX(20.0);

    pnt1b.setY(40.0);

    PointN pnt2b = new PointN();

    pnt2b.setX(10.0);

    pnt2b.setY(30.0);

    PointN pnt3b = new PointN();

    pnt3b.setX(50.0);

    pnt3b.setY(50.0);

    Geometry[] inputGeometry2 = new Geometry[3];

    // Inside polygon

    inputGeometry2[0] = pnt1b;

    // Edge of polygon

    inputGeometry2[1] = pnt2b;

    // Outside polygon

    inputGeometry2[2] = pnt3b;

    // If esriGeometryRelationRelation, define relation parameter

    EsriGeometryRelationEnum enumRelate = EsriGeometryRelationEnum.esriGeometryRelationRelation;

    // G1 = first (base) geometry array, G2 = second (comparison) geometry array

    String relationParameter = "G2 INTERSECT G1.BOUNDARY";

    RelationResult[] relationResults = geometryServerStub.relation(

        inputSpatialReference, inputGeometry1, inputGeometry2, enumRelate,

        relationParameter);

 

Simplify

 

    SpatialReference inputSpatialReference = geometryServerStub.findSRByWKID(

        "EPSG", 4326, -1, true, true);

    // Ring 1

    PointN pnt1a = new PointN();

    pnt1a.setX(10.0);

    pnt1a.setY(30.0);

    PointN pnt2a = new PointN();

    pnt2a.setX(10.0);

    pnt2a.setY(45.0);

    PointN pnt3a = new PointN();

    pnt3a.setX(25.0);

    pnt3a.setY(45.0);

    PointN pnt4a = new PointN();

    pnt4a.setX(25.0);

    pnt4a.setY(30.0);

    PointN pnt5a = new PointN();

    pnt5a.setX(10.0);

    pnt5a.setY(30.0);

    PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };

    Ring ring1 = new Ring();

    ring1.setPointArray(pnts1a);

    // Ring 2

    PointN pnt1b = new PointN();

    pnt1b.setX(15.0);

    pnt1b.setY(35.0);

    PointN pnt2b = new PointN();

    pnt2b.setX(15.0);

    pnt2b.setY(50.0);

    PointN pnt3b = new PointN();

    pnt3b.setX(30.0);

    pnt3b.setY(50.0);

    PointN pnt4b = new PointN();

    pnt4b.setX(30.0);

    pnt4b.setY(35.0);

    PointN pnt5b = new PointN();

    pnt5b.setX(15.0);

    pnt5b.setY(35.0);

    PointN[] pnts1b = new PointN[] { pnt1b, pnt2b, pnt3b, pnt4b, pnt5b };

    Ring ring2 = new Ring();

    ring2.setPointArray(pnts1b);

    // Multipart Polygon (2 overlapping rings)

    Ring[] rings = new Ring[] { ring1, ring2 };

    PolygonN polygon1 = new PolygonN();

    polygon1.setRingArray(rings);

    Geometry[] geometryArray = new Geometry[] { polygon1 };

    // Overlapping section removed

    Geometry[] simplifiedGeometry = geometryServerStub.simplify(

        inputSpatialReference, geometryArray);

 

 

ImageServer

 

ExportImage

 

    // Get GeoImageDescription

    GeoImageDescription geoImgDesc = new GeoImageDescription();

    

    // Setup extent

    ImageServiceInfo serviceInfo = imageServerStub.getServiceInfo();

    EnvelopeN extent = (EnvelopeN)serviceInfo.getExtent();

    geoImgDesc.setExtent(extent);

    geoImgDesc.setHeight(600);

    geoImgDesc.setWidth(800);

    

    // Setup imagetype

    ImageType imageType = new ImageType();

    imageType.setImageFormat(EsriImageFormat.esriImageJPG);

    imageType.setImageReturnType(EsriImageReturnType.esriImageReturnURL);

 

    // Export image

    ImageResult imageResult = imageServerStub.exportImage(geoImgDesc, imageType);

 

GetImage

 

ImageServerBindingStub imgServer = new

ImageServerBindingStub(new URL("http://YourServerNamef:8399/arcgis/services/ServiceName/ImageServer"), null);

 

GeoImageDescription imgDesc = new GeoImageDescription();

 

int[] bandIds = new int[3];

bandIds[0] = 1;

bandIds[1] = 0;

bandIds[2] = 1;

imgDesc.setBandIDs(bandIds);

 

imgDesc.setHeight(500);

imgDesc.setWidth(500);

imgDesc.setExtent(imgServer.getServiceInfo().getExtent());

 

byte[] image = imgServer.getImage(imgDesc);

 

GetServiceInfo

 

     // Get service info

    ImageServiceInfo serviceInfo = imageServerStub.getServiceInfo();

    String actualServiceName = serviceInfo.getName();

 

    String expectedServiceName = ConfigFileReader

        .getProperty(ConfigFileReader.IS_SERVICE_NAME_PROP);

 

GetVersion

 

ImageServerBindingStub imgServer = new    ImageServerBindingStub("http://YourServerName:8399/arcgis/services/ServiceName/ImageServer","",""); 

 

 

NAServer

 

GetNALayerNames

 

String[] actualReturn = routeServerPort.getNALayerNames(EsriNAServerLayerType.esriNAServerRouteLayer);

 

GetNetworkDescription

 

    // Test GetNetworkDescription

    NAServerNetworkDescription networkDesc = naServerStub

        .getNetworkDescription(ConfigFileReader

            .getProperty(ConfigFileReader.NA_INPUT_ROUTE_LAYER_NAME_PROP));

 

GetSolverParameters

 

   NAServerRouteParams routeParams

        = (NAServerRouteParams) routeServerPort.getSolverParameters(routeServerPort.getNALayerNames(

            EsriNAServerLayerType.esriNAServerRouteLayer)[0]);

  

    NAServerClosestFacilityParams cfParams

        = (NAServerClosestFacilityParams) cfServerPort.getSolverParameters(cfServerPort.

        getNALayerNames(

            EsriNAServerLayerType.esriNAServerClosestFacilityLayer)[0]);

 

Solve

 

NAServerRouteResults results = (NAServerRouteResults) routeServerPort.solve(routeParams);