摘要:[WCF][CF] NetCFSvcUtil.exe 使用說明
Microsoft (R) .NET Compact Framework Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.5.0.0]
Copyright (c) Microsoft Corporation. All rights reserved.
USES:
- Generate code from running services or static metadata documents.
- Export metadata documents from compiled code.
- Validate compiled service code.
- Download metadata documents from running services.
-= COMMON OPTIONS =-
Options:
/target:<output type> - The target output for the tool: code or metadata.
/directory:<directory> - Directory to create files in (default: current directory) (Short Form: /d)
/svcutilConfig:<configFile> - Custom configuration file to use in place of the app config file. This can be used to register system.serviceModel extensions without altering the tool's config file.
/noLogo - Suppress the copyright and banner message.
/help - Display command syntax and options for the tool. (Short Form: /?)
-= CODE GENERATION =-
Description: NetCFSvcUtil.exe can generate code for service contracts, clients and data types from metadata documents. These metadata documents can be on disk or retrieved online. Online retrieval follows either the WS-Metadata Exchange protocol or the DISCO protocol.
Syntax: NetCFSvcUtil.exe [/t:code] <metadataDocumentPath>* | <url>* | <epr>
<metadataDocumentPath> - The path to a metadata document (wsdl or xsd). Standard command-line wildcards can be used in the file path.
<url> - The URL to a service endpoint that provides metadata or to a metadata document hosted online. For more information on how these documents are retrieved see the Metadata Download section.
<epr> - The path to an XML file that contains a WS-Addressing EndpointReference for a service endpoint that supports WS-Metadata Exchange. For more information see the Metadata Download section.
Options:
/out:<file> - The filename for the generated code. Default: derived from the WSDL definition name, WSDL service name or targetNamespace of one of the schemas. (Short Form: /o)
/cfClientBase:<file> - The filename for the generated CFClientBase support code. Default: CFClientBase.cs. (Short Form: /cb)
/language:<language> - The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /l)
/namespace:<string,string> - A mapping from a WSDL or XML Schema targetNamespace to a CLR namespace. Using the '*' for the targetNamespace maps all targetNamespaces without an explicit mapping to that CLR namespace. Default: derived from the target namespace of the schema document for Data Contracts. The default namespace is used for all other generated types. (Short Form: /n)
/messageContract - Generate Message Contract types. (Short Form: /mc)
/enableDataBinding - Implement the System.ComponentModel.INotifyPropertyChanged interface on all Data Contract types to enable data binding. (Short Form: /edb)
/serializable - Generate classes marked with the Serializable Attribute. (Short Form: /s)
/internal - Generate classes that are marked as internal. Default: generate public classes. (Short Form: /i)
/reference:<file path> - Reference types in the specified assembly. When generating clients, use this option to specify assemblies that might contain types representing the metadata being imported. (Short Form: /r)
/collectionType:<type> - A fully-qualified or assembly-qualified name of the type to use as a collection data type when code is generated from schemas. (Short Form: /ct)
/excludeType:<type> - A fully-qualified or assembly-qualified type name to exclude from referenced contract types. (Short Form: /et)
/noStdLib - Do not reference standard libraries. By default mscorlib.dll and system.servicemodel.dll are referenced.
-= METADATA EXPORT =-
Description: NetCFSvcUtil.exe can export metadata for services, contracts and data types in compiled assemblies. To export metadata for a service, you must use the /serviceName option to indicate the service you would like to export. To export all Data Contract types within an assembly use the /dataContractOnly option. By default metadata is exported for all Service Contracts in the input assemblies.
Syntax: NetCFSvcUtil.exe [/t:metadata] [/serviceName:<serviceConfigName>] [/dataContractOnly] <assemblyPath>*
<assemblyPath> - The path to an assembly that contains services, contracts or Data Contract types to be exported. Standard command-line wildcards can be used to provide multiple files as input.
Options:
/serviceName:<serviceConfigName> - The config name of a service to export. If this option is used, an executable assembly with an associated config file must be passed as input. NetCFSvcUtil will search through all associated config files for the service configuration. If the config files contain any extension types, the assemblies containing these types must either be in the GAC or explicitly provided using the /r option.
/reference:<file path> - Add the specified assembly to the set of assemblies used for resolving type references. If you are exporting or validating a service that uses 3rd-party extensions (Behaviors, Bindings and BindingElements) registered in config use this option to locate extension assemblies that are not in the GAC. (Short Form: /r)
/dataContractOnly - Operate on Data Contract types only. Service Contracts will not be processed. (Short Form: /dconly)
/excludeType:<type> - The fully-qualified or assembly-qualified name of a type to exclude from export. This option can be used when exporting metadata for a service or a set of service contracts to exclude types from being exported. This option cannot be used with the /dconly option. (Short Form: /et)
-= SERVICE VALIDATION =-
Description: Validation is useful to detect errors in service implementations without hosting the service. You must use the /serviceName option to indicate the service you would like to validate.
Syntax: NetCFSvcUtil.exe /validate /serviceName:<serviceConfigName> <assemblyPath>*
<assemblyPath> - The path to an assembly containing service types to be validated. The assembly must have an associated config file to provide service configuration. Standard command-line wildcards can be used to provide multiple assemblies.
Options:
/validate - Validate a service implementation. To validate a service, you must use the /serviceName option to indicate the service you would like to validate. If this option is used, an executable assembly with an associated config file must be passed as input. (Short Form: /v)
/serviceName:<serviceConfigName> - The config name of a service to validate. To validate a service this option must be provided. NetCFSvcUtil will search through the associated config files of all input assemblies for the service configuration. If the associated configuration file contain any extension types, the assemblies containing these types must either be in the GAC or explicitly provided using the /r option.
/reference:<file path> - Add the specified assembly to the set of assemblies used for resolving type references. If you are exporting or validating a service that uses 3rd-party extensions (Behaviors, Bindings and BindingElements) registered in config use this option to locate extension assemblies that are not in the GAC. (Short Form: /r)
/dataContractOnly - Operate on Data Contract types only. Service Contracts will not be processed. (Short Form: /dconly)
/excludeType:<type> - The fully-qualified or assembly-qualified name of a service type to exclude from validation. (Short Form: /et)
-= METADATA DOWNLOAD =-
Description: NetCFSvcUtil.exe can be used to download metadata from running services and save the metadata to local files. To download metadata, you must explicitly specify the /t:metadata option. Otherwise, client code will be generated. For http and https URL schemes netcfsvcutil.exe will try to retrieve metadata using WS-Metadata Exchange and DISCO. For all other URL schemes NetCFSvcUtil.exe will only try WS-Metadata Exchange. By default, NetCFSvcUtil.exe uses the bindings defined in the System.ServiceModel.Description.MetadataExchangeBindings class. To configure the binding used for WS-Metadata Exchange you must define a client endpoint in config that uses the IMetadataExchange contract. This can be defined either in NetCFSvcUtil.exe's config file or in another config file specified using the /svcutilConfig option.
Syntax: NetCFSvcUtil.exe /t:metadata <url>* | <epr>
<url> - The URL to a service endpoint that provides metadata or an URL that points to a metadata document hosted online.
<epr> - The path to an XML file that contains a WS-Addressing EndpointReference for a service endpoint that supports WS-Metadata Exchange.
-= EXAMPLES =-
netcfsvcutil http://service/metadataEndpoint
- Generate client code from a running service or online metadata documents.
netcfsvcutil *.wsdl *.xsd /language:C#
- Generate client code from local metadata documents.
netcfsvcutil /t:metadata http://service/metadataEndpoint
- Download metadata documents from running services
netcfsvcutil myAssembly.dll
- Generate metadata documents for Service Contracts and associated types in an assembly
netcfsvcutil myServiceHost.exe /serviceName:myServiceName
- Generate metadata documents for a service, and all associated Service Contracts and data types in an assembly