For Programmers: Free Programming Magazines  


Home > Archive > Microsoft Webservices > October 2005 > XSD and facets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XSD and facets
Walter

2005-10-03, 7:03 pm

Hello, everybody

I'm new to webservices in .Net. I'm trying to create a webservice that
accepts a instance of a class generated by XSD.exe from a XML schema.
Everything is working, except that the facets (restrictions) don't
work. For instance, I have some types defined using minLength and
maxLength. I expected that in case of a a string out of bounds, an
exception would occur. I don't know even if it had to work!

Does the framework check the input parameters against the XSD during
the process of deserialization? If so, did I miss something?

I'm using .net 1.1 and VS-2003.

Here is my XSD (just an example):
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Employee2"
targetNamespace="http://tempuri.org/Employee2.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/Employee2.xsd"
xmlns:mstns="http://tempuri.org/Employee2.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="Phone">
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
<xs:minLength value="8" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="FirstName" type="xs:string" minOccurs="1"
maxOccurs="1" />
<xs:element name="LastName" type="xs:string" minOccurs="1"
maxOccurs="1" />
<xs:element name="PhoneNumber" type="Phone" />
<xs:element name="EmailAddress" type="xs:string" minOccurs="1"
maxOccurs="1" />
<xs:element name="WebAddress" type="xs:string" minOccurs="0"
maxOccurs="1" />
<xs:element name="JobTitle" type="xs:string" minOccurs="0"
maxOccurs="1" />
</xs:sequence>
<xs:attribute name="ID" form="unqualified" type="xs:string" />
</xs:complexType>
<xs:element name="Employees">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="Employee" type="EmployeeType" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Thank you.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com