【问题标题】:BPEL variables initialisationBPEL 变量初始化
【发布时间】:2010-12-30 05:01:21
【问题描述】:

是否可以在声明时初始化 BPEL 变量?如果有怎么办?

声明示例:

<variables>
    <variable name="offer" type="xsd:float"/>
    <variable name="response" type="xsd:string"/>
</variables> 

【问题讨论】:

    标签: web-services soa bpel


    【解决方案1】:

    这是可能的。 BPEL 2.0 允许直接在变量声明中使用 from-spec。但是,并非所有 BPEL 引擎都实现了此功能,例如Apache ODE 无法处理此类内联初始化。

    以下 sn-p 是有效的 BPEL 2.0:

    <variables>
        <variable name="response" type="xsd:string">
            <from>'TocToc'</from>
        </variable>
        <variable name="offer" type="xsd:float">
            <from>100</from>
        </variable>
    </variables>
    

    例如,请参阅 [1] 的第 121 页和 [1] 的第 8.1 节(第 45 页)了解定义。

    [1]http://docs.oasis-open.org/wsbpel/2.0/wsbpel-v2.0.pdf

    【讨论】:

      【解决方案2】:

      我们使用 Oracle BPEL,它允许在 bpel.xml 文件中设置属性,如下所示:

       <preferences>
          <property name="output_file" encryption="plaintext">logging.txt</property>
          <property name="expire_hours" encryption="plaintext">10</property>
          <property name="retry_count" encryption="plaintext">4</property>
       </preferences>
      

      可以在代码中使用 ora:getPreference("varname") 访问

      这些也显示在 BPEL 控制台上,如有必要,管理员可以进行更改。

      【讨论】:

        【解决方案3】:

        经过一番谷歌搜索,阅读spec 和示例...我认为不可能在声明时初始化 BPEL 变量...如果我们需要,我们需要在流程序列中进行:

        ...
            <variables>
                <variable name="response" type="xsd:string"/>
                <variable name="offer" type="xsd:float"/>
            </variables>
        ...
            <sequence>
                <receive createInstance="yes" .../>
        ...
                <assign name="init">
                    <copy>
                        <from>100</from>
                        <to variable="offer"/>
                    </copy>
                    <copy>
                        <from>'TocToc'</from>
                        <to variable="response"/>
                    </copy>
                </assign>
        ...
        

        【讨论】:

        • 请看我上面的回答,BPEL 允许通过变量声明中的 from-spec 进行内联初始化。
        猜你喜欢
        • 2019-05-17
        • 2021-07-08
        • 2012-06-15
        • 2012-10-19
        • 2016-11-03
        • 2017-03-20
        • 2016-07-31
        • 2017-09-11
        • 2016-05-28
        相关资源
        最近更新 更多