The representatio" /> The representatio" /> The representatio"/>

WCF 4.5 contract-first not generating simple types "correctly"

253 Views Asked by At

I have the following simple type defined in an XSD:

    <xs:simpleType name="TimeOfDay">
    <xs:annotation>
        <xs:documentation xml:lang="en">The representation of a time value that does not include time zone/offset information.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:time">
        <xs:minInclusive value="00:00:00"/>
        <xs:pattern value="(([01][0-9])|(2[0-3]))(:[0-5][0-9]){2}(\.[0-9]+)?"/>
    </xs:restriction>
</xs:simpleType>

When I generate the C# code from this using the WCF code-gen feature in .NET 4.5, it maps this type to DateTime. As a result, when we serialize the data contract to XML, the value fails schema validation because it contains the full date/time value, "dd-mm-yyyyThh:mm:ss.fff".

Any idea how we can either:

  1. Have the generated code implement the necessary restrictions
  2. Customize the serialization process so only the time component of the value is written into the XML output
0

There are 0 best solutions below