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

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
主站蜘蛛池模板: 临颍县| 噶尔县| 靖边县| 长岭县| 宣武区| 蒲江县| 金秀| 黄大仙区| 西安市| 黄浦区| 武宁县| 荆门市| 泗水县| 闻喜县| 休宁县| 隆化县| 康乐县| 色达县| 乳源| 许昌市| 满洲里市| 都江堰市| 桐城市| 通化市| 西林县| 鄂州市| 德兴市| 邓州市| 贵定县| 巴东县| 新邵县| 微博| 循化| 兰考县| 贺兰县| 东丰县| 德昌县| 婺源县| 德惠市| 甘肃省| 佛学|