Using the ServiceModel Metadata Utility Tool with the BizTalk Adapter for mySAP Business Suite
You can use the ServiceModel Metadata Utility Tool (svcutil.exe) to generate a WCF client class or a WCF service contract (interface) for operations that the Microsoft BizTalk Adapter 3.0 for mySAP Business Suite exposes. After you run svcutil.exe to generate either a WCF client class or a WCF service contract, you can include the generated file in your code and create instances of the generated class or implement a WCF service from the generated interface to perform operations on the SAP system.
Using svcutil.exe requires you to supply a connection URI that contains credentials. Because, by default, the SAP adapter disables credentials in the connection URI, you must configure svcutil.exe to use a non-default binding for the SAP adapter. You can also configure other binding properties in the non-default binding; for example, to create a WCF client for BAPI operations, you must set the EnableBusinessObjects binding property to true.
The following sections show you how to configure svcutil.exe and how to use svcutil.exe to generate WCF client code or a WCF service contract with the SAP adapter.
To configure svcutil.exe to use a non-default binding, you must create a local copy of svcutil.exe and then create or modify a local copy of the svcutil.exe.config configuration file.To configure svcutil.exe for a non-default binding
Create a folder, and copy svcutil.exe into the new folder. You can typically find svcutil.exe at the Windows SDK installation location, specifically, C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin.
Create a file named svcutil.exe.config in the new folder.
Add a binding and a client endpoint to the svcutil.exe.config file. You must run svcutil.exe from the new folder to ensure that the correct configuration is used.
Important The name attribute of the client endpoint must specify the scheme used in the connection URI. This value is case-sensitive.
<configuration> <system.serviceModel> <client> <!-- the name should match the required scheme of the WS-Metadata Exchange endpoint and the contract should be "IMetadataExchange" --> <endpoint name="sap" binding="sapBinding" bindingConfiguration="SAPBinding" contract="IMetadataExchange" /> </client> <bindings> <sapBinding> <binding name="SAPBinding" acceptCredentialsInUri="true"/> </sapBinding> </bindings> </system.serviceModel> </configuration>
You can set any of the binding properties of the SAP adapter in the binding configuration. For example, you could specify the following non-default binding to use svcutil.exe to generate a WCF client for BAPI operations.
<bindings> <sapBinding> <binding name="SAPBinding" acceptCredentialsInUri="true"/> </sapBinding> </bindings>
For more information about configuring a non-default binding for svcutil.exe, see the "Custom Secure Metadata Endpoint" topic in the WCF documentation at http://go.microsoft.com/fwlink/?LinkId=96077.
To use svcutil.exe to generate WCF client code or a WCF service contract (interface) for the SAP adapter, you must supply a connection URI that specifies a WS-Metadata Exchange (MEX) endpoint and the operation or operations for which you want svcutil.exe to generate code. You must also specify connection credentials for the SAP system in the connection URI.
|Before you can use svcutil.exe with the SAP adapter, you must configure it to use a non-default binding; for information about how to do this, see Configuring svcutil.exe for the SAP Adapter.|
You specify a MEX endpoint and target operations in the SAP adapter connection URI in the following manner:
You must include the "wsdl" parameter in the query string. If it is the first parameter in the query string, it is specified just after the question mark (?). If it is not the first parameter, it should be preceded with an ampersand (&).
You must follow the "wsdl" parameter by one or more "op" parameters. Each "op" parameter is preceded by an ampersand (&) and specifies the node ID of a target operation.
The following three examples show how to target various operations by using svcutil.exe.
This example creates a WCF client class for RFC_CALCULATE_TAXES.
This example creates a WCF client class for both the SALESORDER_CREATEFROMDAT201 and SALESORDER_CREATEFROMDAT202 IDOC.
This example creates a WCF service contract to receive the SALESORDER_CREATEFROMDAT201 IDOC from the SAP system. The NODE ID specifies a Receive operation. Because this example deals with retrieving metadata, there is no need to specify the listener parameters in the query_string of the connection URI.
|You must place the connection URI in quotation marks on the command line. Otherwise, svcutil.exe attempts to retrieve metadata for operations that the SAP adapter does not support. The results of such an attempt are undefined.|
By default, svcutil.exe places the generated code in the output.cs file; however, you can change the name of the output file and many other options that svcutil.exe uses by setting command-line switches. For more information about the options that svcutil.exe supports, see the "ServiceModel Metadata Utility Tool (Svcutil.exe)" topic in the WCF documentation at http://go.microsoft.com/fwlink/?LinkId=72777.
Svcutil.exe does not provide the capability to search for operations (for example, by using wildcard characters). You must explicitly specify node IDs for the specific operations you want to target. The node ID of an operation is equivalent to its message action string. You cannot specify node IDs that refer only to categories. For more information about the node IDs that the SAP adapter surfaces, see Metadata Node IDs.
The Add Adapter Service Reference Visual Studio Plug-in provides advanced browse and search capabilities that can greatly simplify generating a WCF client class and WCF service contract. For more information about the Add Adapter Service Reference Plug-in, see Generating a WCF Client or a WCF Service Contract for SAP Artifacts.