Editar

Partilhar via


Generate a WCF client or a WCF service contract for SAP solution artifacts

You can use the Add Adapter Service Reference Visual Studio Plug-in to generate a WCF client class or a WCF service contract (interface) targeted at selected operations on SAP artifacts. You can also use the ServiceModel Metadata Utility Tool (svcutil.exe) to generate the WCF client class or WCF service contract; however, the Add Adapter Service Reference Plug-in exposes the functionality of the ServiceModel Metadata Utility Tool through a standard Microsoft Windows interface. It also provides browse and search capabilities that are not available with the svcutil.exe tool, and generates a configuration file based on the binding properties that you select when you connect to the SAP system.

Generating a Client Class by Using the Add Adapter Service Reference Plug-in

Perform the following steps to generate a WCF client class by using the Add Adapter Service Reference Plug-in.

To generate a WCF client class

  1. In Visual Studio Solution Explorer, right-click your project, and then click Add Adapter Service Reference.

  2. After the Add Adapter Service Reference dialog box opens, follow the steps in Get Metadata for SAP Operations in Visual Studio to connect to the SAP system and browse and search for operations. To create a WCF client class for the operations that you select, be sure that Client (Outbound operations) is selected from the Select contract type drop-down list (this is the default).

  3. After you select all of the operations that you want to target, click OK to generate the WCF client class.

    The Add Adapter Service Reference Plug-in adds two files to your project:

  • SAPBindingClient.cs. This file contains the generated WCF client class and helper code for the operations that you selected.

  • App.config. This file contains a binding configuration and client endpoint configurations. The settings are based on the selections you made when you configured the binding and connection for the Add Adapter Service Reference Plug-in.

    Important

    While using the Add Adapter Service Reference Plug-in, if you do not specify a value for a binding property of type string and whose default value is null then that binding property will not be available in the app.config file. You must manually add the binding property and its value in the app.config file, if required.

Generating a WCF Service Contract by Using the Add Adapter Service Reference Plug-in

When you use the SAP adapter to receive IDOCs, RFCs, and tRFCs from the SAP system, your code acts as a service to the adapter. That is, the adapter receives the appropriate artifact from the SAP system and then invokes an (inbound) operation on your code to deliver the artifact to your application.

You must, therefore, implement a WCF service that can receive this inbound operation from the adapter. To do this, you use the Add Adapter Service Reference Plug-in to generate a .NET interface that represents the service contract that is surfaced by the adapter for the operation. This .NET interface is also called a WCF service contract. The Add Adapter Service Reference Plug-in also generates a class that contains a stubbed implementation of the WCF service. You then implement this interface to create the WCF service that you can use to receive the operation.

Perform the following steps to generate a WCF service contract by using the Add Adapter Service Reference Plug-in.

To generate a WCF service contract

  1. In Visual Studio Solution Explorer, right-click your project, and then click Add Adapter Service Reference.

  2. After the Add Adapter Service Reference dialog box opens, follow the steps in Get Metadata for SAP Operations in Visual Studio to connect to the SAP system and browse and search for operations. To create a WCF service contract for the operations that you select, be sure that Service (Inbound operations) is selected from the Select contract type drop-down list.

  3. After you select all of the operations that you want to target, click OK to generate the WCF service contract.

    The Add Adapter Service Reference Plug-in adds three files to your project:

  • SAPBindingInterface.cs. This file contains the generated WCF service contract (interface) and helper code for the operations that you selected.

  • SAPBindingService.cs. This file contains a stubbed WCF service class that implements the interface defined in SAPBindingInterface.cs. You can implement the business logic that processes the RFC, tRFC or IDOC directly in the methods of this class.

  • App.config. This file contains a binding configuration, endpoint behaviors, and service endpoint configuration that are based on the selections you made when you configured the binding and connection for the Add Adapter Service Reference Plug-in.

    Important

    While using the Add Adapter Service Reference Plug-in, if you do not specify a value for a binding property of type string and whose default value is null then that binding property will not be available in the app.config file. You must manually add the binding property and its value in the app.config file, if required.

Note

You do not have to specify RFC Server parameters when you configure the connection URI for the Add Adapter Service Reference Plug-in to generate the WCF service contract. The SAP adapter retrieves metadata from the SAP system through a client connection.

Generate a WCF Client Class or a WCF Service Contract by Using svcutil.exe

You can use svcutil.exe to generate a WCF client class or a WCF service contract for your application. You must configure svcutil.exe to use it with the SAP adapter. For more information about configuring and using svcutil.exe with the SAP adapter, see Using the ServiceModel Metadata Utility Tool with the BizTalk Adapter for mySAP Business Suite.

Svcutil.exe generates the WCF client class or WCF service contract in an output file. The default file name is output.cs. You must manually include this file in your Visual Studio project.

See Also

Develop SAP applications using the WCF Channel Model