tags:

views:

14

answers:

0

I am working on a WCF (.NET 3.5 target) service which exposes a number of methods to be consumed ultimately by InfoPath.

I have a simple DataContract which includes several members, one of which is an XElement:

[DataContract]
public partial class MyDataContract 
{
    [DataMember]
    public string ObjectId {get; set;}

    [DataMember]
    public string Name {get; set;}

    [DataMember]
    public XElement Definition {get; set;}
}

At the moment, the WSDL generated for the service which returns this data, contains a snippet such as:

  <xs:element name="ObjectId" nillable="true" type="xs:string" /> 
  <xs:element name="Name" nillable="true" type="xs:string" /> 
  <xs:element name="Definition" nillable="true">
      <xs:complexType>
          <xs:sequence>
              <xs:any minOccurs="0" processContents="lax" /> 
          </xs:sequence>
      </xs:complexType>
  </xs:element>

What I would like to do is to specify an XSD which describes the content which comes under Definition and have that included in the WSDL, instead of the sequence of xs:any, so that InfoPath can understand the inner detail in the definition.

I know I could achieve this by replacing the XElement with the hierarchy of business objects which it represents, and decorating these as DataContracts, but the business objects are currently defined in a seperate system (the data contract objects we use here are read from a database, in which the Definition is represented as a string) and it would be a significant headache if we needed to take that route.

If anyone knows how to associate an XSD with an XElement data member, and have that definition included in the generated WSDL, you will be our hero!