Using Dynamic Languages to Implement Services
Table of Contents
Define the JAX-WS style metadata.
Implement the services business logic.
Properties of the variable are expected to specify the same metadata that the JAX-WS WebServiceProvider annotation specifies, including:
wsdlLocation specifies a URL for the WSDL defining the service.
serviceName specifies the name of the service.
portName specifies the service's port/interface name.
targetNamespace specifies the target namespace of the service.
ServiceMode indicates whether the specified service handles SOAP payload documents or full SOAP message documents. This property mimics the JAX-WS ServiceMode annotation. The default value is PAYLOAD.
BindingMode indicates the service binding ID URL. The default is the SOAP 1.1/HTTP binding.
EndpointAddress indicates the URL consumer applications use to communicate with this service. The property is optional but has no default.
You implement the service's logic using the required invoke property of the WebServiceProvider variable. This variable is a function that accepts one input argument, a javax.xml.transform.dom.DOMSource node, and returns a document of the same type. The invoke function can manipulate either the input or output documents using the regular Java DOMSource class interface just as a Java application would.
The only difference between the two approaches is the type of document the implementation manipulates. When working with E4X, the implementation receives requests as an E4X XML document and returns a document of the same type. These documents are manipulated using built-in E4X XML features.
Example 3 shows an invoke property for a simple E4X service implementation.
Note: Script based services can work with SOAP messages. So, while they are multi-transport, they can only use the SOAP binding.
You deploy them into the container using the following command:
ServerApp has three optional arguments:
Specifies the address at which ServerApp publishes the service endpoint implementation found in the script file following the URL.
Specifies the base address used by ServerApp when publishing the service endpoints defined by the script files. The full address for the service endpoints is formed by appending the service's port name to the base address.
Specifies that ServerApp is to run in verbose mode.
Table 1.: Optional Arguments
The optional arguments take precedence over any addressing information provided in EndpointAddress properties that appear in the JAX-WS metadata.
To deploy a number of services using a common base URL you could use the command shown in Example 5. If the service defined by hello_world.jsx had port name of helloWorld, ServerApp would publish it at http://celtix.objectweb.org/helloWorld. If the service defined by goodbye_moon.js had a port name of blue, ServerApp would publish at http://celtix.objectweb.org/blue.
You can also combine the arguments as shown in Example 6., your service would be deployed at http://celtix.objectweb.org/goodness. ServerApp would publish three service endpoints:
The service defined by hello_world.jsx at http://celtix.objectweb.org/helloWorld.
The service defined by goodbye_moon.js at http://celtix.objectweb.org/blue.
The service defined by chocolate.jsx at http://celtix.objectweb.org/goodness.