I am using C #, .NET 4.5, a console application. I added the WSDL file to the service link. There are validation rules inside WSDL, for example:
<xs:complexType name="xRequest">
<xs:sequence>
<xs:element name="SenderDateTime" type="ip:grDateTime"/>
<xs:element name="SenderId" type="ip:grIdentifier"/>
</xs:sequence>
</xs:complexType>
There is also an XSD file with details of the verification rules, for example:
<xs:simpleType name="grDateTime">
<xs:restriction base="xs:dateTime">
<xs:pattern value="[0-9]{4,4}\-[0-9]{2,2}\-[0-9]{2,2}[T][0-9]{2,2}:[0-9]{2,2}:[0-9]{2,2}(\.[0-9]{1,6}){0,1}"/>
</xs:restriction>
</xs:simpleType>
And I automatically created properties from WSDL in Reference.cs, for example:
public partial class xRequest
{
private string senderIdField;
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
public string SenderId {
get {
return this.senderIdField;
}
set {
this.senderIdField = value;
this.RaisePropertyChanged("SenderId");
}
}
}
I am serializing an xRequest object in XML and I want to validate it. How can I validate XML using XSD when part of validation rules are in WSDL?
source
share