How to: Use Svcutil.exe to Export Metadata from Compiled Service Code

Svcutil.exe can export metadata for services, contracts, and data
types in compiled assemblies, as follows:

To export metadata for all compiled service contracts for a set of
assemblies using Svcutil.exe, specify the assemblies as input
parameters. This is the default behavior.

To export metadata for a compiled service using Svcutil.exe, specify
the service assembly or assemblies as input parameters. You must use
the /serviceName option to indicate the configuration name of the
service you want to export. Svcutil.exe automatically loads the
configuration file for the specified executable assembly.

To export all data contract types within a set of assemblies, use the
/dataContractOnly option.

Note:

Use the /reference option to specify the file paths to any dependent assemblies.

How to generating a WCF Client from Service Metadata

Metadata documents can be on a durable storage or be retrieved online.
Online retrieval follows either the WS-MetadataExchange protocol or
the Microsoft Discovery (DISCO) protocol. Svcutil.exe issues the
following metadata requests simultaneously to retrieve metadata:

WS-MetadataExchange (MEX) request to the supplied address.

MEX request to the supplied address with /mex appended.

DISCO request (using the DiscoveryClientProtocol from ASP.NET Web
services) to the supplied address.

Svcutil.exe generates the client based on the Web Services Description
Language (WSDL) or policy file received from the service. The user
principal name (UPN) is generated by concatenating the user name with
"@" and then adding a fully-qualified domain name (FQDN). However, for
users who registered on Active Directory, this format is not valid and
the UPN that the tool generates causes a failure in the Kerberos
authentication with the following error message: The logon attempt
failed. To resolve this problem, manually fix the client file that the
tool generated.

svcutil.exe [/t:code] <metadataDocumentPath>* | <url>* | <epr>