Integration - Web Services

This page is obsolete and available for historical purposes only.

Overview

Your Orbeon Forms applications can consume and expose Web services.

Consuming web services

Applications built on Orbeon Forms call Web services using the delegation processor. For example, this is how you would call the famous highway traffic Web service to get the conditions on the 101 highway in California from an XPL:

<p:processor name="oxf:delegation">
<p:input name="interface">
<config>
<service id="ca-traffic" type="webservice" endpoint="http://services.xmethods.net/soap/servlet/rpcrouter">
<operation nsuri="urn:xmethods-CATraffic" name="getTraffic"/>
</service>
</config>
</p:input>
<p:input name="call">
<delegation:execute xmlns:delegation="http://orbeon.org/oxf/xml/delegation" service="ca-traffic" operation="getTraffic">
<hwynums>101</hwynums>
</delegation:execute>
</p:input>
<p:output name="data" id="traffic"/>
</p:processor>

The output of that call would be:

<return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">
reported as of Wednesday, July 2, 2003 at 16:18 .
Slow for the Cone Zone
US 101
[LOS ANGELES &amp; VENTURA CO.'S] NO TRAFFIC RESTRICTIONS ARE REPORTED FOR THIS AREA ...
</return>

Exposing web services

To expose a Web service, follow these steps:

  1. Declare the Web service in the page-flow.xml, just like a regular page with no view. The Web services will be implemented in an XPL file. The Orbeon Forms example portal features a Web service that sends instant messages to Yahoo! users. It is declared in the page-flow.xml as follows:

    <page path-info="/examples/im" model="oxf:/im/yim-webservice.xpl"/>
  2. To get the SOAP envelope sent to the Web service, use the Request generator and include the path /request/body, specifying the xs:anyURI type for the result. The resuting URI can then be parsed with the URL generator:

    <!-- Extract request body as a URI -->
    <p:processor name="oxf:request">
    <p:input name="config">
    <config xmlns:xs="http://www.w3.org/2001/XMLSchema" stream-type="xs:anyURI">
    <include>/request/body</include>
    </config>
    </p:input>
    <p:output name="data" id="request"/>
    </p:processor>
    <!-- Dereference URI -->
    <p:processor name="oxf:url-generator">
    <p:input name="config" href="aggregate('config', aggregate('url', #request#xpointer(string(/request/body))))"/>
    <p:output name="data" id="file"/>
    </p:processor>

    You will find the SOAP envelope sent by the client of your Web service as the resulting file. For example:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <soapenv:Body>...</soapenv:Body>
    </soapenv:Envelope>
  3. Generate a SOAP envelope that responds to the client's request and send it to the client with the XML serializer, as follows:

    <p:processor name="oxf:xml-serializer">
    <p:input name="config"><config/></p:input>
    <p:input name="data" href="#response"/>
    </p:processor>
Comments