[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
The Silverlight Service Model Proxy Generation Tool is used to generate Silverlight proxy classes from service metadata documents.
Common Usages
The following table shows some commonly used options for this tool.
| Option | Description |
|---|
/directory:<directory> | Directory to create files in.
Default: The current directory.
Short form: /d |
/help | Displays the command syntax and options for the tool.
Short form: /? |
/noLogo | Suppresses the copyright and banner message. |
/slsvcutilConfig:<configFile> | Specifies a custom configuration file to use instead of the App.config file. This can be used to register System.serviceModel extensions without altering the tool's configuration file. |
Code Generation
Slsvcutil.exe can generate code for service contracts, clients, and data types from metadata documents. These metadata documents can be on a durable storage, or be retrieved online. Online retrieval follows either the WS-Metadata Exchange protocol or the DISCO protocol. (For more information, see the Metadata Download section.)
Caution: |
|---|
| Svcutil.exe generates the client based on the WSDL or policy file received from the service. The user principal name (UPN) is generated by concatenating username, "@", and a fully qualified domain name (FQDN). However, for users who registered on Active Directory, this format is not valid and the UPN generated by the tool causes a failure in Kerberos authentication with the error message "The logon attempt failed". To resolve this problem, you should manually fix the client file generated by this tool. |
svcutil.exe <metadataDocumentPath>* | <url>* | <epr>
| Option | Description |
|---|
epr | The path to an XML file that contains a WS-Addressing EndpointReference for a service endpoint that supports WS-Metadata Exchange. |
metadataDocumentPath | The path to a metadata document (wsdl or xsd) that contains the contract to import into code (.wsdl, .xsd, .wspolicy, or .wsmex).
Slsvcutil follows imports and includes when you specify a remote URL for metadata. However, if you want to process metadata files on the local file system, you must specify all files in this argument. In this way, you can use Slsvcutil in a build environment where you cannot have network dependencies. You can use wildcards (for example, *.xsd or *.wsdl) for this argument. |
url | The URL to a service endpoint that provides metadata or to a metadata document hosted online. For more information about how these documents are retrieved, see the Metadata Download section. |
| Option | Description |
|---|
/collectionType:<type> | Specifies a fully qualified name or assembly-qualified name of the type to be used as a collection data type, when code is generated from schemas.
Short Form: /ct |
/config:<configFile> | Specifies the file name for the generated configuration file.
Default: output.config |
/enableDataBinding | Implements the INotifyPropertyChanged interface on all Data Contract types to enable data binding.
Short Form: /edb |
/excludeType:<type> | Specifies a fully qualified name or assembly-qualified type name to be excluded from referenced contract types.
When using this switch together with /r from separate DLLs, the full name of the XSD class is referenced.
Short Form: /et |
/internal | Generates classes that are marked as internal. Default: generate public classes only.
Short Form: /i |
/language:<language> | Specifies the programming language to use for code generation. You should provide either a language name registered in the Machine.config file, or the fully qualified name of a class that inherits from CodeDomProvider.
Values: c#, cs, csharp, vb, visualbasic
Default: csharp
Short form: /l |
/mergeConfig | Merges the generated configuration into an existing file, instead of overwriting the existing file. |
/messageContract | Generates Message Contract types.
Short Form: /mc |
/namespace:<string,string> | Specifies a mapping from a WSDL or XML Schema targetNamespace to a CLR namespace. Using '*' for the targetNamespace maps all targetNamespaces without an explicit mapping to that CLR namespace.
To ensure that the message contract name does not collide with operation name, you should either qualify the type reference with ::, or make sure the names are unique.
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 |
/noConfig | Do not generate configuration files. |
/noStdLib | Do not reference standard libraries.
Default: Mscorlib.dll and System.servicemodel.dll are referenced. |
/out:<file> | Specifies the file name for the generated code.
Default: Derived from the WSDL definition name, WSDL service name, or target namespace of one of the schemas.
Short form: /o |
/reference:<file path> | References types in the specified assembly. When generating clients, use this option to specify assemblies that might contain types that represent the metadata being imported.
You cannot specify message contracts and XmlSerializer types using this switch.
Short Form: /r |
/serializer:Auto | Automatically selects the serializer. This uses the Data Contract serializer. If this fails, the XmlSerializer is used.
Short Form: /ser:Auto |
/serializer:DataContractSerializer | Generates data types that use the Data Contract Serializer for serialization and deserialization.
Short Form: /ser:DataContractSerializer |
/serializer:XmlSerializer | Generates data types that use the XmlSerializer for serialization and deserialization.
Short Form: /ser:XmlSerializer |
| |
| |
| |
Examples
The following command generates client code from a running service or online metadata documents.
slsvcutil http://example.com/service.svc?wsdl
The following command generates client code in Visual Basic from local metadata documents.
slsvcutil *.wsdl *.xsd /language:VB
The following command generates client code from a running service using settings that emulate the default “Add Service Reference” behavior.
slsvcutil http://example.com/service.svc?wsdl /edb /namespace:"*,SilverlightApplication1.ServiceReference1" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"c:\Program Files\Microsoft Silverlight\3.0.#####\System.Windows.dll"
Copyright © 2009 by Microsoft Corporation. All rights reserved.