Processors - Delegation

This processor is deprecated. It still ships with Orbeon Forms for backward compatibility with existing applications using this processor. However, if you are writing new code, or changing code, you should instead look at the Submission processor, which allows you to call web and REST services, while reusing the <xforms:submission> construct, and providing you all the power of the XForms submission from XPL.


Introduction

The Delegation processor allows calling services implemented as:

  • A JavaBean
  • An EJB
  • A Web service

The main benefit of the Delegation processor is that you do not need to implement your own XML processor in Java to call services.

Inputs and outputs

Type Name Purpose Mandatory
Input interface

The interface input declares services that you can then call in the call input. You define one or more service identifiers and map those to a given JavaBean, EJB or Web service. You also need to provide 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, ohly the interface has to be modified, but not the call input.

Yes
Input call
  • The call input contains an XML document which is a template containing <delegation:execute> elements.
  • The <delegation:execute> element must be in the http://orbeon.org/oxf/xml/delegation namespace. The delegation prefix is usually mapped to this namespace.
  • Each <delegation:execute> element specifies a service to be called and the parameters to be sent to that service.
  • For calls to JavaBeans and EJBs in particular, it is important that the resulting document be a well-formed XML document. In particular, the resulting document must have a root element. In this case, always be sure that your call input contains at least one root element around <delegation:execute> elements.
Yes
Output data The data output produces a document based on the call input where the <delegation:execute> elements have been replaced with the value returned by the service. Yes

Calling a JavaBean

This is an example of using the Delegation processor to call a JavaBean:

<p:processor xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:delegation="http://orbeon.org/oxf/xml/delegation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="oxf:delegation">
<p:input name="interface">
<config>
<service id="my-service" type="javabean" class="MyClass"/>
</config>
</p:input>
<p:input name="call">
<result>
<delegation:execute service="my-service" operation="myMethod">
<param1 xsi:type="xs:string">param1</param1>
</delegation:execute>
</result>
</p:input>
<p:output name="data" id="result"/>
</p:processor>
  • The interface input declares the JavaBean to call:
  • The call input defines the method to call and the parameters to pass:

Calling an EJB

This is an example of using the Delegation processor to call an EJB:

<p:processor xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:delegation="http://orbeon.org/oxf/xml/delegation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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="result"/>
</p:processor>
  • The interface input declares the EJB that will be called:
  • The call input defines the method to be called and the parameters:

Calling a web service

Example: rpc-style

<p:processor xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:delegation="http://orbeon.org/oxf/xml/delegation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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" id="result"/>
</p:processor>

Example: document-style

<p:processor xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:delegation="http://orbeon.org/oxf/xml/delegation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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 xmlns:m="http://ws.cdyne.com/">
<m:StockSymbol>IBM</m:StockSymbol>
<m:LicenseKey>0</m:LicenseKey>
</m:GetQuote>
</delegation:execute>
</p:input>
<p:output name="data" id="result"/>
</p:processor>

Usage

  • The interface input declares the Web service to be called:
  • In the call input:
Comments