views:

310

answers:

1

When I add a WCF service reference in Visual Studio 2008, a directory named Service Reference\ServiceReferenceNamespace is created.

In this directory, there's files named Service.xsd, Service1.xsd, Service2.xsd, Service3.xsd and Service4.xsd. The files rae not duplicates - the different files defines different types and elements. When I first created the service refernece, there was just one file but more Service*-files have been added when I've added more DataContract and OperationContracts.

It looks a bit strange that 5 different files are generated and not just one. If I delete the service reference (and hence the directory) and then add it again, the same files are added again.

Can anyone explain why several files are created and not just one?

+1  A: 

When you do Add Service Reference, VS first downloads the metadata -- as WSDL and XSD files -- that describes the service. These get stored in the ServiceReference directory. Then VS runs a code generation step using those files as input, producing the Reference.cs or .vb as output.

alexdej
Maybe I wasn't clear. My question was why there were Service1.xsd, Service2.xsd, Service3.xsd and Service4.xsd and not just Service.xsd.
Martin
You'll get one xsd file per type namespace. For WCF services that use DataContractSerializer, you'll typically get one XSD namespace per CLR namespace that your types use, plus an additional one for built-in types. If you want to put all your application-defined types into one XSD namespace you can use [DataContract(Namespace="...")] to set it to any URI.
alexdej