9 Replies Latest reply on Oct 9, 2006 5:10 AM by Claus Wittmann

    BPEL beta2 - switch condition boolean true/false

    Claus Wittmann Newbie

      Hi there!

      I have a problem to get my switch condition working.
      So what have I done?
      I have written an operation that checkes something and then will return me a boolean value true or false.
      This operation is called directly before I start the switch () and therefore the Variable should be filled with true or false.

      Now I've tried different ways to get it working... Here all versions I've tried and which where not working.

      <case condition="bpel:getVariableData('checkGuardResponse', 'ValueOUT')">
      <case condition="bpel:getVariableData('checkGuardResponse', 'ValueOUT')='true'">

      <case condition="bpel:getVariableData('checkGuardResponse', 'ValueOUT')=true()">

      <case condition="boolean(bpel:getVariableData('checkGuardResponse', 'ValueOUT'))=true()">

      <case condition="bpel:getVariableData('checkGuardResponse', 'ValueOUT')=string(true())">


      In this case
      checkGuardResponse is container and ValueOUT is my Variable OUT for my checkGuard operation.

      What happens?
      My switch / case code is not beeing executed.
      By the way: I have not implemented an otherwise operation as I won't need it (it could be only true or false - and both will be handled by a case operation)

      I would say the first one should be the right one (in this case I would use the otherwise operation) - but also not working.
      As there are allready some other switch operations - I think it is not a failure of BPEL itself... Maybe only my codestyle ;-)

      Thanks in advance for every help!

      Greetings

      Claus

        • 1. Re: BPEL beta2 - switch condition boolean true/false
          Alejandro Guizar Master

          What is the value returned by bpel:getVariableData('checkGuardResponse', 'ValueOUT') ?

          The WSDL message and related schema types of the checkGuardResponse would also help.

          • 2. Re: BPEL beta2 - switch condition boolean true/false
            Claus Wittmann Newbie

            The return value of my checkGuardResponse should be true and false (implemented in java as told). I will test it this day whether this is really this value.

            Greetings

            Claus

            • 3. Re: BPEL beta2 - switch condition boolean true/false
              Claus Wittmann Newbie

              There seems to be something wrong with the condition itself.

              I've tried the following code and it wasn't working...

              <case condition="1 = 1">


              So here is the whole code - maybe you can see some errors?

              <switch>
               <case condition="1 = 1">
               <assign name="set_App_PDFViewer">
               <copy>
               <from part="Ticketnumber" variable="agilproReq"/>
               <to part="Ticketnumber" variable="setAppReq"/>
               </copy>
               <invoke inputVariable="setAppReq" operation="setApp" partnerLink="agilpro" portType="agi:AgilproIssuer"/>
               ...
               </case>
               <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT') = 0">
               <!--NOTHING TO DO HERE-->
               <empty />
               </case>
              </switch>
              


              Normally this code would be my condition:
              <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT') = 1">
              


              • 4. Re: BPEL beta2 - switch condition boolean true/false
                Claus Wittmann Newbie

                OK here comes the strange stuff:
                It doesn't matter what conditions I write or anything else...
                I have tried to use
                switch\condition
                and
                switch\otherwise

                as he won't use the condition I thought the jBOSS should use the otherwise - funtion

                Not at all!

                Now I tried to "kill" the switch code - my code works.
                If I surround it with the switch - it works not...

                I have also now tried the following (and it won't work):

                <variable name="check" type="xsd:boolean"/>
                
                <assign>
                 <copy>
                 <from expression="true()"/>
                 <to variable="check"/>
                 </copy>
                </assign>
                
                <switch name="split">
                 <case condition="bpel:getVariableData('check')">
                


                Any suggestions?

                Greetings

                Claus

                • 5. Re: BPEL beta2 - switch condition boolean true/false
                  Claus Wittmann Newbie

                  Problem solved...
                  first point:

                  <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT')=true()">


                  second point: It is essentiel that code inside the has to be placed inside a or a

                  Greetings

                  Claus

                  • 6. Re: BPEL beta2 - switch condition boolean true/false
                    Claus Wittmann Newbie

                    Oh I see there is missing some text...

                    inside a

                    <flow>
                    or a
                    <sequence>
                    should be there...

                    Ok Problem mostly solfed, but my Java function is returning a boolean value and it seems that this value is not correctly recogniced... Could this be? Here a code example:
                    Random zufall = new Random();
                     returnvalue = zufall.nextBoolean();
                    
                    
                     System.out.println("\tOUTPUT:: "+ returnvalue);
                     return returnvalue;


                    I also tried only an "return true" or "return false" - but got the same error - it doesn't matter which value I send back - It allways takes the first condition...

                    Any suggestions?

                    Greetings Claus

                    • 7. Re: BPEL beta2 - switch condition boolean true/false
                      Alejandro Guizar Master

                      There might be an issue here, but it is hard to tell without seeing the process definition and related WSDL documents. Can you please paste a minimal version of the process that shows the problem?

                      • 8. Re: BPEL beta2 - switch condition boolean true/false
                        Claus Wittmann Newbie

                        It seems to be a problem only related to boolean.
                        If I change it to INT it works fine.

                        Here some stuff that you wanted:
                        partner-wsdl-file (functional):

                        <message name="checkGuardRequest">
                         <part name="Ticketnumber" type="xsd:int"></part>
                         <part name="SomeStuffIn" type="xsd:string"></part> (Dummypart here)
                        </message>
                        <message name="checkGuardResponse">
                         <part name="ValueOUT" type="xsd:int"></part>
                        </message>
                        
                        <operation name="checkGuard">
                         <input message="agi:checkGuardRequest"></input>
                         <output message="agi:checkGuardResponse"></output>
                        </operation>
                        


                        partner-wsdl-file (non-functional):
                        <message name="checkGuardRequest">
                         <part name="Ticketnumber" type="xsd:int"></part>
                         <part name="SomeStuffIn" type="xsd:string"></part> (Dummypart here)
                        </message>
                        <message name="checkGuardResponse">
                         <part name="ValueOUT" type="xsd:boolean"></part>
                        </message>
                        
                        <operation name="checkGuard">
                         <input message="agi:checkGuardRequest"></input>
                         <output message="agi:checkGuardResponse"></output>
                        </operation>
                        



                        partner_impl.java (functional):
                         public int checkGuard(int ticketnumber, String SomeStuffIn) throws RemoteException {
                         //This code is for test purposes only!
                         //So I can change my output value without changing code and redeploy.
                         boolean bool;
                         int returnvalue=-1; //initialize and errorcode
                         System.out.println("**** checkGuard ****");
                         System.out.println("\tINPUT:: ticketnumber: "+ticketnumber+"\tSomeStuffIN: "+SomeStuffIN);
                         Random random = new Random();
                         bool = random.nextBoolean();
                        
                         if (bool == true)
                         returnvalue = 1;
                         if (bool == false)
                         returnvalue = 2;
                        
                         System.out.println("\tOUTPUT:: "+ returnvalue);
                         return returnvalue;
                         }
                        


                        partner_impl.java (non-functional):
                         public boolean checkGuard(int ticketnumber, String SomeStuffIn) throws RemoteException {
                         boolean bool;
                         System.out.println("**** checkGuard ****");
                         System.out.println("\tINPUT:: ticketnumber: "+ticketnumber+"\tSomeStuffIN: "+SomeStuffIN);
                         Random random = new Random();
                         bool = random.nextBoolean();
                        
                         System.out.println("\tYour returnvalue will be:: "+ bool);
                        
                         return bool;
                         //Also not functional:
                         //return true;
                         //return false;
                         }
                        



                        Part of my.bpel (functional):
                         <variable messageType="agi:checkGuardRequest" name="checkGuardReq"/>
                         <variable messageType="agi:checkGuardResponse" name="checkGuardRes"/>
                         <assign name="checkConditions">
                         <copy>
                         <from part="Ticketnumber" variable="nReq"/>
                         <to part="Ticketnumber" variable="checkGuardReq"/>
                         </copy>
                         <copy>
                         somestuff
                         </copy>
                         </assign>
                         <invoke inputVariable="checkGuardReq" operation="checkGuard" outputVariable="checkGuardRes" partnerLink="agilpro" portType="agi:AgilproIssuer"/>
                         <switch name="SplitVertriebschef">
                         <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT')=1">
                         <sequence>
                         somestuff
                         </sequence>
                         </case>
                         <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT')=0">
                         <empty />
                         </case>
                         <otherwise>
                         <empty />
                         </otherwise>
                         </switch>
                        


                        Part of my.bpel (non-functional):
                         <variable messageType="agi:checkGuardRequest" name="checkGuardReq"/>
                         <variable messageType="agi:checkGuardResponse" name="checkGuardRes"/>
                         <assign name="checkConditions">
                         <copy>
                         <from part="Ticketnumber" variable="nReq"/>
                         <to part="Ticketnumber" variable="checkGuardReq"/>
                         </copy>
                         <copy>
                         somestuff
                         </copy>
                         </assign>
                         <invoke inputVariable="checkGuardReq" operation="checkGuard" outputVariable="checkGuardRes" partnerLink="agilpro" portType="agi:AgilproIssuer"/>
                         <switch name="SplitVertriebschef">
                         <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT')=true()">
                         <sequence>
                         somestuff
                         </sequence>
                         </case>
                         <case condition="bpel:getVariableData('checkGuardRes', 'ValueOUT')=false()">
                         <empty />
                         </case>
                         <otherwise>
                         <empty />
                         </otherwise>
                         </switch>
                        
                        

                        my Variable checkGuardRes with its ValueOUT should have the boolean true or false as value. But It seems that he doesn't really check this value - there seems to be some issue as it allways started the first condition. Maybe only my condition is wrong? But I havent found NOWHERE any example that may fit my case...

                        I hope this will help you. I have changed my code to int values - so I have more options for returnvalues and it works :-)

                        Greetings

                        Claus

                        • 9. Re: BPEL beta2 - switch condition boolean true/false
                          Claus Wittmann Newbie

                          Maybe this code needed?
                          partner-impl.wsdl

                          <operation name="checkGuard">
                           <soap:operation soapAction="urn:samples:agilpro:action:checkGuard" />
                           <input>
                           <soap:body use="literal" namespace="urn:samples:agilpro" />
                           </input>
                           <output>
                           <soap:body use="literal" namespace="urn:samples:agilpro" />
                           </output>
                           </operation>


                          This code is allways the same...

                          Greetings
                          Claus