Generated WES Schema File

An XML Schema Definition (XSD) is used to declare the elements that may be contained in a Microsoft Provisioning System (MPS) request or response. The executeData element gets extracted first in order to provide more flexibility with message formats. Taking this approach in the XSD allows for a greater number of formats to be allowed, including ASP.NET Web Services, Simple Object Access Protocol (SOAP), and Connected Services Framework (CSF).

<executeData>
 <path>LDAP://CN=user@customer1.com,OU=customer1,OU=reseller1,OU=Hosting,DC=FAbrikam,DC=Com</path>
	<planName>BaseMail</planName>
	<preferredDomainController>AD01.fabrikam.com</preferredDomainController>
</executeData>

Once the WES Generator has been run, the preceding sample gets translated to the following schema snippet:

<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="executeData">
	<xs:complexType>
	<xs:sequence>
		<xs:element name="path" type="xs:string" />
		<xs:element name="planName" type="xs:string" />
		<xs:element name="preferredDomainController" type="xs:string" />
		<xs:element name="customerTypeName" type="xs:string" />

	</xs:sequence>
	</xs:complexType>
  </xs:element>
</xs:schema>

Note

This is the default output of using the Create Schema function in Microsoft Visual Studio 2005. Several changes should be made to this code based on the functional requirements for this. The remainder of this topic addresses what needs to be changed.

XML Namespace Declaration

The XML Namespace Declaration should represent the provisioning API. This should also match the targetNamespace attribute. The following example uses the Uniform Resource Identifier (URI) for the Hosted Exchange Provisioning API.

<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema xmlns="http://provisioning.microsoft.com/hostedexchange" 
		 attributeFormDefault="unqualified" 
		 elementFormDefault="qualified" 
		 targetNamespace="http://provisioning.microsoft.com/hostedexchange" 
		 xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="executeData">
	<xs:complexType>
	<xs:sequence>
		<xs:element name="path" type="xs:string" />
		<xs:element name="planName" type="xs:string" />
		<xs:element name="preferredDomainController" type="xs:string" />
		<xs:element name="customerTypeName" type="xs:string" />
	</xs:sequence>
	</xs:complexType>
  </xs:element>
</xs:schema>

Sequence vs. All

If a document is validated against the declared schema, you may need to change the particle that dictates how elements may appear. Changing complexType particle to <xs:all> better matches the way MPS messages have been formatted in the past. Leaving this particle set to <xs:sequence> requires that data elements appear in the same order as they appear in the schema definition.

<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema xmlns="http://provisioning.microsoft.com/hostedexchange" 
		 attributeFormDefault="unqualified" 
		 elementFormDefault="qualified" 
		 targetNamespace="http://provisioning.microsoft.com/hostedexchange" 
		 xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="executeData">
	<xs:complexType>
	<xs:all>
		<xs:element name="path" type="xs:string" />
		<xs:element name="planName" type="xs:string" />
		<xs:element name="preferredDomainController" type="xs:string" />
		<xs:element name="customerTypeName" type="xs:string" />
	</xs:all>
	</xs:complexType>
  </xs:element>
</xs:schema>

Note

There are some limitations to what the <xs:all> particle will support. For more information, see XML Schema all Element.

Annotations

To annotate a schema with documentation regarding the elements of the schema, use <xs:annotation>/<xs:documentation>. For example:

<xs:schema xmlns="http://provisioning.microsoft.com/hostedexchange" 
				attributeFormDefault="unqualified" 
				elementFormDefault="qualified" 
				targetNamespace="http://provisioning.microsoft.com/hostedexchange" 
				xmlns:xs="http://www.w3.org/2001/XMLSchema">
		<xs:element name="executeData">
		<xs:annotation>
			<xs:documentation>The root data node</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:all>
			<xs:element minOccurs="1" maxOccurs="1" name="path" type="xs:string">
				<xs:annotation>
				<xs:documentation>The LDAP path of a user object</xs:documentation>
				<xs:appinfo xmlns="http://provisioning.microsoft.com/examples">LDAP://CN=johnc@alpineskihouse.com,ou=AlpineSkiHouse,OU=ConsolidatedMessenger,OU=Hosting,DC=FABRIKAM,DC=Com</xs:appinfo>
				</xs:annotation>
			</xs:element>
			<xs:element minOccurs="1" maxOccurs="1" name="planName" type="xs:string">
				<xs:annotation>
				<xs:documentation>The Exchange mailbox plan</xs:documentation>
				<xs:appinfo xmlns="http://provisioning.microsoft.com/examples">BaseMail</xs:appinfo>
				</xs:annotation>
			</xs:element>
			<xs:element minOccurs="1" maxOccurs="1" name="preferredDomainController" type="xs:string">
				<xs:annotation>
				<xs:documentation>The name of the domain controller to use for this operation</xs:documentation>
				<xs:appinfo xmlns="http://provisioning.microsoft.com/examples">ad01.fabrikam.com</xs:appinfo>
				</xs:annotation>
			</xs:element>
			<xs:element minOccurs="1" maxOccurs="1" name="customerTypeName" type="xs:string">
				<xs:annotation>
				<xs:documentation>Determines the type of resource management to use. BusinessUser and ConsumerUser are the two allowed inputs for this parameter. If not provided the procedure defaults to BusinessUser resource management.</xs:documentation>
				<xs:appinfo xmlns="http://provisioning.microsoft.com/examples">BusinessUser</xs:appinfo>
				</xs:annotation>
			</xs:element>
			 </xs:all>
		</xs:complexType>
		</xs:element>
	</xs:schema>

You can also insert sample data into an <xs:annotation> using <xs:appinfo>. To make use of these particles, you also need to add an identifier namespace declaration: xmlns:http://provisioning.micrsoft.com/examples. The following sample shows how to do this:

<xs:element minOccurs="1" maxOccurs="1" name="path" type="xs:string">
  <xs:annotation>
	<xs:documentation>The LDAP path of a user object</xs:documentation>
	<xs:appinfo xmlns="http://provisioning.microsoft.com/examples">LDAP://CN=johnc@alpineskihouse.com,ou=AlpineSkiHouse,OU=ConsolidatedMessenger,OU=Hosting,DC=FABRIKAM,DC=Com</xs:appinfo>
  </xs:annotation>
</xs:element>

Datatypes and Enums

Code generation and XML validation can be enhanced by stricter definitions of data types, including enumerations. (The default is xs:string.) The following example shows how the customerTypeName element is extended to be defined as an enumeration restriction. When the XML document is validated against this schema, the supplied value for customerTypeName must match one of the defined values:

<xs:element minOccurs="1" maxOccurs="1" name="customerTypeName">
  <xs:annotation>
	<xs:documentation>Determines the type of resource management to use. BusinessUser and ConsumerUser are the two allowed inputs for this parameter. If not provided the procedure defaults to BusinessUser resource management.</xs:documentation>
	<xs:appinfo xmlns="http://provisioning.microsoft.com/examples">BusinessUser</xs:appinfo>
  </xs:annotation>
  <xs:simpleType>
	<xs:restriction base="xs:string">
	<xs:enumeration value="BusinessUser" />
	<xs:enumeration value="CustomerUser" />
	</xs:restriction>
  </xs:simpleType>
</xs:element>