none
How to validate schema for the boolean field in BizTalk server 2013 R2 ? RRS feed

  • Question

  • I have a schema in which there is a field in which derived by restriction has been used to set few values using enumeration. In this schema there is also a boolean type field which is not mandatory, this field can be empty. But when using validate as a true and documentSpecnames in xmlReceive it is not validating the boolean field with empty value. If I am providing any boolean value then it is working fine. 

    Same thing is happening when I am using XMLValidate pipeline as well. Is there any way so that we can pass the empty value in boolean field? It is fine with string data type field.

    Monday, June 29, 2015 6:18 PM

All replies

  • What exactly do you mean not validating?

    Can you include the error message?

    Monday, June 29, 2015 6:31 PM
    Moderator
  • This is just like .NET (and other programming languages).

    Strings can be null

    numbers and booleans cannot!

    If you require a null element in XML for a boolean type you need to look into xsi:nil functionality. However I would recommend instead making the element optional (minOccurs = 0) and not include the boolean element, when it is "null"

    Morten la Cour

    Monday, June 29, 2015 6:52 PM
  • Hi Uday,

    When setting up the receive location the ValidateDocument and DocumentSpecNames properties are False and blank respectively. In this default configuration the XMLReceive pipeline will try and match the received XML document's target namespace and root node name to the published schemas in BizTalk, and the received document's structure will be validated against the schema's structure. No data validation is performed on the received document.

    By setting the ValidateDocument property to True the XML disassembler pipeline component will be instructed to validate the data contained in the received document as well.  Setting this property to true also requires that at least one DocumentSpecName is also provided, as the XML disassembler uses the schema specified by the fully qualified assembly name in the DocumentSpecNames property to identify the schema with which to perform the validation

    I would suggest to go with below MSDN blog for more details .

    BizTalk Does Not Validate My Message

    Thanks

    Abhishek

    Tuesday, June 30, 2015 4:38 AM
  • Hi Abishek,

    I have used the documentSpecNames and also I have kept the validateDocument property to true. It is validating for other fields where I have used the restriction.

    It is also validating boolean fields when I am providing some values like true or false, but since it is optional field sometimes this boolean field will be empty. In that case it throwing an error like :

    "FieldBoolean has an invalid value according to its DataType."."

    To make the field optional I have used the nillable property as true and minOccurres as 0. But I am getting the same error.

    Tuesday, June 30, 2015 5:29 AM
  • Hi Uday ,

    As been mentioned by La Cour ,have you tried setting the min occurrence to 0 for your boolean element . You can also try assigning   any default value over the boolean element (true,false) so that it can be validated in case your message contain null value for boolean element  .

    Thanks

    Abhishek

     

    Tuesday, June 30, 2015 5:58 AM
  • Hi Abhishek,

    Yes, I have tried setting the min occurrence with 0 value. I have tried by setting nillable with true value. But in both cases I getting below error:

    Reason: The document failed to validate because of the following error:"The 'testBoolean' element has an invalid value according to its data type." .  

    I cannot give any default values(true or false), please suggest me if there is any way or property that can help to achieve this.

     

    Thanks,

    Tuesday, June 30, 2015 6:39 AM
  • Hi Udal,

    Empty is a string value. you can't convert string Empty value to boolean this is your issue.

    MinOccur = 0 means the element not the value can be not exist but in your case the node element exists but value is empty.

    So, you need either to change datatype to string and deal with this node as string or this node element in test data should not be exist


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Tuesday, June 30, 2015 8:59 AM
  • Hi Uday,

    I do not think there is any available option there were you change the message structure at port level before pipeline processing  .As mapping comes after pipeline processing so you cannot use any transformation as well . So option available are either you set any default boolean value or remove the tag from the schema (as it is optional field as you have mentioned above .

    Thanks

    Abhishek

    Tuesday, June 30, 2015 9:53 AM
  • For clarity, if @myAttribute is defined as xs:Boolean, then @myAttribute="" is not valid because "" is not a valid Boolean.  There is no way around this in the Schema.  xs:boolean must be either "true" or "false".

    You did not say where this message is coming from.

    1. If you are generating it, then the solution is to go back to that code and change it so @myAttribute is either "true", "false" or does not appear at all.
    2. If you are receiving this, the solution is to push it back to the source.  They are sending you invalid Xml and they need to correct it.  If then refuse or cannot, then you need to inform your management that you are spending extra time to accommodate their non-compliance.  This is not your problem or a BizTalk problem.

    If you have to solve their problem, you have some options:

    1. Don't validate.
    2. Apply a Map first, then validate later such as in an Orchestration.
    3. Use a Custom Pipeline Component to correct the Xml in the Decode Stage.
    Tuesday, June 30, 2015 11:19 AM
    Moderator