Delegation Processor
1. Introduction
The delegation processor can be used to call existing
code available as:
- a Web service
- an EJB
- a JavaBean
2. Usage

interface input |
With this input you describes services that you can then call
in the call input.
You define one or more service id(s) and maps each one
of those id(s) to a given Web service, EJB, or JavaBean. You also
need to provide any information that the delegation processor needs to
call the service: for instance a JNDI name for an EJB or a class
name for a JavaBean.
The interface input is the only document with information
specific to the service type (EJB, Web service or JavaBean).
This means that if, at some point, a service is moved from, say, a
JavaBean to an EJB, only the interface will have to be modified
(not the call input or data output).
|
call input |
A document containing <delegation:execute> elements.
Each <delegation:execute> element specifies a
service to be called and the parameters to be sent to that service.
|
data output |
A document based on the call input where the
<delegation:execute> elements have been
replaced with the value returned by the service.
|
3. Calling an EJB
You call an EJB with:
<p:processor name="oxf:delegation"> <p:input name="interface"> <config> <service id="creditcard-validation" type="stateless-ejb" uri="java:comp/env/ejb/creditcard-validation"/>
</config> </p:input> <p:input name="call"> <delegation:execute service="creditcard-validation" operation="validate"> <number xsi:type="xs:string">1234123412341234</number>
<type xsi:type="xs:string">visa</type>
</delegation:execute> </p:input> <p:output name="data" id="data"/>
</p:processor>
- The interface input declares the EJB that will be called:
-
The value of the type attribute must be set to
stateless-ejb.
-
The URI attribute references the JNDI name of the EJB.
- The call input defines the method to be called and the parameters:
-
The service attribute references the service id declared
in the interface input.
-
Each child element of <delegation:execute>
corresponds to an attribute of the method to be called. The name of
each element must match the attribute name, and the value in the
xsi:type attribute must match the attribute type. The
content of the element is the value passed to the EJB method.
-
Note: the only two supported types are: xs:string and
xs:double.
4. Calling a Web Service
4.1 Example: RPC-Style
<p:processor name="oxf:delegation"> <p:input name="interface"> <config> <service id="quotes" type="webservice" style="rpc" endpoint="http://www.scdi.org/~avernet/webservice/"> <operation nsuri="urn:avernet" name="getRandomQuote" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</service> </config> </p:input> <p:input name="call"> <delegation:execute service="quotes" operation="getRandomQuote"/>
</p:input> <p:output name="data" ref="data"/>
</p:processor>
4.2 Example: Document-Style
<p:processor name="oxf:delegation"> <p:input name="interface"> <config> <service id="stock-quote" type="webservice" style="document" endpoint="http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx"> <operation name="get-quote" soap-action="http://ws.cdyne.com/GetQuote"/>
</service> </config> </p:input> <p:input name="call"> <delegation:execute service="stock-quote" operation="get-quote" xsl:version="2.0"> <m:GetQuote> <m:StockSymbol>
<xsl:value-of select="/symbol"/>
</m:StockSymbol> <m:LicenseKey>0</m:LicenseKey>
</m:GetQuote> </delegation:execute> </p:input> <p:output name="data" ref="data"/>
</p:processor>
4.3 Usage
-
The interface input declares the Web service to be called:
-
Valid values for the style attribute are rpc
and document. The default value if the attribute
is missing is rpc.
-
The id (referenced when Web service is called in
the call input) and endpoint
(the SOAP endpoint) attributes are mandatory.
-
Declaring the Web service operations is optional for document-style
services. You only need to do so if you want to specify a SOAP action
for a given operation.
-
Optionally you can declare for each operation the encoding style
(encodingStyle attribute) and SOAP action
(soap-action attribute).
-
In the call input:
-
The XML fragment you specify in the execute element is
sent as is, and you are responsible of making sure that it
is valid according to the encoding style.
-
Referencing a specific operation in the operation
attribute is mandatory for RPC-style services, and is optional
for document-style services (you only want to do so if you
declared specific information about the operation in the
interface input).