官术网_书友最值得收藏!

Invoking web services in a sequence

In this recipe, we will identify how to call web services in a sequence from the BPEL process. The sequential web service invocation presents one of the basic workflow concepts. We use this approach when we have several web services in our business process and each of them needs to wait for the previous one to finish.

Getting ready

We need to set up an environment where we can access multiple web services. Since the BPEL processes are also exposed as web services, we can also call another BPEL process in a sequence.

How to do it…

The following steps explain how to call a web service in a sequence from the BPEL process:

  1. We will start with the creation of an empty BPEL process. We can choose the synchronous or asynchronous BPEL process. We start by adding the web services references to the SOA composite. We add the following two web service references:
    • BookHotelSvc: This web reference helps to gather the hotel names that have available rooms in a selected period
    • RoomPriceSvc: This web reference queries the room price in the hotel

    The SOA composite or SCA (Service Composition Architecture) outlook is as shown in the following screenshot:

    In the SCA we can see the interconnection between the BPEL processes, how the BPEL process is exposed as web service, and which web services the BPEL process is referencing. We describe here the SCA from the BPEL process point of view; however, other components, such as human tasks, mediator components, business rules, and various adapters fit in.

  2. We will continue by modeling the BPEL process. We add the sequence activity and continue with the assign and invoke activity combination for both web services we want to call as follows:
    <sequence name = "Hotels_And_Prices">
      <assign name = "AssignAvailHotels">
        <copy>
          <from>xp20:current-dateTime()</from>
          <to>$AvailableHotels_availableHotels_InputVariable.parameters/ns1:from</to>
        </copy>
        <copy>
          <from>xp20:current-dateTime()</from>
          <to>$AvailableHotels_availableHotels_InputVariable.parameters/ns1:to</to>
        </copy>
      </assign>
    <invoke name = "AvailableHotels" bpelx:invokeAsDetail = "no" partnerLink = "BookHotelSvc" portType = "ns1:HotelBooking" operation = "availableHotels" inputVariable = "AvailableHotels_availableHotels_InputVariable" outputVariable = "AvailableHotels_availableHotels_OutputVariable"/>
      <assign name = "AssignRoomPrice">
        <copy>
          <from>$inputVariable.payload/client:input</from>
          <to>$GetRoomPrice_getPrice_InputVariable.parameters</to>
        </copy>
      </assign>
    <invoke name = "GetRoomPrice" bpelx:invokeAsDetail = "no" partnerLink = "RoomPriceSvc" portType = "ns2:RoomPriceServicePortType" operation = "getPrice" inputVariable = "GetRoomPrice_getPrice_InputVariable" outputVariable = "GetRoomPrice_getPrice_OutputVariable"/>
    </sequence>
  3. We deploy the BPEL process to the server and run it from the Oracle Enterprise Manager Console. We check Audit Trail of the BPEL process instance. We can observe that the web services we run are in a sequence, one after another, as shown in the following screenshot:

How it works…

In cases when the calls to multiple web services are dependent, we use the sequential execution of web services. Such a case can, for example, be a loan approval. Suppose we have a web service for the loan approval and a web service for the money transfer. It is obvious that money cannot be transferred before the loan is approved.

The sequence execution of web services in the BPEL process is achieved through the sequence activity. We used the sequence activity in this recipe in order to ensure that we get the price of the hotel room, only if the room is available.

See also

  • To develop and deploy web services, see the Implementing web services with Axis2 and Implementing web services with JAX-WS recipes
主站蜘蛛池模板: 洪洞县| 沂南县| 长治市| 灵宝市| 江川县| 布尔津县| 新乐市| 定兴县| 定襄县| 南涧| 洱源县| 贵港市| 莱阳市| 阜阳市| 安泽县| 建水县| 昆明市| 博白县| 泰宁县| 正镶白旗| 徐州市| 宁津县| 汉源县| 囊谦县| 彩票| 黑河市| 新源县| 临江市| 融水| 吉水县| 贵阳市| 西安市| 碌曲县| 银川市| 祁连县| 景宁| 唐河县| 太仆寺旗| 陈巴尔虎旗| 榆社县| 呼伦贝尔市|