orangewise blog
Accessing a Simple HTTP Webservice Using Oracle BPEL Designer
This example shows how to create a HTTP web service and how you can include it in a BPEL process using Oracle BPEL designer.
Create a Very Simple PHP Service: ws.php
Create a php script that has the contents shown below. This script will act as our very simple PHP service.
<?
print"
  <ows:sessionLocator xmlns:ows=\"http://orangewise.com/SessionLocator\">
  <ows:sessionCity>Amsterdam</ows:sessionCity>
  <ows:sessionStreet>Singel</ows:sessionStreet>
  </ows:sessionLocator>";
?>
    
What is WSDL?
The Web Services Description Language (WSDL) is an XML language for describing the syntax of Web Service interfaces and their locations. A WSDL document has a definitions element that contains the following elements:

  • types - Provides information about any complex data types used in the WSDL document. When simple types are used, the WSDL document does not need this section.
  • message - An abstract definition of the data being communicated.
  • operation - An abstract description of the action supported by the service.
  • portType - An abstract set of operations supported by one or more endpoints.
  • binding - Describes how the operation is invoked by specifying concrete protocol and data format specifications for the operations and messages.
  • service - Specifies the port address(es) of the binding. The service is a collection of network endpoints or ports.
  • Create a WSDL File for the HTTP Web Service
    Create file SessionLocatorHTTPBinding.wsdl with the following contents:
    <?xml version="1.0" encoding="utf-8"?>
    <definitions 
          name="SessionLocatorHTTPBinding"
          targetNamespace="http://www.orangewise.uklinux.net"
          xmlns:tns="http://www.orangewise.uklinux.net"
          xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
          xmlns="http://schemas.xmlsoap.org/wsdl/"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
          xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    >
    
      
      <!-- Define the types the messages are built on
        --> 
      <types>
        <xsd:schema elementFormDefault="qualified"
                    targetNamespace="http://www.orangewise.uklinux.net">
          <xsd:element name="session" type="xsd:string"/>
          <xsd:element name="sessionLocator">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="sessionCity" type="xsd:string"/>
                <xsd:element name="sessionStreet" type="xsd:string"/>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:schema>
      </types>
    
      <!-- Define messages
        --> 
      <message name="HttpGetIn">
        <part name="sessionNumber" element="tns:session" />
      </message>
      <message name="HttpGetOut">
        <part name="payload" element="tns:sessionLocator"/>
      </message>
    
    
      <!-- Define portType, the logical definition of input and output
        -->
      <portType name="HttpGet">
        <operation name="GetSessionLocatorMethod">
          <input message="tns:HttpGetIn"/>
          <output message="tns:HttpGetOut"/>
        </operation>
      </portType>
    
    
      <!-- Define binding. 
           Binding defines the operations and for each operation
           the second part of the url that implements the operation,
           make sure it is available otherwise it will not work.
        -->
      <binding name="HttpGet" type="tns:HttpGet">
        <http:binding verb="GET"/>
        <operation name="GetSessionLocatorMethod">
          <http:operation location=""/>
          <input>
            <http:urlEncoded/>
          </input>
          <output>
            <mime:mimeXml part="payload"/>
          </output>
        </operation>
      </binding>
    
    
      <!-- Define service and tie it to a port.
           Port consists of a protocol specific binding 
           and an address (url)
        --> 
      <service name="SessionLocator">
        <port name="HttpGet" binding="tns:HttpGet">
          <http:address location="http://www.orangewise.uklinux.net/ws.php"/>
        </port>
      </service>
    
      <plnk:partnerLinkType name="SessionLocatorService">
        <plnk:role name="SessionLocatorServiceProvider">
          <plnk:portType name="tns:HttpGet"/>
        </plnk:role>
      </plnk:partnerLinkType>
    
    </definitions>
        
    Open your Oracle BPEL Process
    Open Oracle BPEL designer and your BPEL Process Project window.

    Create a Partner Link
    Add the wsdl file to your project directory and include it in your project (File > Add to <>.jpr). Validate the file by right clicking it in the Application Navigator and selecting "Validate WSDL". Now you can add this WSDL file to your flow. Drag the partnerlink icon to one of the swimlanes in the project. Give a name, select the WSDL file and set the Partner Role:

    Invoke the HTTP Service
    Drag the "Invoke" activity between the receiveInput and callbackClient activity in your process and name it Invoke_SLS, select partner link "Session Locator Service", operation "GetSessionLocatorMethod" and create the input and output variables:

    Deploy the Flow
    The flow can now be tested by deploying the project to the local BPEL server.

    Test the Flow in Oracle BPEL Console
    Select your deployed process on the Dashboard tab and submit a XML test file.

    HTTP Response of the Web Service
    Click on the Invoke_SLS icon in the flow diagram, the response of the service is displayed: