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

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.

  1. We start by defining the new schema element for the fault.
    <element name = "faultResponse">
      <complexType>
        <sequence>
          <element name = "msg" type = "string"/>
        </sequence>
      </complexType>
    </element>
  2. 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>
  3. 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>
  4. 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.
  5. 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.

  1. 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:
  2. 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()
  3. The modified fault handler of the BPEL process is as shown in the following screenshot:
主站蜘蛛池模板: 临漳县| 临海市| 嵊州市| 全州县| 桂平市| 榆中县| 望都县| 鹿邑县| 花垣县| 松滋市| 钟祥市| 珲春市| 泽库县| 建宁县| 丹巴县| 拉萨市| 修水县| 讷河市| 安化县| 临澧县| 柘城县| 盘山县| 遂平县| 丹江口市| 佛坪县| 湟中县| 清丰县| 绥阳县| 闸北区| 新化县| 牡丹江市| 大田县| 阿拉善左旗| 临潭县| 鞍山市| 巫溪县| 辉南县| 池州市| 宁津县| 深州市| 武清区|