- BPEL and Java Cookbook
- Jurij Laznik
- 310字
- 2021-08-06 16:58:20
Throwing the faults from BPEL
In this recipe, we will identify the ways of how to throw the faults from BPEL. For this recipe, we will adapt the BPEL process from the previous recipe.
How to do it…
In the previous recipe, we saw that the web service performed the check against the dates. However, we would like to change the BPEL process so that some basic checking on the dates is performed in the BPEL process. We will check if the from
and to
dates are the same. If they are the same, we will throw the fault.
- We start by defining the new schema element for the fault.
<element name = "faultResponse"> <complexType> <sequence> <element name = "msg" type = "string"/> </sequence> </complexType> </element>
- We also define the new message in WSDL that will hold information about the fault.
<wsdl:message name = "EqualDatesFault"> <wsdl:part name = "fault" element = "client:faultResponse"/> </wsdl:message>
- In the next step, we extend the port type of the BPEL process. Notice the fault element that we added.
<wsdl:portType name = "BPELProcessFault"> <wsdl:operation name = "process"> <wsdl:input message = "client:BPELProcessFaultRequestMessage"/> <wsdl:output message = "client:BPELProcessFaultResponseMessage"/> <wsdl:fault message = "client:EqualDatesFault" name = "fault"/> </wsdl:operation> </wsdl:portType>
- In the BPEL process, we take the
<switch>
activity. We set the condition on dates and put the<throw>
activity inside of the<switch>
activity. The<throw>
activity would throw the fault we defined in the previous steps. - Now we run the BPEL process and define the same date in the
from
-to
parameters. We can see that the fault was thrown from the BPEL process and that the BPEL process did not finish successfully.
There's more…
We do a check about the fault in the fault handlers. In cases where the BPEL process cannot recover from the fault, we sometimes want to rethrow the fault to the client, calling the BPEL process.
- We do this by using the
<throw>
activity. We define the same parameters as we did for the<catch>
activity as shown in the following screenshot: - We set the condition for checking the dates in the
<switch>
activity as follows:bpws:getVariableData('inputVariable','payload','/client:process/client:from') > xp20:current-dateTime()
- The modified fault handler of the BPEL process is as shown in the following screenshot:
推薦閱讀
- Linux設(shè)備驅(qū)動(dòng)開發(fā)詳解:基于最新的Linux4.0內(nèi)核
- Modern Web Testing with TestCafe
- Implementing Cisco UCS Solutions
- Mastering KVM Virtualization
- 循序漸進(jìn)學(xué)Docker
- 精解Windows8
- RESS Essentials
- Linux運(yùn)維最佳實(shí)踐
- Linux使用和管理指南:從云原生到可觀測(cè)性
- Linux內(nèi)核設(shè)計(jì)的藝術(shù):圖解Linux操作系統(tǒng)架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- Windows 7應(yīng)用入門與技巧
- Cassandra 3.x High Availability(Second Edition)
- Windows 7使用詳解(修訂版)
- Windows Server 2008組網(wǎng)技術(shù)與實(shí)訓(xùn)(第3版)
- bash shell腳本編程經(jīng)典實(shí)例(第2版)