12 Replies Latest reply: Mar 19, 2012 11:12 AM by veejai24 RSS

    How to validate incoming messages with mandatory field coming as null/empty

    905784
      Hi,

      I want to validate the incoming messages received by the file adpater.

      1. Need to check that all the mandatory fields(minoccurs=1) has values, else it should return fault. But what happening now is even though the mandatory fields are empty/null, file is being read by the file adapter and not getting faulted.

      2. I have tried using the Validate Activity/Assign Activity but this is a business fault and not sytem fault, hence no faults are auto generated.

      3. We are presently using the if/switch activity and putting the conditions manually in order to validate the mandatory fields and hence it is throwing the business faults explicitly.

      4. But if there is 200 fields mandatory out of 500 fields schema, then we need to hardocde manually all 200 fields. Please advise me if this is possible in any dynamic way.

      Thanks

      Edited by: 902781 on 15.mar.2012 07:33
        • 1. Re: How to validate incoming messages with mandatory field coming as null/empty
          Arik
          Go to the partner link property. Choose in the name: validateXML and in the value: true
          This is actually validate the file before it enters you process.
          This attribute exists also in the EM bpel properties. Choosing it from there will validate all files.


          Riko
          • 2. Re: How to validate incoming messages with mandatory field coming as null/empty
            veejai24
            Right click the partnerlink and edit it to launch a pop up window, then click on the property tab.
            From the drop down set the "*validateXml*" to true.

            This will force the incoming xml payload to validate with the xsd for the particular composite.
            If you want to set it globally for all the composites of bpel then follow the setting mentioned in the URL below.
            http://docs.oracle.com/cd/E15523_01/integration.1111/e10226/bp_config.htm


            For Mediator, you can validate by using xsd or schematron.

            http://docs.oracle.com/cd/E15523_01/integration.1111/e10224/med_createrr.htm#BGBIHHEG

            Thanks,
            Vijay

            Edited by: veejai24 on 15-Mar-2012 06:43
            • 3. Re: How to validate incoming messages with mandatory field coming as null/empty
              905784
              Hi Vijay and Riko,

              Thanks for the immediate response.

              I tried giving validateXML property as true in the partner link but still message is not getting faulted.

              I set the below property in composite.xml for the bpel component:

              <component name="BPEL1" version="1.1">
              <implementation.bpel src="BPEL1.bpel"/>
              <property name="partnerLink.FileReadService.validateXML" type="xs:string"
              many="true">true</property>
              </component>

              Could you please help me to resove this issue.

              Thanks
              • 4. Re: How to validate incoming messages with mandatory field coming as null/empty
                veejai24
                Just keep the property like below

                <property name="validateXML">true</property>

                If validation fails, you will get bpelx:invalidVariables fault raised.

                http://docs.oracle.com/cd/E15523_01/integration.1111/e10224/bp_app_deploydesc.htm


                Thanks,
                Vijay

                Edited by: veejai24 on 15-Mar-2012 08:17
                • 6. Re: How to validate incoming messages with mandatory field coming as null/empty
                  905784
                  Dear Vijay and Riko,

                  Thanks for your comment. validateXML is working for all fields except string field.

                  validateXML and validate activity is actually performing the same manner. Whenever mandatory int field is null/empty, it is throwing the fault.

                  But if the string field comes as null/empty, instance is not getting faulted even though the minoccurs for the string field is 1(mandatory field) and the instance is getting completed.

                  Please advise me if the same case works for the mandatory string field coming as null/empty.


                  *@ Riko*,

                  strict value is not working at all even for the int mandatory fields coming as null/empty.

                  Thanks again.

                  Edited by: 902781 on Mar 15, 2012 11:50 PM
                  • 7. Re: How to validate incoming messages with mandatory field coming as null/empty
                    veejai24
                    Hi,

                    Can you share your XSD File here.

                    Thanks,
                    Vijay
                    • 8. Re: How to validate incoming messages with mandatory field coming as null/empty
                      veejai24
                      Hi,

                      You need to add an attribute to your string element definition like below.

                      <xs:element minOccurs="0" name="SomeStrings" nillable="false" type="xs:string"/>

                      This will force the payload to have this element and it shouldnt be nillable and with string value.

                      Thanks,
                      Vijay
                      • 9. Re: How to validate incoming messages with mandatory field coming as null/empty
                        905784
                        Dear vijay,

                        This is my xsd::


                        <?xml version="1.0" encoding="UTF-8" ?>
                        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                        xmlns="http://www.example.org"
                        targetNamespace="http://www.example.org"
                        elementFormDefault="qualified">
                        <xsd:element name="exampleElement">
                        <xsd:annotation>
                        <xsd:documentation>
                        A sample element
                        </xsd:documentation>
                        </xsd:annotation>
                        <xsd:complexType>
                        <xsd:sequence>
                        *<xsd:element name="element1" type="xsd:string" minOccurs="0"*
                        nillable="false"/>
                        *<xsd:element name="element2" type="xsd:int" minOccurs="0"*
                        nillable="false"/>
                        </xsd:sequence>
                        </xsd:complexType>
                        </xsd:element>
                        </xsd:schema>


                        I tried the above xsd as well as

                        <?xml version="1.0" encoding="UTF-8" ?>
                        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                        xmlns="http://www.example.org"
                        targetNamespace="http://www.example.org"
                        elementFormDefault="qualified">
                        <xsd:element name="exampleElement">
                        <xsd:annotation>
                        <xsd:documentation>
                        A sample element
                        </xsd:documentation>
                        </xsd:annotation>
                        <xsd:complexType>
                        <xsd:sequence>
                        *<xsd:element name="element1" type="xsd:string" minOccurs="1"*
                        nillable="false"/>
                        *<xsd:element name="element2" type="xsd:int" minOccurs="1"*
                        nillable="false"/>
                        </xsd:sequence>
                        </xsd:complexType>
                        </xsd:element>
                        </xsd:schema>

                        But instance is getting completed even though the mandatory string field(element 1) is empty/null like:

                        <element1></element1>

                        What I feel is, string will accept all the values whether it is int, date, long and in the same way it is accepting null character.

                        Please let me know if you have any solutions to overcome this.

                        Thanks again.
                        • 10. Re: How to validate incoming messages with mandatory field coming as null/empty
                          veejai24
                          Thats correct, empty string is a valid value to pass through.
                          Either you have to restrict before its been passed or handle it after receiveing it on the other end using if or choose statements.

                          Thanks,
                          Vijay
                          • 11. Re: How to validate incoming messages with mandatory field coming as null/empty
                            905784
                            Hello Vijay,

                            Presently, we are using switch condition but in our case there will be more than 100 mandatory string fields(minOccurs=1) in our xsd and we need to put conditions for all the fields manually inside switch or if. If you could please share how to restrict this before entering the receive activity in the xsd structure. Xsd structure has complex types and need to enforce restriction for the complex types. I even searched for the same but got the restriction only for simple type schema. So, if you could share the xsd structure with restrictions for complex types.

                            Thanks
                            • 12. Re: How to validate incoming messages with mandatory field coming as null/empty
                              veejai24
                              Before you pass the message to the endpoint, in your terms before it reaches the receive activity you will have a invoke and a transformation to pass the message.
                              There you can restrict by checking for null value, if not null then pass the message otherwise throw error message.

                              If you are using .xslt file you can use if statement or choose statement before passing the value to calling bpel service.

                              Hope this helps.

                              Thanks,
                              Vijay

                              Edited by: veejai24 on 19-Mar-2012 09:10