Installing and running the Custom Rest Service – Mapservice legends sample

I recently saw that there has been lots of discussion on the custom rest service legend sample posted on the code gallery in terms of getting the sample up and running successfully. If you have no clue on what I am talking about, here is the link.

This post should help you get the sample running in no time (almost):

I am using Eclipse (screen-shots show version 3.4/Ganymede, 3.3/Europa should work as well) as my IDE and ArcGIS Server 9.3.1 Java ADF libraries.

1. Download the sample on to the disk:

sample

download

unzip

The sample comes with “json.jar” library, as shown in the screen-shot here:

library-included

2. Create a new project in eclipse

new-project-1

new-project-2

new-project-3

new-project-4

3. Import the source files and web-inf folder from the sample to the project

after-import

As you see, IDE complains that there are missing imports. We are going to fix them in step 4

4. Copy (drag and drop) the following libraries into the project from the Web ADF library collection
Note: You do not need ArcGIS Server to run this sample, just the Java Web ADF libraries is good. You can copy the required libraries from other machine if needed

select-libraries

After completing steps 3 and 4 you project should look like:

after-adding-libraries

5. Run the web app (Assumption is that you have eclipse configured with web server like tomcat or jetty. I am using tomcat 6)

run-with-tomcat    

run1
 
run2

6. Optionally, you can export this into a war file for deployment

export-to-war

Advertisements

8 Responses to “Installing and running the Custom Rest Service – Mapservice legends sample”

  1. Daily News About Java : A few links about Java - Tuesday, 19 May 2009 13:06 Says:

    […] Installing and running the Custom Rest Service – Mapservice legends sample […]

  2. Jason Zou Says:

    Is there any .NET version? We are using ArcGIS Server for .NET. Thanks.

  3. Moogletrop Says:

    …and the example javascript showing how to consume the service is…where? :-/

    • sathyaprasad Says:

      @Moogletrop – Here is the sample available on resource center which shows how to consume the legend service from ArcGIS JavaScript API app – Link – Once you download this set of samples, and run the index.html page you will find link to the sample you are looking for. (you can also find it directly under functionality/restLegends.html and functionality/js/RestLegends.js)

  4. Blair Says:

    sathyaprasad

    Is there any way you can compile a war file for me? I have followed your instructions and still getting a fair number of build errors. Thanks.

    Cheers,
    Blair

  5. Jeff Says:

    Thanks, nicely done.

    A couple of changes I had to make to get the service to run:
    1) There was no default (index.html) page included in the download, so I copied the online default page here (http://orthogonal.esri.com/restlegends/) and created my own.
    2) In the index.html you have to add an action attr to the form tag that points to the servlet (action=”legends”).
    3) In the jsps/legends-html.jsp page you also have to add an action attr to the form tag that points to the servlet (action=”../../legend/legends”).

  6. mohammed megahed Says:

    i did so but receive those errors

    1- Unable to generate legends: Invalid response from Server, HTTP status code {203} received from server.
    And it happens when using default map service published on ESRI server

    2- Unable to generate legends: Invalid response from Server, Response content type is text/html.
    And it happens when using may own map service published on my server.

    any comments??

  7. hudy Says:

    I have the same problem Invalid response from Server, Response content type is text/html

    Please help


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: