Tôi sử dụng C#, .NET 4.5, ứng dụng Bảng điều khiển. Tôi đã thêm tệp WSDL vào tham chiếu dịch vụ. Bên trong WSDL là quy tắc xác nhận như:Cách xác thực XML với XSD, khi một phần của quy tắc xác thực nằm trong WSDL
<xs:complexType name="xRequest">
<xs:sequence>
<xs:element name="SenderDateTime" type="ip:grDateTime"/>
<xs:element name="SenderId" type="ip:grIdentifier"/>
</xs:sequence>
</xs:complexType>
Có tập tin XSD quá, với các chi tiết của quy tắc xác nhận như:
<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>
Và tôi đã tự động tạo ra các thuộc tính từ WSDL trong Reference.cs như:
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");
}
}
}
Tôi tuần tự hóa đối tượng xRequest thành XML và tôi muốn xác thực nó. Làm cách nào để xác thực XML bằng XSD, khi một phần của các quy tắc xác thực nằm trong WSDL?