27
Building Web Services with ArcGIS Building Web Services with ArcGIS Server and Java Server and Java Eric Miller Eric Miller Antony Antony Jayaprakash Jayaprakash Jay Theodore Jay Theodore Steven Citron Steven Citron - - Pousty Pousty

Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Building Web Services with ArcGIS Building Web Services with ArcGIS Server and JavaServer and Java

Eric MillerEric MillerAntonyAntony JayaprakashJayaprakash

Jay TheodoreJay TheodoreSteven CitronSteven Citron--PoustyPousty

Page 2: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

OverviewOverview

•• Web Services OverviewWeb Services Overview

•• ArcGIS Server Web ServicesArcGIS Server Web Services

•• Creating and Consuming ArcGIS Server Web ServicesCreating and Consuming ArcGIS Server Web Services

•• Application Web ServicesApplication Web Services

•• Creating and Consuming Application Web ServicesCreating and Consuming Application Web Services

•• New at 9.2New at 9.2

•• API references and DocumentationAPI references and Documentation

Page 3: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Web Services OverviewWeb Services Overview

Bind – generate stubs from WSDLInvoke – SOAP over HTTPWeb Service

ConsumerWeb Service

ConsumerWeb Service

ProviderWeb Service

Provider

ServiceDirectoryService

Directory

Discover -UDDI

Publish

Web Service: Web Service: a software component, described via WSDL,a software component, described via WSDL,that is accessible via SOAP over HTTP.that is accessible via SOAP over HTTP.

•• ArcGIS Server Web ServicesArcGIS Server Web Services•• CatalogCatalog•• Map ServerMap Server•• GeocodeGeocode ServerServer

•• Application Web ServicesApplication Web Services•• Custom serviceCustom service

•• ArcGIS Server ClientsArcGIS Server Clients•• ArcMapArcMap•• ArcCatalogArcCatalog

•• Custom ClientsCustom Clients•• Web ApplicationsWeb Applications•• Desktop ApplicationsDesktop Applications

Page 4: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

AGS Web Services @ 9.1AGS Web Services @ 9.1•• Exposes Server Objects as web servicesExposes Server Objects as web services

–– MapServerMapServer–– GeocodeServerGeocodeServer

•• Provides a pseudo discovery serviceProvides a pseudo discovery service–– Web Service CatalogWeb Service Catalog

•• Also a web serviceAlso a web service•• Hosts server object web servicesHosts server object web services

–– Published using web service catalog template.Published using web service catalog template.

•• InteroperabilityInteroperability–– Consumed by both Java and .NETConsumed by both Java and .NET

•• Standard web application securityStandard web application security–– Basic, Digest, Forms based authentication.Basic, Digest, Forms based authentication.–– HTTPS channel encryption.HTTPS channel encryption.

Page 5: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

AGS Web Services @ 9.1(cont)AGS Web Services @ 9.1(cont)

•• Designed for stateless consumption by ArcGIS Designed for stateless consumption by ArcGIS clients; SOAP responses can be used by the clients; SOAP responses can be used by the AGSClientAGSClient ArcObjectsArcObjects library.library.–– ArcMapArcMap–– ArcCatalogArcCatalog–– Custom clientsCustom clients

•• Implemented using JSP pages.Implemented using JSP pages.–– SOAP request is forwarded to serverSOAP request is forwarded to server

HttpSoapHandler.sendSoapResponse(nullHttpSoapHandler.sendSoapResponse(null, , String String soapRequestsoapRequest, , IRequestHandlerIRequestHandler requestHandlerrequestHandler, String out);, String out);

–– Each server object type implements Each server object type implements IRequestHandlerIRequestHandler which which handles SOAP input by parsing it into native handles SOAP input by parsing it into native ArcObjectsArcObjectsrequests.requests.

Page 6: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

ArcGIS Server (AGS) Web ServicesArcGIS Server (AGS) Web ServicesDiscovery and RequestDiscovery and Request

Conservation_MapServerConservation_MapServerWeb ServiceWeb Service

Germany_MapServerGermany_MapServerWeb ServiceWeb Service

USA_MapServerUSA_MapServerWeb ServiceWeb Service

Portland_GeocodeServerPortland_GeocodeServerWeb ServiceWeb Service

Client ApplicationsClient Applications•• ArcMapArcMap•• ArcCatalogArcCatalog

4. Server Object Implements 4. Server Object Implements IRequestHandlerIRequestHandler

3. DCOM Call with embedded

3. DCOM Call with embedded

SOAP request/response

SOAP request/response

2. SOAP request/response

2. SOAP request/response

to/from MapServer Web Service

to/from MapServer Web Service

ArcGIS ServerArcGIS Server

1. SOAP request/response for1. SOAP request/response forURLs of hosted web servicesURLs of hosted web services Catalog Web ServiceCatalog Web Service

Page 7: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Creating AGS Web ServicesCreating AGS Web Services

A simple matter of:A simple matter of:

•• Create a Server Object configuration.Create a Server Object configuration.

•• Start the Server object configuration.Start the Server object configuration.

•• Create a web service catalog web Create a web service catalog web service from template in Developer Kit.service from template in Developer Kit.

Page 8: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web ServicesConsuming AGS Web Services

ArcGIS Desktop ClientsArcGIS Desktop Clients

Page 9: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web Services (cont)Consuming AGS Web Services (cont)

Custom ClientsCustom Clients

Page 10: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web Services (cont)Consuming AGS Web Services (cont)

Custom Client Implementation: Custom Client Implementation:

Get MapServer Web Service URLs from Get MapServer Web Service URLs from ServiceCatalogServiceCatalog..// get all MapServer web services and add their URLs // get all MapServer web services and add their URLs // to the MapServer // to the MapServer JComboBoxJComboBoxURL URL urlurl = new = new URL(urlTextField.getTextURL(urlTextField.getText());());ServiceCatalogBindingStubServiceCatalogBindingStub servicecatalogservicecatalog = (= (ServiceCatalogBindingStubServiceCatalogBindingStub) )

new _new _defaultLocator().getServiceCatalogPort(urldefaultLocator().getServiceCatalogPort(url););ArrayOfServiceDescriptionArrayOfServiceDescription sdArraysdArray = =

servicecatalog.getServiceDescriptionsservicecatalog.getServiceDescriptions();();ServiceDescriptionServiceDescription sdsd[] = [] = sdArray.getServiceDescriptionsdArray.getServiceDescription();();

// add // add MapServersMapServers to the to the JComboBoxJComboBoxfor (for (intint i = 0; i < i = 0; i < sd.lengthsd.length; i++) {; i++) {

if ( if ( sd[i].getType().equals("MapServersd[i].getType().equals("MapServer") ) {") ) {mapserverComboBox.addItem(sd[i].getUrlmapserverComboBox.addItem(sd[i].getUrl());());

}}}}

Page 11: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web Services (cont)Consuming AGS Web Services (cont)

Custom Client Implementation:Custom Client Implementation:

Get data frames from MapServer Web Service.Get data frames from MapServer Web Service.

// Connect to MapServer web service// Connect to MapServer web serviceMapServerBindingStubMapServerBindingStub mapservermapserver = =

((MapServerBindingStubMapServerBindingStub) new ) new MapLocator().getMapServerPort(urlMapLocator().getMapServerPort(url););dfComboBox.removeAllItemsdfComboBox.removeAllItems();();intint numMapsnumMaps = = mapserver.getMapCountmapserver.getMapCount();();for (for (intint i = 0; i < i = 0; i < numMapsnumMaps; i++) {; i++) {

dfComboBox.addItem(mapserver.getMapName(idfComboBox.addItem(mapserver.getMapName(i));));}}

Page 12: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web Services (cont)Consuming AGS Web Services (cont)

Custom Client Implementation: Custom Client Implementation:

Get map document bookmarks from MapServer Web Service.Get map document bookmarks from MapServer Web Service.MapServerBindingStubMapServerBindingStub mapservermapserver = (= (MapServerBindingStubMapServerBindingStub))

new new MapLocator().getMapServerPort(urlMapLocator().getMapServerPort(url););String name = String name =

mapserver.getMapName(dfComboBox.getSelectedIndexmapserver.getMapName(dfComboBox.getSelectedIndex());());MapServerInfoMapServerInfo mapInfomapInfo = = mapserver.getServerInfo(namemapserver.getServerInfo(name););ArrayOfMapServerBookmarkArrayOfMapServerBookmark bookmarkArraybookmarkArray = =

mapInfo.getBookmarksmapInfo.getBookmarks();();MapServerBookmarkMapServerBookmark[] bookmarks = [] bookmarks =

bookmarkArray.getMapServerBookmarkbookmarkArray.getMapServerBookmark();();if ( bookmarks != null ) {if ( bookmarks != null ) {

for (for (intint i = 0; i < i = 0; i < bookmarks.lengthbookmarks.length; i++) {; i++) {bookmarkComboBox.addItem(bookmarks[i].getNamebookmarkComboBox.addItem(bookmarks[i].getName());());

}}}}

Page 13: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web Services (cont)Consuming AGS Web Services (cont)

Custom Client Implementation: Custom Client Implementation: Draw map at extent of map document bookmark.Draw map at extent of map document bookmark.

MapServerInfoMapServerInfo mapInfomapInfo = = mapserver.getServerInfo(namemapserver.getServerInfo(name););MapDescriptionMapDescription mapDescmapDesc = = mapDescriptionmapDescription;;ArrayOfMapServerBookmarkArrayOfMapServerBookmark bookmarkArraybookmarkArray = = mapInfo.getBookmarksmapInfo.getBookmarks();();MapServerBookmarkMapServerBookmark[] bookmarks = [] bookmarks =

bookmarkArray.getMapServerBookmarkbookmarkArray.getMapServerBookmark();();if ( bookmarks != null ) {if ( bookmarks != null ) {

for (for (intint i = 0; i < i = 0; i < bookmarks.lengthbookmarks.length; i++) {; i++) {if (if (bookmarks[i].getName().equals(bookmarkComboBoxbookmarks[i].getName().equals(bookmarkComboBox..

getSelectedItem().toStringgetSelectedItem().toString())) {())) {mapDesc.setMapArea(bookmarks[imapDesc.setMapArea(bookmarks[i]);]);}}

}}}}mapDescriptionmapDescription = = mapDescmapDesc;;drawMap(mapDescriptiondrawMap(mapDescription););

Page 14: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming AGS Web Services (cont)Consuming AGS Web Services (cont)

Custom Client Implementation: Custom Client Implementation:

Create an image by calling Create an image by calling ExportMapImageExportMapImage().().ImageTypeImageType it = new it = new ImageTypeImageType();();it.setImageFormat(EsriImageFormat.esriImageJPGit.setImageFormat(EsriImageFormat.esriImageJPG););it.setImageReturnType(EsriImageReturnType.esriImageReturnMimeDatit.setImageReturnType(EsriImageReturnType.esriImageReturnMimeDataa););ImageDisplayImageDisplay idispidisp = new = new ImageDisplayImageDisplay();();idisp.setImageHeight(400);idisp.setImageHeight(400);idisp.setImageWidth(552);idisp.setImageWidth(552);idisp.setImageDPI(150);idisp.setImageDPI(150);ImageDescriptionImageDescription iDesciDesc = new = new ImageDescriptionImageDescription();();iDesc.setImageDisplay(idispiDesc.setImageDisplay(idisp););iDesc.setImageType(itiDesc.setImageType(it););MapImageMapImage mi = mi = mapserver.exportMapImage(mapDescmapserver.exportMapImage(mapDesc, , iDesciDesc););byte[] data = byte[] data = mi.getImageDatami.getImageData();();mapimagemapimage = = java.awt.Toolkit.getDefaultToolkit().createImage(datajava.awt.Toolkit.getDefaultToolkit().createImage(data););

Page 15: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Application Web ServicesApplication Web Services

•• Software components that accept and return simple nonSoftware components that accept and return simple non--ArcObjectsArcObjectsJava types.Java types.

•• Use the Use the ArcObjectsArcObjects Java Server API to solve your business logic, Java Server API to solve your business logic, but accept and return only simple Java types as input and outputbut accept and return only simple Java types as input and output..

•• Example: Example: –– Locate ideal locations to build a school by building farthest frLocate ideal locations to build a school by building farthest from om

toxic waste sites toxic waste sites •• [in] double x, [in] double y[in] double x, [in] double y•• [out] double distance[out] double distance

Page 16: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Creating Application Web ServicesCreating Application Web Services

•• Development planDevelopment plan

Step 2: Create a SOAP service wrapper

Step 1: Create core functionality

Step 3: Create WSDL service description

Step 4: Deploy service

Step 5: Register service via UDDI (optional)

Page 17: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Consuming Application Web ServicesConsuming Application Web Services

•• Development planDevelopment plan

Step 2: Retrieve service description file (WSDL)

Step 1: Discover services (UDDI)

Step 3: Generate stubs and add to classpath

Step 4: Work with proxy stubs

Page 18: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

New at 9.2 New at 9.2 -- AGS Web ServicesAGS Web Services•• Exposes Server Objects and Extensions as web Exposes Server Objects and Extensions as web

servicesservices–– MapServer (KML, WMS, NA, Mobile), MapServer (KML, WMS, NA, Mobile),

GlobeServer, GeocodeServer, GlobeServer, GeocodeServer, GeoDataServerGeoDataServer

•• Capabilities can be restricted or enabledCapabilities can be restricted or enabled–– MapServer MapServer –– map, query, datamap, query, data–– GeocodeServer GeocodeServer –– geocodegeocode, , reversegeocodereversegeocode–– GeoDataServerGeoDataServer –– query, extraction, replicationquery, extraction, replication–– GlobeServer GlobeServer –– globe, animation, queryglobe, animation, query

•• Provides a Provides a pseduopseduo discovery servicediscovery service–– Web Service CatalogWeb Service Catalog

•• Also a web serviceAlso a web service•• Hosts server object SOAP web services.Hosts server object SOAP web services.•• Hosts server object binary endpoints.Hosts server object binary endpoints.

–– Published using standalone publisher (under development)Published using standalone publisher (under development)

Page 19: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

New at 9.2 New at 9.2 -- AGS Web Services (cont)AGS Web Services (cont)

•• Designed for stateless consumption by ArcGIS clients; SOAP Designed for stateless consumption by ArcGIS clients; SOAP responses can be used by the responses can be used by the AGSClientAGSClient ArcObjectsArcObjects library.library.

–– ArcMapArcMap–– ArcGlobeArcGlobe–– ArcExplorerArcExplorer 22–– ADF ClientsADF Clients–– ArcCatalogArcCatalog–– Custom clientsCustom clients

•• Implemented using a Java ServletImplemented using a Java Servlet–– SOAP request is forwarded to serverSOAP request is forwarded to server

HttpSoapHandler.sendSoapResponse(nullHttpSoapHandler.sendSoapResponse(null, , String String soapRequestsoapRequest, , IRequestHandlerIRequestHandler requestHandlerrequestHandler, String out);, String out);

–– Each server object type implements Each server object type implements IRequestHandlerIRequestHandler which which handles SOAP input (handles SOAP input (IRequestHandler.HandleStringRequestIRequestHandler.HandleStringRequest()) by ()) by parsing it into native parsing it into native ArcObjectsArcObjects requests.requests.

–– Binary requests are also forwarded to the server and handled by Binary requests are also forwarded to the server and handled by IRequestHandler.HandleBinaryRequestIRequestHandler.HandleBinaryRequest().().

Page 20: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

New at 9.2 New at 9.2 -- AGS Web Services (cont)AGS Web Services (cont)Publishing ArcGIS Server Web ServicesPublishing ArcGIS Server Web Services

Page 21: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

With ArcGIS Server Manager You Can:With ArcGIS Server Manager You Can:

•• Create and deploy GIS ServicesCreate and deploy GIS Services•• Create and deploy Web ApplicationsCreate and deploy Web Applications•• Create and deploy Mobile ApplicationsCreate and deploy Mobile Applications•• Manage and Monitor GIS ServicesManage and Monitor GIS Services•• Build custom services and applicationsBuild custom services and applications

Page 22: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

ArcGIS Server Manager: Complete ArcGIS Server Manager: Complete SolutionSolution

•• Single consolidated view Single consolidated view of ArcGIS Serverof ArcGIS Server

•• Zero programming webZero programming web--application builderapplication builder

•• Simplified publishing Simplified publishing model just onemodel just one--click click awayaway

•• Centralized Centralized management and management and monitoringmonitoring

Page 23: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Simplified Publishing Simplified Publishing ……..Just One..Just One--Click AwayClick Away

Page 24: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Integrated Server AdministrationIntegrated Server Administration……Point and Click EasePoint and Click Ease

Page 25: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

FeaturesFeatures

•• Easy to use Web Application Builder Easy to use Web Application Builder –– zero zero programmingprogramming

•• Provides extensive support for Mapping, KML, OGC Provides extensive support for Mapping, KML, OGC WMS, Network Analysis, CachingWMS, Network Analysis, Caching……

•• Provides flexible deployment to J2EE environments Provides flexible deployment to J2EE environments •• Easy to customize applicationsEasy to customize applications•• Integrate GIS Services into Web ApplicationsIntegrate GIS Services into Web Applications•• Access full power of ArcGIS Server within your Access full power of ArcGIS Server within your

applicationsapplications•• Easy to use outEasy to use out--ofof--the box applications and toolsthe box applications and tools

Page 26: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

API References and DocumentationAPI References and Documentation

•• JavaDocJavaDoc generated from WSDLgenerated from WSDL--generated generated stub classes.stub classes.

•• Match descriptions to similarly named classes Match descriptions to similarly named classes in Server API.in Server API.

•• Developer scenariosDeveloper scenarios

•• SamplesSamples

Page 27: Building Web Services with ArcGIS Server and Java · 2006-05-12 · Conservation_MapServer Web Service Germany_MapServer Web Service USA_MapServer Web Service Portland_GeocodeServer

Session Evaluations ReminderSession Evaluations Reminder

Session Attendees:Session Attendees:Please turn in your session evaluations.Please turn in your session evaluations.

. . . Thank you. . . Thank you