You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ode.apache.org by phanlesang <ph...@gmail.com> on 2009/07/09 06:31:35 UTC
When we need to initialize a variable
Hi Everyone!
I'm getting confused about when we need to initialize a variable in BPEL 2.0
though BPEL 2.0 standard says that every variable must be initialized before
using.
For example:
In the HelloBPELProcess example, I see the variable output is initialized:
<bpel:assign validate="no" name="createResponse">
<bpel:copy>
<bpel:from>
<bpel:literal
xml:space="preserve"><tns:HelloBPELProcessResponse
xmlns:tns="http://www.se.uni-hannover.de/soa08/tutorial/HelloBPELProcess"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:result></tns:result>
</tns:HelloBPELProcessResponse>
</bpel:literal>
</bpel:from>
<bpel:to variable="output" part="payload"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="payload" variable="input">
<bpel:query
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:input]]></bpel:query>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
But in the SimpleInvokeProcess process, the variable output is not
initialized:
<bpel:assign validate="no" name="PrepareRandomHelloRequest">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve"><impl:sayHello
xmlns:impl="http://randomHelloService.tutorial.soa08.se.unihannover.de"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<impl:withSpace></impl:withSpace>
</impl:sayHello>
</bpel:literal>
</bpel:from>
<bpel:to variable="RandomHelloRequest"
part="parameters"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">true</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="RandomHelloRequest">
<bpel:query
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:withSpace]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="GetGreeting" partnerLink="RandomHelloPL"
operation="sayHello" portType="ns1:RandomHelloService"
inputVariable="RandomHelloRequest"
outputVariable="RandomHelloResponse"></bpel:invoke>
<bpel:assign validate="no" name="PrepareOutput">
<bpel:copy>
<bpel:from xmlns:http="urn:http:namesapce">
<![CDATA[concat(bpel:getVariableData('RandomHelloResponse', 'parameters',
'/'), bpel:getVariableData('input', 'payload', '/'))]]>
</bpel:from>
<bpel:to variable="output" part="payload"></bpel:to>
</bpel:copy>
</bpel:assign>
Thanks for any help!
-----
Sang PL http://www.nabble.com/file/u1501219/20.gif
--
View this message in context: http://www.nabble.com/When-we-need-to-initialize-a-variable-tp24403747p24403747.html
Sent from the Apache Ode User mailing list archive at Nabble.com.
Re: When we need to initialize a variable
Posted by phanlesang <ph...@gmail.com>.
Hi,
Thank you for your explanation.
Bill McCusker wrote:
>
> Hi,
>
> Variables need to be initialized before they are assigned from or when
> assigned to using a query or an expression or if they are used as to
> input to an invoke or in conditional expressions. If you are just
> assigning directly to a variable's message part with no query then no
> initialization is needed. Thats why the second example needs no
> initialization.
>
> Bill McCusker
>
> phanlesang wrote:
>> Hi Everyone!
>> I'm getting confused about when we need to initialize a variable in BPEL
>> 2.0
>> though BPEL 2.0 standard says that every variable must be initialized
>> before
>> using.
>> For example:
>> In the HelloBPELProcess example, I see the variable output is
>> initialized:
>>
>> <bpel:assign validate="no" name="createResponse">
>> <bpel:copy>
>> <bpel:from>
>> <bpel:literal
>> xml:space="preserve"><tns:HelloBPELProcessResponse
>> xmlns:tns="http://www.se.uni-hannover.de/soa08/tutorial/HelloBPELProcess"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> <tns:result></tns:result>
>> </tns:HelloBPELProcessResponse>
>> </bpel:literal>
>> </bpel:from>
>> <bpel:to variable="output" part="payload"></bpel:to>
>> </bpel:copy>
>> <bpel:copy>
>> <bpel:from part="payload" variable="input">
>> <bpel:query
>> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:input]]></bpel:query>
>> </bpel:from>
>> <bpel:to part="payload" variable="output">
>> <bpel:query
>> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
>> </bpel:to>
>> </bpel:copy>
>> </bpel:assign>
>>
>> But in the SimpleInvokeProcess process, the variable output is not
>> initialized:
>>
>> <bpel:assign validate="no" name="PrepareRandomHelloRequest">
>> <bpel:copy>
>> <bpel:from>
>> <bpel:literal xml:space="preserve"><impl:sayHello
>> xmlns:impl="http://randomHelloService.tutorial.soa08.se.unihannover.de"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> <impl:withSpace></impl:withSpace>
>> </impl:sayHello>
>> </bpel:literal>
>> </bpel:from>
>> <bpel:to variable="RandomHelloRequest"
>> part="parameters"></bpel:to>
>> </bpel:copy>
>> <bpel:copy>
>> <bpel:from>
>> <bpel:literal
>> xml:space="preserve">true</bpel:literal>
>> </bpel:from>
>> <bpel:to part="parameters" variable="RandomHelloRequest">
>> <bpel:query
>> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:withSpace]]></bpel:query>
>> </bpel:to>
>> </bpel:copy>
>> </bpel:assign>
>> <bpel:invoke name="GetGreeting" partnerLink="RandomHelloPL"
>> operation="sayHello" portType="ns1:RandomHelloService"
>> inputVariable="RandomHelloRequest"
>> outputVariable="RandomHelloResponse"></bpel:invoke>
>> <bpel:assign validate="no" name="PrepareOutput">
>> <bpel:copy>
>> <bpel:from xmlns:http="urn:http:namesapce">
>>
>> <![CDATA[concat(bpel:getVariableData('RandomHelloResponse', 'parameters',
>> '/'), bpel:getVariableData('input', 'payload', '/'))]]>
>> </bpel:from>
>> <bpel:to variable="output" part="payload"></bpel:to>
>> </bpel:copy>
>> </bpel:assign>
>>
>> Thanks for any help!
>>
>> -----
>> Sang PL http://www.nabble.com/file/u1501219/20.gif
>>
>
>
>
-----
Sang PL
--
View this message in context: http://www.nabble.com/When-we-need-to-initialize-a-variable-tp24403747p24410292.html
Sent from the Apache Ode User mailing list archive at Nabble.com.
Re: When we need to initialize a variable
Posted by Bill McCusker <wm...@parasoft.com>.
Hi,
Variables need to be initialized before they are assigned from or when
assigned to using a query or an expression or if they are used as to
input to an invoke or in conditional expressions. If you are just
assigning directly to a variable's message part with no query then no
initialization is needed. Thats why the second example needs no
initialization.
Bill McCusker
phanlesang wrote:
> Hi Everyone!
> I'm getting confused about when we need to initialize a variable in BPEL 2.0
> though BPEL 2.0 standard says that every variable must be initialized before
> using.
> For example:
> In the HelloBPELProcess example, I see the variable output is initialized:
>
> <bpel:assign validate="no" name="createResponse">
> <bpel:copy>
> <bpel:from>
> <bpel:literal
> xml:space="preserve"><tns:HelloBPELProcessResponse
> xmlns:tns="http://www.se.uni-hannover.de/soa08/tutorial/HelloBPELProcess"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <tns:result></tns:result>
> </tns:HelloBPELProcessResponse>
> </bpel:literal>
> </bpel:from>
> <bpel:to variable="output" part="payload"></bpel:to>
> </bpel:copy>
> <bpel:copy>
> <bpel:from part="payload" variable="input">
> <bpel:query
> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:input]]></bpel:query>
> </bpel:from>
> <bpel:to part="payload" variable="output">
> <bpel:query
> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
> </bpel:to>
> </bpel:copy>
> </bpel:assign>
>
> But in the SimpleInvokeProcess process, the variable output is not
> initialized:
>
> <bpel:assign validate="no" name="PrepareRandomHelloRequest">
> <bpel:copy>
> <bpel:from>
> <bpel:literal xml:space="preserve"><impl:sayHello
> xmlns:impl="http://randomHelloService.tutorial.soa08.se.unihannover.de"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <impl:withSpace></impl:withSpace>
> </impl:sayHello>
> </bpel:literal>
> </bpel:from>
> <bpel:to variable="RandomHelloRequest"
> part="parameters"></bpel:to>
> </bpel:copy>
> <bpel:copy>
> <bpel:from>
> <bpel:literal xml:space="preserve">true</bpel:literal>
> </bpel:from>
> <bpel:to part="parameters" variable="RandomHelloRequest">
> <bpel:query
> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:withSpace]]></bpel:query>
> </bpel:to>
> </bpel:copy>
> </bpel:assign>
> <bpel:invoke name="GetGreeting" partnerLink="RandomHelloPL"
> operation="sayHello" portType="ns1:RandomHelloService"
> inputVariable="RandomHelloRequest"
> outputVariable="RandomHelloResponse"></bpel:invoke>
> <bpel:assign validate="no" name="PrepareOutput">
> <bpel:copy>
> <bpel:from xmlns:http="urn:http:namesapce">
>
> <![CDATA[concat(bpel:getVariableData('RandomHelloResponse', 'parameters',
> '/'), bpel:getVariableData('input', 'payload', '/'))]]>
> </bpel:from>
> <bpel:to variable="output" part="payload"></bpel:to>
> </bpel:copy>
> </bpel:assign>
>
> Thanks for any help!
>
> -----
> Sang PL http://www.nabble.com/file/u1501219/20.gif
>