【发布时间】: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
是否可以在声明时初始化 BPEL 变量?如果有怎么办?
声明示例:
<variables>
<variable name="offer" type="xsd:float"/>
<variable name="response" type="xsd:string"/>
</variables>
【问题讨论】:
标签: web-services soa bpel
这是可能的。 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 页)了解定义。
【讨论】:
我们使用 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 控制台上,如有必要,管理员可以进行更改。
【讨论】:
经过一番谷歌搜索,阅读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>
...
【讨论】: