0

I have to create a SOAP service (server) written in C# and would like it to take certain XML as an input. It is a first time I have to do this. I would base my solution on http://www.dotnetcurry.com/wcf/728/expose-wcf-service-soap-rest.

I have an XML schema for the input data. Is there a way to automatically convert the schema into [DataContract] record?

onkami
  • 8,791
  • 17
  • 90
  • 176

1 Answers1

1

Yes you can.

Simply start a Visual Studio command prompt and type:

svcutil /dconly mySchemaName.xsd

This will generate the equivalent datacontract class files for you. Syntax here: https://msdn.microsoft.com/en-us/library/aa347733(v=vs.110).aspx

However you must ensure that all dependent schemas (referenced by xsd:imports) are local to the schema you are generating against.

Additionally, svcutil is very fussy about supported schema element types. See here for details: https://msdn.microsoft.com/en-us/library/ms733112(v=vs.110).aspx

tom redfern
  • 30,562
  • 14
  • 91
  • 126