tags:

views:

231

answers:

1

It is well-known how to create a "contract first" WCF service where the first step is to define the ServiceContracts and DataContracts.

How should one approach WCF development if one has the "schema first". In other words, an XSD schema has been independently developed. The service may not deviate from the schema that is already defined. As a complication, the schema might use features that don't translate into DataContract (the DataContract capabilities, after all, are quite minimal).

Using XDocument on the server or client side for the entire document would be fine and good. (Use of XDocument would be greatly preferred over anything involving the XmlSerializer which unfortunately seems to have fallen out of favor without replacement). It is a requirement that the metadata/WSDL properly report the actual schema per the standards. It may not report a "generic" schema such as xsd:any. (Figuring out how to deal with these WSDL requirements is the part that is giving me the most trouble.)

(Similar questions/answers here do not address XDocument or WSDL requirements.)

+3  A: 

If you already have the XSD, the only missing link between those and a WCF interface is the WSDL. Once you have a WSDL, you can use svcutil.exe to generate WCF interfaces and classes properly annotated with the required attributes.

You can do it the hard way and write the WSDL by hand, but you also migth want to consider the WSCF tool.

Mark Seemann
Thanks, but this uses System.Xml.Serialization which I would prefer to not use. XmlSerializer seems like an important part of WCF interoperability but MS does not seem interested in enhancing it forward. :( What I am looking for here is a way to use XDocument and also still get the WSDL metadata I expect returned from the service.
binarycoder
Actually, WCF will use the **DataContractSerializer** by default, which is quite a different beast from the XmlSerializer. It's optimized and faster in general, uses a specific "opt-in" (rather than opt-out) model, but has other limitations (e.g. doesn't support attributes in the serialized XML)
marc_s