3 Replies Latest reply on Oct 1, 2014 10:28 AM by Jorge Morales

    How to trigger XML validation of response message.

    Mark H Newbie

      We have a Soap web-service built using Switchyard and the incoming XML request messages are validated by declaring a number of validators which respectively reference an XSD file corresponding to one of the possible messages that may be received.


      One of our web-service methods takes as input a number of data items which are used to identify a record to return. We search for and find these records in a legacy database system that contains a lot of data that pre-dates this web-service application.


      It is therefore possible that the data in the database does not comply with the newer, more strict validation rules defined in the XSDs.


      We would like to ensure that outgoing messages are validated for conformance with the XSDs but at the moment validation is only being applied to the incoming messages, not the outgoing messages.


      The question therefore is, can the outgoing response messages be validated much as the incoming request messages are? I have initially attempted to add the XSDs for the response message type I am testing to the validator definition but thus far it hasn't had an effect.


      Many thanks in advance for your help in this matter.


      Best wishes,



        • 1. Re: How to trigger XML validation of response message.
          Tomohisa igarashi Master

          Are you sure your response message type is exactly same as name attribute of your validator definition? If you use Java interface for the service, you may want to add @OperationTypes(out = "{urn:your-namespace}yourOutMessageType") on a service operation in the service interface definition. Please attach a small reproducer if you can't solve with it.

          • 2. Re: How to trigger XML validation of response message.
            Mark H Newbie

            Apologies - this investigation has had to be down-graded in priority so I have had no time this week to look further into this.


            However, your answer was of value to me because by implication it told me I should be able to expect the out-bound response message to be XML Schema validated if I/we get everything configured properly.


            If/when I get back to looking at this issue, if I still cannot resolve the "how" I'll come back here. For now I've marked the answer as good since it at least got me the confirmation I was looking for.


            Many thanks,



            • 3. Re: How to trigger XML validation of response message.
              Jorge Morales Master


              Validations are applied several times for an Exchange.

              If the Exchange is IN_ONLY it is applied before and after the message has been transformed. (if any).

              If the Exchange is IN_OUT it is also applied for the response message, before and after is been transformed (if any).


              One exception to this is, if the validation has been already applied to the type, it will not be applied again. But, looking at: core/ValidateHandler.java at master · jboss-switchyard/core · GitHub It seems that this is an Exchange scoped property, so if the this property somehow is copied to the new Exchange (camel seems to propagate these properties) it may definitely avoid going through the validation again in the outgoing request.


              To test if this is true you can remove this property "org.switchyard.validatedType" from the context.


              If it happens to be true whatever I say, please raise a JIRA, as this will be a bug.


              PS: I'm not a SwitchYard commiter, so I might be very wrong ;-)