Abstract
This document describes the CWC2 Service Instance as implemented for Chameleon 2.0, as well as how to use it with your Chameleon application.
Last Updated: 2005/01/11
Table of Contents
This document is intended to help install the CWC2 Service Instance for Chameleon 2.0, configure it, and help you use it. If, after thoroughly reading this document and trying out its instructions, you have further Service Instance questions, please refer to the For More Information section.
The CWC2 Service Instance is an Internet-accessible service that can interpret a Chameleon Application Template and load a Context to create a fully interactive Web mapping application. If you have access to a Service Instance running on a remote server, then you can invoke and control a Chameleon Application without having to have Chameleon installed on your local machine - all you need to supply is a Template and a Context. (In fact, those two files can be on different machines as well, so long as you can properly reference them.)
There have been some changes in the way configuration files are set up with recent versions of Chameleon. If you have a version of Chameleon installed that is earlier than Chameleon 1.99 beta 2, then the following instructions might be relevant to you. If you are installing your first version of Chameleon and/or are using the MS4W utility, then you don't need to worry about these changes.
Previous to Chameleon 1.99 beta 1, the configuration file was called cwc2.xml (for historical reasons, since Chameleon was originally called CWC2). It contained, amongst all the other configuration values, several parameters that were only really needed by the service. In more recent versions, the configuration file has been split into two separate files, chameleon.xml and cwc2.xml. The splitting process resulted in the removal of some completely unnecessary elements, the adding of new parameters, and changing the names of some elements.
It is not sufficient to rename your old cwc2.xml file to chameleon.xml. You must start from the xml-dist versions of these files. You may find that you can copy some settings from your previous cwc2.xml file into the appropriate place in either chameleon.xml or the new cwc2.xml, but you cannot just do a blind copy.
If, after you install the Service Instance, you are having problems running it, you may wish to check that you have your configuration files properly named.
There really is little or no extra work to do to install the CWC2 Service Instance, since it is installed with the main Chameleon 2.0 package by default. Simply follow the installation instructions found in the "Chameleon 2.0 Installation Guide".
However, to access the installed Service Instance, you need to adjust your system configuration and edit the Service Instance configuration file to reflect your system's configuration.
Note: the Service Instance requires a properly installed and configured Chameleon package. Please follow the Chameleon installation instructions carefully and ensure that Chameleon is fully functional before attempting to configure the Service Instance.
You need to configure your Web Server to grant access to at least one directory in the Service Instance. Granting access to two other directories is optional. The following table is a suggested configuration:
Make a copy of the cwc2.xml-dist file found in the {install-path}/chameleon/config folder and name it cwc2.xml. You need to edit at least some of the settings found in this file. It is recommended that you use the Chameleon Administration tool provided to do these edits. (See the "Chameleon Adminstrator's Guide" for details.)
Each configuration item is described within the XML document but, as a minimum, you should review the following items:
Table 2. Service Instance Configuration
Config Item | Set to... |
service_instance_path | URL to Service Instance htdocs folder (from above) |
server_data_path | {install-path}/chameleon/cwc2/data |
default_context | {install-path}/chameleon/cwc2/contexts/world_context.xml |
default_template | {install-path}/chameleon/cwc2/templates/sample_cwc2.html |
context_root | {install-path}/chameleon/cwc2/contexts/ |
template_root | {install-path}/chameleon/cwc2/templates |
fontlist_file | {install-path}/chameleon/cwc2/etc/fonts.txt |
symbol_file | {install-path}/chameleon/cwc2/etc/symbols.sym |
Assuming that the above configuration is implemented correctly, the Service Instance should now be fully functional. You can test the Service Instance by connecting to the following URL:
http://{myserver}/cwc2/cwc2.php
You should receive the following message:
request URI was http://{myserver}/cwc2/cwc2.php query string was Missing mandatory SERVICE parameter
This error message means that the Web Server is correctly providing access to the Service Instance (but that you haven't supplied all the needed information to launch an application).
Normally, the Service Instance is configured to provide a default application and context. If you followed the instructions above, you can access the default application and context by connecting to the following URL:
http://{myserver}/cwc2/cwc2.php?service=VCG&version=0.1.0&request=GetApplication
Please read the Users Guide section below to find out more about communicating with and using the features of the Service Instance.
The CWC2 Service Instance is part of the Chameleon 2.0 package available from http://www.maptools.org. Please visit the Chameleon Web site at http://www.maptools.org/chameleon to access information about using Bugzilla (to report bugs) and the Chameleon users mailing list (to ask questions).
Please refer to the Set Up and Installation section for instructions on getting your Service Instance installed and tested. This section assumes that you have a fully functional and correctly configured Service Instance.
The Chameleon Service Instance is an application built on top of the Chameleon engine that allows application developers to create Web mapping applications by creating an Application Template and a Web Map Context document. It will only work with WMS layers.
The Chameleon Service Instance is a Web service that can be invoked by clients using only a Web browser - they do not necessarily have to have any of the Chameleon engine running on their local machine (so long as it is running on the machine providing the service). The Service Instance is invoked through a specially-constructed URL which contains pointers (parameters) to an Application Template and a context. (There are examples of these URLs throughout this document.)
A service exception describes the result of an error that happens in the CWC2 Service Instance. The CWC2 Service Instance is designed to capture internal errors and report them in a standard, machine-parsable way using structured XML documents. Whenever an error is trapped internally, CWC2 generates and returns a service exception instead of the requested application. The intention is to provide sufficient information to the user to allow for troubleshooting of the problem that caused the service exception to be triggered. Service exceptions can happen at any time and for a wide variety of reasons.
For an example of a service exception, see the Testing the Service Instance section.
This section describes parameters that are common to, and mandatory in, every invocation of the Service Instance. Valid values for these parameters depend on how the service instance is being invoked and are described in the Supported REQUESTs section below.
REQUEST
The REQUEST parameter indicates which operation is being invoked and its value is one of the names of the operations supported by the Service Instance.
VERSION
The VERSION parameter indicates the protocol version number to be used.
SERVICE
The SERVICE parameter indicates the service that is being requested. Some Web services can be configured to provide multiple services through the same base URL. In the case of CWC2, this is not yet possible. However, this parameter is provided for compatibility with existing services and for possible future requirements.
Example URL
The following is the most basic valid URL to invoke a Service Instance, using all three of the above required parameters:
http://localhost/chameleon/cwc2/cwc2.php?service=VCG&version=0.1.0&request=GetApplication
The CWC2 Service Instance supports two REQUESTs, described below.
Note: the GetCapabilities REQUEST is not implemented for Chameleon 2.0.
The purpose of the GetCapabilities operation is to describe the operating parameters of a particular Service Instance so that clients can use the service in an effective manner.
Request Parameters
The GetCapabilities operation has three mandatory parameters: SERVICE, REQUEST, and VERSION, described in the following table:
Table 3. GetCapabilities Request Parameters
Parameter | Required/Optional | Description |
SERVICE=VCG | Required | Service name, must be VCG |
REQUEST=GetCapabilities | Required | Request name, must be GetCapabilities |
VERSION={version} | Required | Supported protocol version number |
Please see the Common Invocation Parameters section above for details on the above parameters.
Response
The response to the GetCapabilities request is an XML document. This feature is not yet implemented, but will be in a future version.
Example URL
Once the GetCapabilities request is operational, the following URL would retrieve the capabilities information:
http://localhost/chameleon/cwc2/cwc2.php?service=VCG&version=0.1.0&request=GetCapabilities
The purpose of the GetApplication operation is to generate a client application based on the parameters provided when invoking the service.
Request Parameters
The GetApplication operation has three mandatory parameters and six optional parameters, which are described in the following table:
Table 4. GetApplication Request Parameters
Parameter | Required/Optional | Description |
SERVICE=VCG | Required | Service name, must be VCG |
REQUEST=GetApplication | Required | Request name, must be GetApplication |
VERSION={version} | Required | Supported protocol version number |
LANGUAGES={list} | Optional | A list of languages |
TEMPLATES={list} | Optional | A list of application template paths or URLs |
CONTEXTS={list} | Optional | A list of context paths or URLs |
LANGUAGE={lang} | Optional | The language to display |
BBOX={list} | Optional | A comma-separated list of coordinates that describe the initial spatial extents to be displayed to the user |
SRS={srs} | Optional | A spatial reference system (must be a valid EPSG code) to be used for the initial map view. |
Please see the Common Invocation Parameters section above for details on the required parameters.
LANGUAGES
A list of language specifiers separated by commas. Languages are specified in the form of a two-character (lowercase) language code followed by a dash and then a two-character (uppercase) country code (e.g., en-CA). Service Instances list supported languages in the capabilities document. Unsupported languages may be requested, but the Service Instance uses the default language in these case. In addition, if the LANGUAGE parameter is not set, the default language (set in the Service Instance configuration file) is used.
This parameter is optional unless TEMPLATES parameter is set, in which case it becomes mandatory.
TEMPLATES
A list of application template paths or URLs separated by commas. A template is identified either by a relative (to the template root directory specified in the Service Instance configuration) path on the server or by a URL to a Web-accessible template. The templates are listed in the same order as their related language specifiers in the LANGUAGES parameter, with one template required for each supported language (even if the same template supports every language). URLs must be in the standard http://{server}/path/template.html format and must be URL-encoded.
Example URL
The following URL could be used to support a bilingual application using remote context files:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA,fr-CA &TEMPLATES=http://localhost/chameleon/cwc2/templates/sample_cwc2_en.html, http://localhost/chameleon/cwc2/templates/sample_cwc2_fr.html
This parameter is optional unless LANGUAGES is set, in which case it becomes mandatory. The Service Instance defines a default template in its configuration file.
CONTEXTS
A list of Web map context paths or URLs separated by commas. A context is identified either by a relative (to a directory specified in the Service Instance configuration) path on the server or a URL to a Web-accessible context. The contexts are loaded in the order in which they appear in this list, and the projection and spatial extents are taken from the last context loaded (see Common Problems below). The order of these contexts determines the order in which the layers of each context are drawn. Layers from the first context in the list are drawn first, layers from later contexts are drawn 'on top' of earlier ones. URLs must be in the standard http://{server}/path/template.html format and must be URL-encoded.
Example URL
The following URL could be used to get multiple remote contexts while using the default template and language:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA,fr-CA &TEMPLATES=http://localhost/chameleon/cwc2/templates/sample_cwc2_en.html, http://localhost/chameleon/cwc2/templates/sample_cwc2_fr.html
This parameter is optional. The Service Instance defines a default value context in its configuration file.
LANGUAGE
The language to use to display the application. This causes one of the templates to be selected from those specified as available in the TEMPLATES parameter. Typically, this parameter only needs to be used when a non-default language is being requested.
This parameter is optional. The Service Instance defines a default value in its configuration file.
BBOX
The BBOX provides a mechanism to define a different set of initial spatial extents than the default. By default, the Service Instance uses the extents defined in the last context opened. This may not be appropriate in all cases, especially when providing multiple contexts. The format for this parameter is a comma-separated list of values in the following order:
BBOX={MINX},{MINY},{MAXX},{MAXY}
The values are specified in georeferenced coordinates and depend on the spatial reference system of the initial view.
SRS
The SRS provides a mechanism to define a different spatial reference system than the default. By default, the Service Instance uses the SRS defined in the last context opened. This may not be appropriate in all cases, especially when providing multiple contexts. This parameter must use EPSG codes in the following format:
SRS=EPSG:XXXXX
Example URL
The following URL could be used to get a fully remote, bilingual application using multiple contexts, and defining an SRS and BBOX:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA,fr-CA &TEMPLATES=http://localhost/chameleon/cwc2/templates/sample_cwc2_en.html, http://localhost/chameleon/cwc2/templates/sample_cwc2_fr.html &SRS=epsg:4326 &BBOX=-180,-90,180,90 &CONTEXTS=http://localhost/chameleon/cwc2/contexts/world_context.xml, http://localhost/chameleon/cwc2/contexts/gmap_context.xml
When specifying a template or a context, you must do so in relation to the Service Instance server. This means that if the context or template that you wish to access is on the Service Instance server, then it must reside in the Service Instances defined template directory or context directory (or a subdirectory of these directories). If the context or template is not on the Service Instance server, then you must refer to it using a valid URL. It is very important to note that the URL will be opened from the Service Instance server, so a URL that refers to localhost:
http://localhost/mytemplates/app1.html
most likely will NOT work. This is because the Service Instance, when it tries to open this URL, will be pointing to itself - most likely not the situation you intended.
When specifying multiple CONTEXTS, the Service Instance loads them sequentially and uses the BBOX and SRS defined in the last context it loads. It is quite possible that the BBOX and SRS in the last context you want to load are not valid for all the contexts that you are trying to load. For example, if you try to load the world_context.xml and the gmap_context.xml contexts (in that order) that come with the Service Instance, the world data is displayed in LCC projection and does not appear to 'line up' with the gmap data. The problem is that the LCC projection is invalid for extents beyond Canada. To fix this problem, you can manually provide a BBOX and SRS as part of the request. In this case, changing the SRS to EPSG:4326 displays everything correctly.
The CWC2 Service Instance only works with data that is accessible via WMS.
The CWC2 Service Instance does not allow applications to define and access custom widgets, unless they are installed in the Chameleon instance that the CWC2 Service Instance is configured to use.
Other useful sample Service Instance URLs include:
The URL to get a single local template for a given language is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA &TEMPLATES=sample_cwc2.html
The URL to get a single remote template for a given language is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA &TEMPLATES=http://localhost/chameleon/cwc2/templates/sample_cwc2.html
The URL to get a bilingual application using local templates is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA,fr-CA &TEMPLATES=sample_cwc2_en.html,sample_cwc2_fr.html
The URL to get a single local context using default template and language is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &CONTEXTS=gmap_context.xml
The URL to get a single remote context using default template and language is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &CONTEXTS=http://localhost/chameleon/cwc2/contexts/gmap_context.xml
The URL to get multiple local contexts using default template and language is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &CONTEXTS=world_context.xml,gmap_context.xml
The URL to get a fully remote, bilingual application using multiple contexts is:
http://localhost/chameleon/cwc2/cwc2.php? service=VCG &version=0.1.0 &request=GetApplication &LANGUAGES=en-CA,fr-CA &TEMPLATES=http://localhost/chameleon/cwc2/templates/sample_cwc2_en.html, http://localhost/chameleon/cwc2/templates/sample_cwc2_fr.html &CONTEXTS=http://localhost/chameleon/cwc2/contexts/world_context.xml, http://localhost/chameleon/cwc2/contexts/gmap_context.xml
If you were unable to answer all the questions you had about the subject of this document, other possible methods of obtaining information include:
There are several other Chameleon 2.0 documents that can be found on the Chameleon Documentation page (including some that are referenced in this document). Please look through these documents for answers to your questions.
You can pose a question on the Chameleon Mailing List and other members of the Community might be able to help you. In fact, searching the mailing list archive can often lead to the necessary information without having to pose a new question. To sign up to be a part of the mailing list, please visit here.
If you find what you believe to be a bug in Chameleon 2.0, please submit it to the public Bugzilla repository. This is by far the quickest way to get a bug in the product addressed. The mailing list should not be used for reporting bugs.
The numbering is in parallel with the revision control system. Missing numbers indicate minor maintenance revision updates.
Revision History | ||
---|---|---|
Revision 1.00 | 2004/08/20 | Paul Spencer |
original text-only version | ||
Revision 1.01 | 2004/08/21 | Darren Redfern |
initial compilation in DocBook | ||
Revision 1.1 | 2004/11/12 | Darren Redfern |
finished initial draft | ||
Revision 1.2 | 2004/11/13 | Darren Redfern |
changes based on review comments | ||
Revision 1.3 | 2004/12/08 | Chris Thorne |
changed coding format, etc. | ||
Revision 1.4 | 2004/12/08 | Darren Redfern |
editorial changes | ||
Revision 1.5 | 2005/01/11 | Jeff McKenna |
minor changes, fixed docbook formatting errors |
Copyright (c) 2005, Paul Spencer, DM Solutions Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Input is appreciated. Send any comments or suggestions to the Chameleon Mailing List, which you can join at http://lists.maptools.org/mailman/listinfo/chameleon.