The Java Backend Service
Introduction
It's very easy to deploy an Axis Web Service simply by writing public methods in a class and configuring them to be published with a Web Services Deployment Descriptor (wsdd) file. In fact, any and all of the Web Services we use are deployed in this way. The Ferret and Database services which are deployed in this way are sophisticated classes which use extensions of the Tool class to interface with legacy application and external databases. A service may not need to be so complicated. In fact, if a service has a simple job that can be easily coded in Java, the creating a new service method in the Java Backend Service is the way to go.
The KML Service
Creating a KML file is the perfect example of such a need. All the service needs to accomplish is to take information from the LAS Map Scale file and the URL of the image product and merge this into a KML template.
The Compound Operation
<operation name="Plot to Google Earth" ID="Google_Earth" template="kml_output">
<operation name="Plot_2D" ID="Plot_for_GE" script="Plot_2D">
<response ID="PlotResp">
<result type="image" ID="plot_image" streamable="true" mime_type="image/png" />
<result type="ps" ID="plot_postscript" streamable="true" mime_type="application/postscript" />
<result type="image" ID="ref_map" />
<result type="map_scale" ID="map_scale" />
<result type="debug" ID="debug" />
<result type="cancel" ID="cancel" />
</response>
<service>ferret</service>
</operation>
<operation chained="true" name="Make KML File" ID="Plot_insitu_XY_locations" script="kml">
<args>
<arg chained="true" type="image" operation="Plot_for_GE" result="plot_image"/>
<arg chained="true" type="map_scale" operation="Plot_for_GE" result="map_scale"/>
</args>
<response ID="PlotResp" type="HTML" index="1">
<result type="kml" ID="kml" streamable="true" mime_type="application/vnd.google-earth.kml+xml"/>
</response>
<service>kml</service>
</operation>
</operation>
Suppose you have an operation defined as above. The first operation creates an image just as we've seen many times before as part of LAS. The second operation chained to is supposed to create a KML file using the image file and the map scale file from the previous operation as input.
Note that the service name "kml" appears in the second definition. In our productserver.xml file we create an entry for this service:
<service name="kml" url="http://porter.pmel.noaa.gov:8920/testbed/services/LASJavaBackend" method="mapScaleToKML"/>
The combination of these two configuration steps means that when the request is processed, the mapScaleToKML method will be run to create the KML file in the second step of the chained operation.
See JavaSource/gov/noaa/pmel/tmap/las/service/java/JavaBackendService.java if you want to look at the source for this simple service method.
As with the images described in the Streamable Output section the KML file can be streamed directly by creating a product request URL with the stream=true&stream_ID=kml request parameters.