| ILOG JRules User Guide > Integrating Application Data > Reference > Mapping Between Web Service Data and Dynamic Classes > Web Service Mapping |
Web Service Mapping |
PREVIOUS NEXT |
Web service mapping follows the JAX-RPC specifications (see http://java.sun.com/xml/jaxrpc/index.html). JAX-RPC stands for Java API for XML-based Remote Procedure Call. It is an API for building Web services and clients that use RPCs and XML. JAX-RPC focuses on point-to-point SOAP messaging, the basic mechanism that most Web service clients use. Although JAX-RPC is based on the RPC model, it offers features that go beyond basic RPC. For example, it is possible to send complete documents and document fragments. In addition, JAX-RPC supports SOAP message handlers, which make it possible to send a wide variety of messages. JAX-RPC can be extended to perform one-way messaging, in addition to the request-response style of messaging normally performed with RPC. JAX-RPC also offers extensible type mapping, which gives still more flexibility in what can be sent.
In a standard Web service framework such as Axis, the WSDL/Java mapping requires a class generation and compilation stage. However, ILOG JRules uses a XOM dynamic class mechanism, so the WSDL binding does not need to generate Java classes. The process of reading a WSDL document, mapping it on Java, and using it at runtime is completely dynamic.
| Note |
| The use of WSDL files in the XOM is now deprecated. We recommend you use the JAX-WS API instead. |
The following points outline the ILOG JRules Web service mapping with respect to the JAX-RPC specification:
| Note |
| Parts of the WSDL can be mapped by different Java packages. |
portType is represented by a dynamic class and each operation defined for this portType becomes a method in the class.
IlrWSObject class (similar to IlrXmlObject).
ILOG JRules mapping diverges from the JAX-RPC specification in that the services themselves are not represented in the XOM.
| Note |
| The implementation of the mapping and the runtime connection are based on the Axis 1.1 open source framework. |
The following table lists the different root components that may be encountered in a WSDL document, and details their mapping on a XOM.
WDSL Components |
XOM Components |
|---|---|
Service |
None * |
Binding |
None * |
Port type |
A dynamic Web service class inherits from IlrWsObject |
Port type operation |
Dynamic methods of the dynamic Web service class. Message parameters are mapped on Java method parameters |
Simple type (XSD, SOAP) |
See Simple Types |
Complex type (XSD, SOAP) |
A dynamic class inherits from IlrXmlObject |
* These WSDL components are not neglected in the XOM. They are just not transformed into separate and distinct XOM components.
Mapping a WSDL document as a XOM permits Web service operations inside a business rule. The mapping transformation is achieved by the interface ilog.rules.webservices.client.IlrWSDataDriver and its implementation class ilog.rules.webservices.client.binding.IlrWSDefaultDataDriver.
The following code shows how to create a WSDL driver and transform a WSDL document into a dynamic model--a XOM.
// Create the driver and connect it to a XOM ruleset. IlrRuleset aRuleset =...; IlrWSDataDriver driver = new IlrWSDefaultDataDriver ( aRuleset.getReflect() ); // Load the WSDL file. String wsdlFileName = "myFile.wsdl"; String serviceName = "myService"; driver.loadModel ( wsdlFileName, serviceName ); // In J2SE System.setProperty(ServiceFactory.SERVICEFACTORY_PROPERTY,"org.apache.axis.client.ServiceFactory"); // Create the driver and connect it to the XOM of the ruleset. IlrRuleset aRuleset = ... ; IlrWSDataDriver driver = new IlrWSDefaultDataDriver ( aRuleset.getReflect() ); ...
A port type is mapped to a dynamic class composed of two constructors:
ILOG JRules Web service operations can either be synchronous request-response or asynchronous one-way. This behavior is determined by the <message> and <operation> elements in the WSDL file.
Synchronous request-response means that every time a client application invokes a Web service operation, it receives a SOAP response, even if the method that implements the operation returns void. Asynchronous one-way means that the client never receives a SOAP response, not even a fault or exception.
The <operation> element describes how the public operations of a Web service are implemented. The public operations are those listed in the Web service WSDL and are executed by a client application that invokes the Web service:
wsdl:operation element in a WSDL file is named by the name attribute. The operation name maps to the name of the corresponding method on the mapped port type dynamic class.
<operation> element are used in combination to specify different kinds of operations.
<input message> and <output message> elements are used to explicitly declare the parameters and return values of the operation.
The following example shows an <operation> declaration:
<operation name="getRate">
// If a part name appears in only the input message, it is an in parameter.
<input message="tns:getRateRequest" name="getRate" />
// If a part name appears in only the output message, it is an out parameter.
<output message="tns:getRateResponse" name="getRateResponse"/>
</operation>
Out and in-out parameters enable an operation to return more than one return value. An in-out parameter acts as both an input and output parameter. To specify that a parameter is an in-out parameter, a part name appears in both the input and output message with the same type. You must always specify the parameter's XML Schema data type using the type attribute, as highlighted in the following <message> sample.
<message name="getRateRequest">
<part name="country1" type="xsd:string" />
<part name="country2" type="xsd:string" />
</message>
<message name="getRateResponse">
<part name="Result" type="xsd:float" />
</message>
For out and in-out modes, a special object (a holder - see Holder Classes and Support for Output Parameters) is introduced in the method signature. A holder is required to keep a reference on the instance built during the operation invocation. For example, if an out XML string parameter is declared in an operation, it is mapped on a javax.xml.rpc.holders.StringHolder class. For a simple XML string parameter, the mapping uses a java.lang.String class, whereas out parameters with a complex XML type are mapped on an ObjectHolder class.
Thus, the port type maps to a XOM dynamic class, and the operation maps to XOM dynamic methods. The following table shows how the different parts of an operation are mapped.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |