- BPEL and Java Cookbook
- Jurij Laznik
- 479字
- 2021-08-06 16:58:19
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:
- 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 periodRoomPriceSvc
: 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.
- 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>
- 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
- Containerization with LXC
- 零起點學Linux系統(tǒng)管理
- Windows Vista基礎與應用精品教程
- 計算機系統(tǒng)開發(fā)與優(yōu)化實戰(zhàn)
- Linux內核觀測技術BPF
- 計算機系統(tǒng)的自主設計
- Distributed Computing with Go
- Windows 8實戰(zhàn)從入門到精通(超值版)
- Windows 7實戰(zhàn)從入門到精通(超值版)
- Multi-Cloud for Architects
- Linux內核修煉之道
- Java EE 8 High Performance
- Learning Joomla! 3 Extension Development(Third Edition)
- BuddyPress Theme Development
- 鴻蒙HarmonyOS應用開發(fā)從入門到精通