<?xml version="1.0" encoding="UTF-8"?>

<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
          elementFormDefault="qualified"
          targetNamespace="http://cucbc.com/sdd2/"
          xmlns:s1="http://cucbc.com/sdd2/">
	<s:element name="SDD2Request" type="s1:SDD2RequestType"/>
	<s:complexType name="SDD2RequestType">
		<s:annotation>
			<s:documentation>
				The initial SDD2 message.
			</s:documentation>
		</s:annotation>
		<s:sequence>
			<s:element minOccurs="1" maxOccurs="1" name="AppId"
			           type="s1:AppIdType">
				<s:annotation>
					<s:documentation>
						Value MUST be one of the CUCBC defined values.
						Those are NOT defined in an enumeration, since we
						expect the list to expand over time.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="RequestId"
			           type="s1:RequestIdType">
				<s:annotation>
					<s:documentation>
						Value SHOULD be unique within the SDD2Requests sent by the source.
						It is used to associate a SDD2Reply/ReplyResponse pair to the
						initial SDD2Request/Response pair.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="SourceService"
			           type="s1:ServiceNameType">
				<s:annotation>
					<s:documentation>
						Identifies the sender of the message. See documentation for
						ServiceNameType. In particular, this element may include the
						"OnBehalfOf" attribute, ( for instance when either MDi or MD5
						is handling a message created on one of the Credit Union sites.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="DestService"
			           type="s1:ServiceNameType">
				<s:annotation>
					<s:documentation>
						Identifies the target of the message. See documentation for
						ServiceNameType. Should NOT include the "OnBehalfOf" attribute.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="0" maxOccurs="1" name="RequestBody"
			           type="s:string">
				<s:annotation>
					<s:documentation>
						Payload for this Request. Must be in the format that the
						AppId implies. If that format is defined by some XML Schema,
						this payload MUST use XML escape characters appropriately.
					</s:documentation>
				</s:annotation>
			</s:element>
		</s:sequence>
	</s:complexType>

	<s:element name="SDD2Response" type="s1:SDD2ResponseType"/>
	<s:complexType name="SDD2ResponseType">
		<s:annotation>
			<s:documentation>
				The response to a specific instance of an SDD2Request.
			</s:documentation>
		</s:annotation>
		<s:sequence>
			<s:element minOccurs="1" maxOccurs="1" name="AppId"
			           type="s1:AppIdType">
				<s:annotation>
					<s:documentation>
						Value MUST match that of the associated SDD2Request.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="RequestId"
			           type="s1:RequestIdType">
				<s:annotation>
					<s:documentation>
						Value MUST match that of the associated SDD2Request.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="ProcessingStatus"
			           type="s1:ProcessingStatusType">
				<s:annotation>
					<s:documentation>
						This value is set by the application processing the Request.
						The value should be "Pending" if
						all the processing done so far has been successful AND
						the target will be sending an SDD2Reply when all processing is finished
						The value should be "Complete" if all processing was successfully completed -
						the ResponseBody may include application specific information.
						The value should be "Failure" if some processing was not successful - in that
						case the ResponseBody should contain application specific information about
						the problem.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="0" maxOccurs="1" name="ResponseBody"
			           type="s:string">
				<s:annotation>
					<s:documentation>
						OPTIONAL ( as far as SDD2 is concerned ) Payload for this Response.
						The application may require something here, and if so,
						this must be in the format that the
						AppId implies. If that format is defined by some XML Schema,
						this payload MUST use XML escape characters appropriately.
					</s:documentation>
				</s:annotation>
			</s:element>
		</s:sequence>
	</s:complexType>

	<s:element name="SDD2Reply" type="s1:SDD2ReplyType"/>
	<s:complexType name="SDD2ReplyType">
		<s:annotation>
			<s:documentation>
				The result of processing an "asynchronous" specific instance of an SDD2Request,
				sent from the RECIPIENT of an SDD2Request back to the sender.
				NOTE that MOST applications will not expect one of these. The only
				one that currently does expect one is the bulk mail application.
			</s:documentation>
		</s:annotation>
		<s:sequence>
			<s:element minOccurs="1" maxOccurs="1" name="AppId"
			           type="s1:AppIdType">
				<s:annotation>
					<s:documentation>
						Value MUST match that of the associated SDD2Request.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="RequestId"
			           type="s1:RequestIdType">
				<s:annotation>
					<s:documentation>
						Value MUST match that of the associated SDD2Request.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="SourceService"
			           type="s1:ServiceNameType">
				<s:annotation>
					<s:documentation>
						Identifies the sender of the message, which should be the destination
						of the original SDD2Request. See documentation for
						ServiceNameType.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="DestService"
			           type="s1:ServiceNameType">
				<s:annotation>
					<s:documentation>
						Identifies the target of the message, which should be the source
						of the original SDD2Request. See documentation for
						ServiceNameType. Should NOT include the "OnBehalfOf" attribute.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="1" maxOccurs="1" name="ProcessingStatus"
			           type="s1:ProcessingStatusType">
				<s:annotation>
					<s:documentation>
						This value is set by the application processing the Request.
						The value should NEVER be "Pending" in a SDD2Reply.
						The value should be "Complete" if all processing was successfully completed -
						the ResponseBody may include application specific information.
						The value should be "Failure" if some processing was not successful - in that
						case the ResponseBody should contain application specific information about
						the problem.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="0" maxOccurs="1" name="ReplyBody"
			           type="s:string">
				<s:annotation>
					<s:documentation>
						OPTIONAL ( as far as SDD2 is concerned ) Payload for this Reply.
						The application may require something here, and if so,
						this must be in the format that the
						AppId implies. If that format is defined by some XML Schema,
						this payload MUST use XML escape characters appropriately.
					</s:documentation>
				</s:annotation>
			</s:element>
		</s:sequence>
	</s:complexType>

	<s:element name="SDD2ReplyResponse" type="s1:SDD2ReplyResponseType"/>
	<s:complexType name="SDD2ReplyResponseType">
		<s:annotation>
			<s:documentation>
				The response to a specific instance of an SDD2Reply.
			</s:documentation>
		</s:annotation>
		<s:sequence>
			<s:element minOccurs="1" maxOccurs="1" name="AppId"
			           type="s1:AppIdType"/>
			<s:element minOccurs="1" maxOccurs="1" name="RequestId"
			           type="s1:RequestIdType"/>
			<s:element minOccurs="1" maxOccurs="1" name="ProcessingStatus"
			           type="s1:ProcessingStatusType">
				<s:annotation>
					<s:documentation>
						This value is set by the application processing the ReplyResponse.
						In general, the value should be "Complete" - the receiver of a Reply
						is not expected to do anything more than save it for reference.
						The value should be "Failure" if some processing was not successful - e.g.
						there was a failure when saving the Reply to a database. In that
						case the ResponseBody should contain application specific information
						about the problem.
						The value should NEVER be "Pending" in a SDD2ReplyResponse.
					</s:documentation>
				</s:annotation>
			</s:element>
			<s:element minOccurs="0" maxOccurs="1" name="ReplyResponseBody"
			           type="s:string">
				<s:annotation>
					<s:documentation>
						OPTIONAL ( as far as SDD2 is concerned ) Payload for this ReplyResponse.
						The application may require something here, and if so,
						this must be in the format that the
						AppId implies. If that format is defined by some XML Schema,
						this payload MUST use XML escape characters appropriately.
					</s:documentation>
				</s:annotation>
			</s:element>
		</s:sequence>
	</s:complexType>

	<s:simpleType name="ErrorCodeType">
		<s:restriction base="s:string">
			<s:maxLength value="30"/>
			<s:minLength value="1"/>
		</s:restriction>
	</s:simpleType>

	<s:simpleType name="ErrorMessageType">
		<s:restriction base="s:string">
			<s:maxLength value="300"/>
			<s:minLength value="1"/>
		</s:restriction>
	</s:simpleType>

	<s:simpleType name="ErrorLocationType">
		<s:restriction base="s:string">
			<s:enumeration value="Client"/>
			<s:enumeration value="Webservice"/>
			<s:enumeration value="Application"/>
		</s:restriction>
	</s:simpleType>

	<s:simpleType name="AppIdType">
		<s:restriction base="s:string">
			<s:maxLength value="30"/>
			<s:minLength value="1"/>
		</s:restriction>
	</s:simpleType>

	<s:simpleType name="RequestIdType">
		<s:restriction base="s:string">
			<s:maxLength value="50"/>
			<s:minLength value="1"/>
		</s:restriction>
	</s:simpleType>

	<s:complexType name="ServiceNameType">
		<s:attribute name="Service" type="s1:ServiceType" use="required"/>
		<s:attribute name="OnBehalfOf" type="s1:ServiceType" use="optional"/>
	</s:complexType>

	<s:simpleType name="ServiceType">
		<s:restriction base="s:string">
			<s:maxLength value="100"/>
			<s:minLength value="5"/>
		</s:restriction>
	</s:simpleType>

	<s:simpleType name="ProcessingStatusType">
		<s:restriction base="s:string">
			<s:enumeration value="Complete"/>
			<s:enumeration value="Failure"/>
			<s:enumeration value="Pending"/>
		</s:restriction>
	</s:simpleType>
</s:schema>

