Web Services
1. Overview
Your Orbeon Forms applications can consume and expose Web services.
2. 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:
The output of that call would be:
3. Exposing Web Services
To expose a Web service, follow these steps:
-
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 thepage-flow.xml
as follows:<page path-info="/examples/im" model="oxf:/im/yim-webservice.xpl"/> -
To get the SOAP envelope sent to the Web service, use the Request generator and include the path
/request/body
, specifying thexs: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 stream-type="xs:anyURI" xmlns:xs="http://www.w3.org/2001/XMLSchema"><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 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>...</soapenv:Body></soapenv:Envelope> -
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>