views:

16

answers:

1

scratching my head on WCF ... I've got XML messages where the children of could be anything, e.g.

<Test1Root> 
  <CaseNo></CaseNo>
  <Activity></Activity>
  <DataFields>
     <AccountRef></AccountRef>
     <PropRef></PropRef>
     <User></User>
  </DataFields>
</Test1Root>

I've handled this in BizTalk using the xs:any for the

<xs:element name="DataFields">
  <xs:complexType>
    <xs:sequence>
      <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

But I'm struggling to see how to handle this in a WCF [DataContract]

I tried using both svcutil.exe and xsd.exe to create the classes, and they both give the main elements (CaseNo, Activity, etc.) but neither seems to handle the xs:any of DataFields ...

  • svcutil has DataFields as an XmlElement
  • xsd has it as a class, but with an Any property of type XmlElement []

Is it possible to get a better handling of the child elements ?

+1  A: 

Well, xs:any can be anything, so the best the .NET tools could do is give you an array of objects....

Since it can be anything, there's really not much you can do about it, right? It could be anything... so you need to use a type that could be anything.

If you really need that xs:any in your XML schema, and can't replace by e.g. a set of more specific xs:element (possibly inheriting from one another), I don't see how you could get better support...

marc_s
Thanks for the response, I was sort of expecting it, but had a (faint) hope there was a really neat way to handle this
SteveC