You must have deployed the sample message flow and message set before you can run the sample.
If you encounter any problems when you run the sample, see Resolving problems when running samples in the WebSphere Message Broker documentation.
To run the XMLNSC Validation sample with a message that passes validation:
The input message passes all validation checks. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.OUT queue, and a copy of the input message is displayed under Message in the Test Client.
To run the XMLNSC Validation sample, where the input message fails validation because of missing data:
<Header Title="MissingElement"></Header>
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>Unexpected end element event. The content of element 'Header' is not complete.</Text>
The reason for the validation failure is because the input message must have an element called SaleListCount as a child of Header. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:complexType name="Header"> <xsd:sequence> <xsd:element name="SaleListCount" type="xsd:int"></xsd:element> </xsd:sequence> <xsd:attribute name="Title" type="xsd:string" use="optional"></xsd:attribute> </xsd:complexType>
To run the XMLNSC Validation sample, where the input message fails validation because of a numeric field that is out of range:
<Quantity>1010</Quantity;>
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>cvc-maxInclusive-valid: The value "1010" is not valid with respect to the maxInclusive facet with value "100" for type "#Anonymous".</Text>
The reason for the validation failure is because the value of Quantity in the input message must be an integer in the range 1 through 100 inclusive. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:element name="Quantity"> <xsd:simpleType> <xsd:restriction base="xsd:int"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="100"/> </xsd:restriction> </xsd:simpleType> </xsd:element>
To run the XMLNSC Validation sample, where the input message fails validation because the value of an element does not conform to the required pattern:
<Code>0#</Code>
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>cvc-pattern-valid: The value "0#" is not valid with respect to the pattern facet for type "#Anonymous".</Text>
The reason for the validation failure is because the value of Code in the input message must be alphanumeric. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:element maxOccurs="3" minOccurs="3" name="Code"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="[0-9a-zA-Z]{2}"/> </xsd:restriction> </xsd:simpleType>
To run the XMLNSC Validation sample, where the input message fails validation because a numeric field contains non-numeric data:
<Balance>$00.50</Balance>
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>cvc-datatype-valid.1.2: The value "$00.50" is not a valid value for the "float" datatype.</Text>The reason for the validation failure is because the value of Balance must be a float, and the dollar symbol is not a valid character for a float datatype. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:element name="Balance" type="xsd:float"></xsd:element>
To run the XMLNSC Validation sample, where the input message fails validation because a field is too long:
<Surname>Braithwaaaaaaaaaaaite</Surname>
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>cvc-maxLength-valid: The length of value "Braithwaaaaaaaaaaaite" is "21" which is not valid with respect to maxLength facet with value "20" for type "#Anonymous".</Text>
The reason for the validation failure is because the maximum length of Surname must be 20, whereas the length in the message is 21. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:element name="Surname"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="20"/> </xsd:restriction> </xsd:simpleType> </xsd:element>
To run the XMLNSC Validation sample, where the input message fails validation because the value of an element is not in the list of permitted values:
<Currency>FRF</Currency>
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>cvc-enumeration-valid: The value "FRF" is not valid with respect to the enumeration facet for type "#Anonymous". It must be a value from the enumeration.</Text>
The reason for the validation failure is because the Currency element must contain one of the permissable values defined in the schema. The value in the input message does not match any of the values in the list. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:element name="Currency"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="USD"/> <xsd:enumeration value="GBP"/> <xsd:enumeration value="Sterling"/> <xsd:enumeration value="EUR"/> <xsd:enumeration value="Euros"/> <xsd:enumeration value="JPY"/> </xsd:restriction> </xsd:simpleType> </xsd:element>
To run the XMLNSC Validation sample, where the input message fails validation because it has the wrong namespace:
<samp:SaleListMessage xmlns:samp="http://www.samplemessage.broker.hursley.ibm.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.samplemessage.broker.hursley.ibm.com/SampleMessageNamespace1.xsd">
The input message fails validation. In the Test Client a message is retrieved from the XMLNSCVALIDATIONMF1.FAIL queue, and part of the Exception List is displayed as an XML message. This ExceptionList message contains the following part:
<Text>Unexpected root tag. Element "samp:SaleListMessage" is not a global element.</Text>The reason for the validation failure is because the the global element SaleListMessage has no target namespace defined in the schema. The instance in the input message has a root tag called SaleListMessage with a namespace, making it different to what is expected from the schema definition. The following section of the XML schema SampleMessageValidation.xsd is where this requirement is defined:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="SaleListMessage" type="RootMessage"></xsd:element>
When you have completed these steps, you have successfully run the XMLNSC Validation sample. For information about the structure of XMLNSC validation exceptions, see Validation Properties.