11 Replies Latest reply on Jan 12, 2011 1:24 PM by bbrodt

    Check input parameters (bpel:condition)

    izgur

      Hey!

       

      I'm wondering what's the best way to check input parameters in bpel.

       

      I'm able to check the one input parameter in one if statement in this way:

      <bpel:if name="CheckUsernameAndPassword">

              <bpel:condition expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[$input.payload/tns:sUsername="myname"]]></bpel:condition>

       

      No problem. But ...

      Let's say I have this method:  setUser(name, username, password, address, cgpn, cdpn, ip)    and they are all strings...

       

      Can I make more conditions within one if statement which checks if the params are NULL ???


      Like ... [CDATA[$input.payload/tns:sUsername=NULL]] && [CDATA[$input.payload/tns:sPassword=NULL]]

      Is there a way ??    or is the only way to make every if statement within the previous for every input parameter ???

       

      What is more... 

      The normal way would be that

      if (myparam1 = null OR myparam2 = null OR myparam3 = null OR myparam4 = null)

          go to  sendReply     (i saw the QUIT is not sending a reply)   -> can I jump to replyOutput ??

      else

         execute the next bpel element

       

      Thanks in advance!

       

      BR, Igor!

        • 1. Check input parameters (bpel:condition)
          objectiser

          Don't think there is the concept of null, so two possibilities are:

          a) if element always exists, then it would probably be an empty string, so $input.payload/tns:sUsername=""

          b) if element only present if a value specified, then use "exists($input.payload/tns:sUsername)"

           

           

           

          Igor JStarter wrote:

           

          The normal way would be that

          if (myparam1 = null OR myparam2 = null OR myparam3 = null OR myparam4 = null)

              go to  sendReply     (i saw the QUIT is not sending a reply)   -> can I jump to replyOutput ??

          else

             execute the next bpel element

           

           

          If using the same reply (i.e. normal response) in both paths, then best to put the reply following the if, and set the variable within each path - although wouldn't the first path return a fault?

           

          Regards

          Gary

          • 2. Check input parameters (bpel:condition)
            izgur

            I almost sure it didn't return a fault using the same replyOutput if one of the else statements... I'll try it tomorrow for sure...

            I pretty sure i will figure the replyOutput out... btw there is no function in BPEL like a goto ic C or jump to bpel element ???:)

             

            But... what about the other question... is there a way to write this line

            if (param1="" && param2="" &&param3="" && param4="")

                return "parameters already filled"

             

            in BPEL  :=)    Can I check 4 params (check if they are empty strings) in sth like one line  (not using 4 IFs)  ??

             

            The only way i tried and works to write IFs within IFs:

            <bpel:if>

            <bpel:condition param1=""  .... >

                 <bpel:sequence>

                     <bpel:if>

                     <bpel:condition param2="">  .....

                            <bpel:sequence>

                             <bpel:if>

                              <bpel:condition   param3=""> ....

             

            But there must be a more efficient way - not using 200 lines to check if 4-5 input parameters are null or empty strings ...

             

            Regards, Igor!

            • 3. Check input parameters (bpel:condition)
              jeffdelong

              If the input parameters are required elements in your message schema, perhaps you should use the bpel validate on the initial assign activity.

              • 4. Check input parameters (bpel:condition)
                izgur

                Could you please tell sth more or provide a short example how to use BPEL VALIDATE?

                 

                Thank you in advance!

                 

                Regars, Igor!

                • 5. Check input parameters (bpel:condition)
                  jeffdelong

                         <bpel:assign validate="yes" name="AssignDataToRequest">

                   

                   

                  This can be set by a Checkbox in the BPEL Editor.

                  • 6. Check input parameters (bpel:condition)
                    izgur

                    CHECKING / VALIDATION

                     

                    I got it know. I will test this today, got to expand the wsdl and try the validate.

                     

                    But that means that I have to use/initialize all input data in this first assign validate=yes tag or are automatically all inputs validate when turning validate=yes on the first assign ?

                     

                    That is help, but what about the other example...

                    Can I check if username=myuser and password=mypassword in one IF statement or within one condition, so that there would be only one else statement ... 

                     

                    SENDING ERROR REPLY

                    About replyOutput... i tested it know and there are no problems... i got more if/else statements and in each else I assigned an error string to the output variable and send the replyOutput...  works fine...

                     

                                <bpel:else>

                                    <bpel:sequence>            

                                        <bpel:assign>

                                            <bpel:copy>

                                                <bpel:from>

                                                    <![CDATA[concat($output.payload/tns:sTransactionID,'Wrong password ')]]>

                                                </bpel:from>

                                                <bpel:to part="payload" variable="output">

                                                    <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:sTransactionID]]></bpel:query>

                                                </bpel:to>

                                            </bpel:copy>

                                        </bpel:assign>

                                        <bpel:reply name="replyOutput"

                                               partnerLink="client"

                                               portType="tns:alertUsers"

                                               operation="process"

                                               variable="output"

                                           />

                                   </bpel:sequence> 

                                </bpel:else>

                    • 7. Check input parameters (bpel:condition)
                      izgur

                      Hey, the validate="yes" does nothing. What am I missing ?

                       

                      I think there is nothing to change in the wsdl. I think i got this right. Element in the XSD is required if minOccurs="1" and maxOccurs="1".

                      And if none of these 2 are set, the default valuest are 1 and 1.

                       

                      That's why I think you have only to set the validate right. How ?

                       

                      Is the validate checking only the elements inside the assign tag. I think I shouldn't initialize the input in the first assign ... how can i get it validate ??

                      • 8. Check input parameters (bpel:condition)
                        objectiser

                        Hi Igor

                         

                        It appears as if ODE does not support the 'validate' capability - on the http://ode.apache.org/ws-bpel-20-specification-compliance.html page, it says:

                         

                        "The specification also provides for validating variables at the end of an assignment using the validate attribute. ODE does not support this. This means that the bpel:invalidVariables fault is never thrown by an <assign> activity."

                         

                        Going back to a previous question of yours, you should be able to do:

                         

                        expr1 and expr2 and expr3 ....

                         

                        instead of separate 'if' statements. Have you tried this?

                         

                        Regards

                        Gary

                        • 9. Check input parameters (bpel:condition)
                          izgur

                          Yes, i read too that validate is not supported. But because of previous posts I thought only the bpel:validate isn't supported, but bpel:assign validate=yes is.  So there is not way validating input...

                           

                          How do you think expr1 and expr2 and expr3 .... would work ??

                           

                          Tests:

                          it returns The XPath segment "child::tns:sUsername" cannot be resolved. If I change the order, child::tns:sPassword" cannot be resolved

                          <bpel:condition expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[$input.payload/tns:sPassword="kkiss" and $input.payload/tns:sUsername="kkiss"]]></bpel:condition>

                           

                          not valid xpath expression

                          <bpel:condition expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[$input.payload/tns:sPassword="kkissuser"]] and [CDATA[$input.payload/tns:sUsername="kkisspasss"]]></bpel:condition>

                           

                          What would be the correct syntax ?

                          • 10. Check input parameters (bpel:condition)
                            objectiser

                            Hi Igor

                             

                            I thought the first syntax should work - anyone else see what is wrong with it?

                             

                            Regards

                            Gary

                            • 11. Check input parameters (bpel:condition)
                              bbrodt

                              Hmm, the first one should be correct, i.e.:

                               

                              <bpel:condition expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[$input.payload/tns:sPassword="kkiss" and $input.payload/tns:sUsername="kkiss"]]></bpel:condition>

                               

                              I have no idea what the problem could be