Muokkaa

Jaa


Consume a WCF LOB Adapter SDK adapter in a .NET project

To consume an adapter built using the WCF LOB Adapter SDK from Visual Studio, you must add a service reference to the project. You can do this by:

  • Using the Add Adapter Service Reference Visual Studio Plug-in, which is installed as part of the WCF LOB Adapter SDK.

  • Using svcutil.exe (the ServiceModel Metadata Utility), which is installed as part of the Windows SDK.

Add a Service Reference using the Add Adapter Service Reference Plug-in

The Add Adapter Service Reference Plug-in can be used to browse and search metadata, and to generate .NET CLR proxy classes using the selected operations and types.

  1. Open your .NET application in Visual Studio.

  2. In Visual Studio, right-click the Project menu, and then click Add Adapter Service Reference.

    Note

    This option does not appear for BizTalk Server projects.

  3. In the Add Adapter Service Reference Plug-in screen, from the Select a binding drop-down list, select an adapter binding.

  4. To configure the connection URI for the selected adapter binding and to provide any credentials, URI properties, and binding properties, click Configure. Actual requirements vary based on the selected adapter binding.

  5. When you have configured the URI, click OK.

  6. Click Connect. If the connection URI is valid and client credentials (if any) are accepted, the Category pane should be populated with the categories and operations provided by the adapter.

  7. If the adapter supports search, the search field will be active. Otherwise, you can filter by contract type, explore types, and operations by clicking nodes in the Category pane.

  8. For advanced proxy generation options, click Advanced. Your options include:

    Option Equivalent svcutil.exe option Description
    Generate asynchronous methods /async Generates both synchronous and asynchronous method signatures.

    Default (if not selected): generates only synchronous method signatures.
    Generate message contracts /messageContract Generates message contract types.
    Make types internal /internal Generates classes that are marked as internal.

    Default (if not selected): generate public classes.
    Enable data binding /enableDataBinding Implements the System.ComponentModel.INotifyPropertyChanged interface on all Data Contract types to enable data binding.
    Import non-data types as IXmlSerializable /importXmlTypes Configures the Data Contract serializer to import non-Data Contract types as IXmlSerializable types.
    Generate channel interface Generates the channel interface.
    Mark classes serializable Selects whether to generate the data types with a serializer.
    Do not generate app.config /noConfig Does not generate application configuration file.
    Serializer

    Auto
    /serializer:Auto Automatically selects the serializer for serialization and deseralization.
    Serializer

    DataContract Serializer
    /serializer:DataContractSerializer Generates data types that use the Data Contract Serializer for serialization and de-serialization
    Serializer

    XmlSerializer
    /serializer:XmlSerializer Generates data types that use the XmlSerializer for serialization and deserialization.
  9. To generate the proxy artifacts, click OK. The number of artifacts varies based on the contract type.

    Contract Type Artifact Description
    Outbound CLR WCF Proxy Contains the contract and service implementation.
    Outbound App.config Contains the <endpoint> and <bindings> elements for <system.ServiceModel><client>.
    Inbound CLR WCF service interface Contains the contract.
    Inbound CLR WCF service implementation Stub implementation that derives from the contract.
    Inbound App.config Contains the <endpoint>, <bindings> and <behaviors> elements for <system.ServiceModel><service>.
  10. You can now use the proxy in your application.

Adding a Service Reference by Using svcutil.exe

Svcutil.exe is a command-line utility that can be used to retrieve metadata and generate .NET CLR proxy classes, which can then be added to a Visual Studio project. For more information about svcutil.exe, see ServiceModel Metadata Utility Tool (Svcutil.exe).

To generate a proxy class from an adapter hosted in IIS

  1. At the command prompt, enter svcutil.exe “<http://localhost/adapter/AdapterService.svc?wsdl”> /config:app.config. Replace the HTTP path with the correct path for your hosted adapter. This creates a .cs file that contains the .NET CLR proxy and output.config which contains the <bindings> and client <endpoint> for <system.serviceModel>.

    Note

    If your adapter contains many operations, you can limit the operations returned by using a query string of ‘op=’ followed by the name of the operation in which you are interested. For example: svcutil.exe “http://localhost/adapter/AdapterService.svc?wsdl&op=Echo/EchoString&op=Echo/EchoArray” generates proxy code for only the EchoString and EchoArray operations.

  2. Open your project in Visual Studio.

    1. In Solution Explorer, right-click the project, point to Add, and then click New Item. In the Add Existing Item dialog box, select the .cs and app.config files created previously. Click Add.

    2. In Solution Explorer, right-click References, and then click Add Reference. On the .NET tab, select System.ServiceModel, and then click OK. You can now use the proxy in your application.

See Also

Tutorial 1: Develop the Echo Adapter
Consume an Adapter created using the WCF LOB Adapter SDK