What are these WCF service reference files
Asked Answered
T

1

12

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 are 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?

Thetic answered 18/11, 2009 at 10:55 Comment(0)
P
5

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.

Peake answered 20/11, 2009 at 18:43 Comment(2)
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.Thetic
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.Peake

© 2022 - 2024 — McMap. All rights reserved.