2 Replies Latest reply on Oct 29, 2012 4:44 AM by Ravish Srivastava

    Smook Validation issue in Jboss ESB

    Ravish Srivastava Newbie

      Hi ,

       

      I am new to Jboss ESB. I have a requirment where I need to validate State/Country combination coming in requests as below:

       

      Input SOAP request format :

      --------------

      Request 1:

      <order>

           <InstallAddress>

                <CommonAddress>

                   <street1>900 A Ashland B</street1>

                   <street2>10019</street2>

                   <City>Chigao</City>

                   <Country>US</Country>

                   <State>IL</State>

               </CommonAddress>

           </InstallAddress>

           <BillingAddress>          

                <street1>900 A Ashland B</street1>

              <street2>10019</street2>

              <City>Chigao</City>

              <Country>US</Country>

              <State>IL</State>

           </BillingAddress>

           <ShipingAddress>

              <street1>900 A Ashland B</street1>

              <street2>10019</street2>

              <City>Chigao</City>

              <Country>US</Country>

              <State>IL</State>

         </ShipingAddress>

      </order>

       

      Request 2:

       

      <order>

           <InstallAddress>

                   <street1>900 A Ashland B</street1>

                   <street2>10019</street2>

                   <City>Chigao</City>

                   <Country>US</Country>

                   <State>IL</State>

           </InstallAddress>   

      </order>

       

      I have used smook vlidation to implement this validation as below:

       

      smook-validate.xml

      -------------------------------

      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"

                            xmlns:rules="http://www.milyn.org/xsd/smooks/rules-1.0.xsd"

                            xmlns:validation="http://www.milyn.org/xsd/smooks/validation-1.0.xsd"

                            xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd">

       

      <rules:ruleBases>

             <rules:ruleBase name="validateStateCountry" src="rules/validation-rules.csv" provider="org.milyn.rules.mvel.MVELProvider"/>      

          </rules:ruleBases>

       

          <jb:bean beanId="installAddress" class="java.util.HashMap" createOnElement="InstallAddress">

                 <jb:value data="InstallAddress/*"/>

          </jb:bean>

       

           <jb:bean beanId="billingAddress" class="java.util.HashMap" createOnElement="BillingAddress">

                 <jb:value data="BillingAddress/*"/>

          </jb:bean>

       

          <jb:bean beanId="shipingAddress" class="java.util.HashMap" createOnElement="ShipingAddress">

                 <jb:value data="ShipingAddress/*"/>

          </jb:bean>

       

      <validation:rule executeOn="InstallAddress" name="validateStateCountry.validateInstallState1"  onFail="ERROR"/>

      <validation:rule executeOn="InstallAddress/CommonAddress" name="validateStateCountry.validateInstallState2"  onFail="ERROR"/>

      <validation:rule executeOn="BillingAddress" name="validateStateCountry.validateBillingState1"   onFail="ERROR"/>

      <validation:rule executeOn="ShipingAddress" name="validateStateCountry.validateShipingState1"   onFail="ERROR"/>

      </smooks-resource-list>

       

      The probelm here is each time the request comes request 1 or request 2, engine tries to fire all the above rules and while exeuting the rule on element "InstallAddress/CommonAddress", it goes back to fire rule on "InstallAddress" element and fails there and vice- versa. I am gettting only <InstallAddress> only in one SOAP request and <CommonAddress> as direct child of <InstallAddress> in a different SOAP request.

       

      How can, I make sure that each time the correct rules sholud get fire.

       

       

      Thanks

      RS