title: How to avoid processContents="lax" in WCF WSDL from classes implementing IXmlSerializable?
body: <p>I have a wcf service written in a contract-first fashion. As some of the elements in the schema uses attributes, I had to create a custom serialization for this (using <code>IXmlSerializable</code>). Below is a snippet of the schema, and the classes, as well as the schema from the wsdl output.</p>
  
  <p>My problem is that even though I render the xsd for my IXmlSerializable classes, the schema is not included in the wsdl. They are just referenced with <code>processContents="lax"</code>. This seems to be a problem for consumers of my services, as they can not use their wizards to create clients.</p>
  
  <p>Has anyone encountered this problem? Is there anyway to control the wsdl output to avoid this. I experience the same behaviour using both message contracts and data contracts.</p>
  
  <p><strong>The schema for collection and item:</strong></p>
  
  <pre><code>&lt;xs:element name="TelephoneList"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element ref="Telephone" maxOccurs="unbounded"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="Telephone"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:simpleContent&gt;
                  &lt;xs:extension base="xs:string"&gt;
                      &lt;xs:attribute name="Type"&gt;
                          &lt;xs:simpleType&gt;
                              &lt;xs:restriction base="xs:NMTOKEN"&gt;
                                  &lt;xs:enumeration value="Preferred"/&gt;
                                  &lt;xs:enumeration value="Office"/&gt;
                                  &lt;xs:enumeration value="Mobile"/&gt;
                                  &lt;xs:enumeration value="Home"/&gt;
                                  &lt;xs:enumeration value="MobilePhoneFromExternalPartner"/&gt;
                                  &lt;xs:enumeration value="HomePhoneFromExternalPartner"/&gt;
                              &lt;/xs:restriction&gt;
                          &lt;/xs:simpleType&gt;
                      &lt;/xs:attribute&gt;
                  &lt;/xs:extension&gt;
              &lt;/xs:simpleContent&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
  </code></pre>
  
  <p><strong>The collection class:</strong></p>
  
  <pre><code>[CollectionDataContract(ItemName = "Telephone", Name = "TelephoneList", Namespace = Schema.WorkOrderNamespace)]
  public class TelephoneSet : SetBase&lt;Telephone&gt;
  {    }
  </code></pre>
  
  <p><strong>The item class:</strong></p>
  
  <pre><code>    [XmlSchemaProvider("GetSchemaFile")]
      public class Telephone : CustomSerializedEntity //The base class implements IXmlSerializable
      {
          public virtual TelephoneType? Type { get; set; }
          public virtual string Number { get; set; }
  
          /// &lt;remarks&gt;This method is referenced in the &lt;seealso cref="XmlSchemaProviderAttribute"/&gt; decoration.&lt;/remarks&gt;
          public static XmlSchemaComplexType GetSchemaFile(XmlSchemaSet xs)
          {
              return CreateSchema(xs, "Telephone");
          }
  
          public override void ReadXml(XmlReader reader)
          {
              Type = ReadEnumAttribute&lt;TelephoneType?&gt;(reader, "Type");
              reader.MoveToElement();
              Number = reader.Value;
          }
  
          public override void WriteXml(XmlWriter writer)
          {
              WriteAttribute(writer, "Type", Type);
              if (!string.IsNullOrEmpty(Number))
              {
                  writer.WriteValue(Number);
              }
          }
      }
  </code></pre>
  
  <p><strong>The xsd rendered by the service:</strong></p>
  
  <pre><code>&lt;xs:complexType name="TelephoneList"&gt;
        &lt;xs:sequence&gt;
           &lt;xs:element minOccurs="0" maxOccurs="unbounded" name="Telephone" nillable="true"&gt;
              &lt;xs:complexType&gt;
                 &lt;xs:sequence&gt;
                    &lt;xs:any minOccurs="0" processContents="lax"/&gt;
                 &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
           &lt;/xs:element&gt;
        &lt;/xs:sequence&gt;
     &lt;/xs:complexType&gt;
     &lt;xs:element name="TelephoneList" nillable="true" type="tns:TelephoneList"/&gt;
  </code></pre>