Freigeben über


Adapter Proxy Generation Advanced Options

In WCF programming model, one of the usage of ServiceModel Metadata Utility Tool (Svcutil.Exe) is to generate WCF service proxy files from static metadata documents (WSDL / XML Schema) or from running services. Use the command “svcutil /?” to see the list of options supported by this utility.

In the Adapter SDK, the Add Adapter Service Reference Visual Studio Plug-In is used to generate a WCF client proxy after the Adapter Consumer has browsed, searched and selected the operations she is interested in. Just like one can provide advanced options in Svcutil.Exe to control the output, Add Adapter Service Reference Visual Studio Plug-In provides an Advanced Dialog to allow the user to generate appropriate proxy file.

Following table maps the Advanced Options to Svcutil.Exe commands and provides examples showing the impact on the generated WCF service proxy.

Advanced Options

“svcutil.exe” Option

Description

Expected Outcome

Generate asynchronous methods

/async

Generate both synchronous and asynchronous method signatures.

Default (if not selected): generate only synchronous method signatures.

public interface IService1

{

[System.ServiceModel.OperationContractAttribute(Action="https://tempuri.org/IService1/MyOperation1", ReplyAction="https://tempuri.org/IService1/MyOperation1Response")]

string MyOperation1(string myValue);

   

[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="https://tempuri.org/IService1/MyOperation1", ReplyAction="https://tempuri.org/IService1/MyOperation1Response")]

System.IAsyncResult BeginMyOperation1(string myValue, System.AsyncCallback callback, object asyncState);

string EndMyOperation1(System.IAsyncResult result);

...

Generate message contracts

/messageContract

Generate message contract types.

Default

[System.ServiceModel.OperationContractAttribute(Action="https://tempuri.org/IService1/MyOperation1", ReplyAction="https://tempuri.org/IService1/MyOperation1Response")]

string MyOperation1(string myValue);

With Message Contract Option

[System.ServiceModel.OperationContractAttribute(Action="https://tempuri.org/IService1/MyOperation1", ReplyAction="https://tempuri.org/IService1/MyOperation1Response")]

MyOperation1Response MyOperation1(MyOperation1Request request);

[System.ServiceModel.MessageContractAttribute(WrapperName="MyOperation1", WrapperNamespace="https://tempuri.org/", IsWrapped=true)]

public partial class MyOperation1Request

{

Make types internal

/internal

Generate classes that are marked as internal.

Default (if not selected): generate public classes.

Default

public interface IService1…

public interface IService1Channel : IService1, System.ServiceModel.IClientChannel…

public partial class Service1Client : System.ServiceModel.ClientBase<IService1>, IService1…

With Internal Option

internal interface IService1…

internal interface IService1Channel : IService1, System.ServiceModel.IClientChannel…

internal partial class Service1Client : System.ServiceModel.ClientBase<IService1>, IService1…

Enable data binding

/enableDataBinding

Implement the System.ComponentModel.INotifyPropertyChanged interface on all Data Contract types to enable data binding.

Default

[System.Runtime.Serialization.DataContractAttribute()]

public partial class DataContract1 : object, System.Runtime.Serialization.IExtensibleDataObject

With Enable Data Binding option

public partial class DataContract1 : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged

Import non-data types as IXmlSerializable

/importXmlTypes

Configure the Data Contract serializer to import non-Data Contract types as IXmlSerializable types.

If the XML Schema metadata file is not a valid data contract schema, for example, the schema may involve XML attributes which are not supported in the data contract model, you can import the schema as IXmlSerializable types. This is enabled by the /importXmlTypes switch.

public class Person : IXmlSerializable

Generate channel interface

Generates the channel interface

Here is the code that gets generated in the proxy file:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]

public interface MyServiceInterfaceChannel :

                 MyServiceInterface,

                 System.ServiceModel.IClientChannel

{

}

Mark classes serializable

N/A

Select whether to generate the data types with a serializer.

This option enables the type of serializer to use for the generated proxy. The serializers contain mapping algorithms for mapping between .NET objects and XML.

DataContractSerlializer is the default.

The following white paper explains in detail the serialization concepts.

https://msdn.microsoft.com/msdnmag/issues/06/08/ServiceStation/default.aspx

Do not generate app.config

/noConfig

Do not generate application configuration file

Default: Generate app.config

Serializer

Auto

/serializer:Auto

Automatically select the serializer for serialization and deseralization

This option let’s the tool pick the best option depending on the type of WSDL and XML Schema.

Serializer

DataContract Serializer

/serializer:DataContractSerializer

Generate data types that use the Data Contract Serializer for serialization / de-serialization

The following white paper explains in detail the serialization concepts.

https://msdn.microsoft.com/msdnmag/issues/06/08/ServiceStation/default.aspx

Serializer

XmlSerializer

/serializer:XmlSerializer

Generate data types that use the XmlSerializer for serialization / de-serialization

Default

namespace MyNamespace

{

    using System.Runtime.Serialization;

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]

    [System.Runtime.Serialization.DataContractAttribute()]

    public partial class DataContract1 : object, System.Runtime.Serialization.IExtensibleDataObject

}

[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IService1")]

public interface IService1

{

     [System.ServiceModel.OperationContractAttribute(Action="https://tempuri.org/IService1/MyOperation2", ReplyAction="https://tempuri.org/IService1/MyOperation2Response")]

    string MyOperation2(EightBall.DataContract1 dataContractValue);

}

With XmlSerializer Option

The data structure is not decorated with the [DataContractAttribute], but [XmlTypeAttribute]

[System.Xml.Serialization.XmlTypeAttribute(Namespace="https://schemas.datacontract.org/2004/07/EightBall")]

public partial class DataContract1

The input and output message of the operation is wrapped in a separate class and decorated with [MessageContractAttribute]. The properties within the message class has [XmlElementAttribute] attribute.

public partial class MyOperation1Request

{

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="https://tempuri.org/", Order=0)]

    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]

    public string myValue;…

The operations within the service interface have an attribute of [XmlSerializerFormatAttribute]

public interface IService1

{

    [System.ServiceModel.OperationContractAttribute(Action="https://tempuri.org/IService1/MyOperation1", ReplyAction="https://tempuri.org/IService1/MyOperation1Response")]

    [System.ServiceModel.XmlSerializerFormatAttribute()]

    MyOperation1Response MyOperation1(MyOperation1Request request);

Comments

  • Anonymous
    June 22, 2007
    The Add Adapter Service Reference Visual Studio Plug-In is metadata proxy generation tool shipped with

  • Anonymous
    March 24, 2008
    was very useful,as i dint find theprocess to generate proxies for asyncronous methods anywhere.thanks