Define the Schema Type
First, define the object’s type either in the WSDL file’s types element, or in an associated or embedded XML Schema. Here’s an excerpt from mime.wsdl in the MIME directory. This example illustrates both traditional attachments as specified by SwA, as well as unreferenced attachments as described by WS-I Attachments Profile 1.0.
 
<types>
<xsd:schema targetNamespace="http://www.roguewave.com/rwsf/webservice/
examples/MIME.wsdl">
<!-- swaRef schema type, as defined in WS-I Attachments Profile 1.0 -->
<!-- http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html -->
<xsd:simpleType name="swaRef">
<xsd:restriction base="xsd:anyURI"/>
</xsd:simpleType>
 
<xsd:complexType name="DocumentPair">
<xsd:sequence>
<xsd:element name="DocumentName" type="xsd:string"/>
<xsd:element name="DocumentRef" type="tns:swaRef"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DocumentPairList">
<xsd:sequence>
<xsd:element name="List"
type="tns:DocumentPair"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Documents" type="tns:DocumentPairList"/>
</xsd:schema>
</types>
Note the simple type swaRef. This a schema type defined by the WS-I Attachments Profile 1.0 that identifies any associated message attachment. The restriction xsd:anyURI references an attachment in the message. By using a common type, all recipients know that the referenced message is an attachment. (For more information, see http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope). This type is used in unreferenced attachments (see Generate Code and Manipulate the Attachment).
The WSDL defines two complex types, DocumentPair and DocumentPairList, which is simply a list of elements of type DocumentPair. DocumentPair contains two elements, DocumentName, the MIME document’s name, and DocumentRef, MIME document’s key. DocumentRef is of type swaRef, which identifies it as a link to an attachment. In addition, the element Documents is declared, of type DocumentPairList.