How to: Use Svcutil.exe to Download Metadata Documents
You can use Svcutil.exe to download metadata from running services and to save the metadata to local files. For HTTP and HTTPS URL schemes, Svcutil.exe attempts to retrieve metadata using WS-MetadataExchange and XML Web Service Discovery. For all other URL schemes, Svcutil.exe uses only WS-MetadataExchange.
By default, Svcutil.exe uses the bindings defined in the MetadataExchangeBindings class. To configure the binding used for WS-MetadataExchange, you must define a client endpoint in the configuration file for Svcutil.exe (svcutil.exe.config) that uses the
IMetadataExchange contract and that has the same name as the Uniform Resource Identifier (URI) scheme of the metadata endpoint address.
When running Svcutil.exe to get metadata for a service that exposes two different service contracts that each contain an operation of the same name, Svcutil.exe displays an error saying, “Cannot obtain Metadata from ....” For example, if you have a service that exposes a service contract called ICarService that has an operation Get(Car c) and the same service exposes a service contract called IBookService that has an operation Get(Book b). To work around this issue, do one of the following:
Locate the Svcutil.exe tool at the following location:
C:\Program Files\Microsoft SDKs\Windows\v1.0.\bin
At the command prompt, launch the tool using the following format.
svcutil.exe /t:metadata <url>* | <epr>
You must specify the
/t:metadataoption to download metadata. Otherwise, client code and configuration are generated.
url>argument specifies the URL to a service endpoint that provides metadata or to a metadata document hosted online. The <
epr> argument specifies the path to an XML file that contains a WS-Addressing
EndpointAddressfor a service endpoint that supports WS-MetadataExchange.
For more options about using this tool for metadata download, see ServiceModel Metadata Utility Tool (Svcutil.exe).
The following command downloads metadata documents from a running service.
svcutil /t:metadata http://service/metadataEndpoint