+ All Categories
Home > Documents > GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being...

GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being...

Date post: 03-Aug-2021
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
17
1 Welcome to this presentation about SAP NetWeaver Gateway Productivity Accelerator for Microsoft (GWPAM). We will cover how to Add a SAP Service Reference to a new or existing Visual Studio project.
Transcript
Page 1: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

1

Welcome to this presentation about SAP NetWeaver Gateway Productivity Accelerator for Microsoft (GWPAM). We will cover how to Add a SAP Service Reference to a new or existing Visual Studio project.

Page 2: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

2

Page 3: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

In this presentation, the following topics will be covered: First we will provide an overview of the Add SAP Service Reference feature. Then we will cover a step-by-step explanation of how to use the feature along an example. The steps are: Step 1: Choose a New Visual Studio Project Step 2: Add a SAP Service Reference Step 3: Explain the Generated Proxy Classes Step 4: Add UI Elements and Coding to Trigger Query Operation Step 5: Test your Project Lastly we will cover additional topics, e.g. when the OData service changes at a later time.

3

Page 4: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

Let’s take a close look at the Add SAP Service Reference feature. When should you use this feature? You want to create a Windows application that interacts with a SAP NetWeaver Gateway Service What does it actually do? It adds a reference of a SAP NetWeaver Gateway Service into your Visual Studio project. It generates Proxy, Extension and Helper Classes for the Service and adds them to your project. You can use it for new or existing Visual Studio projects, but they have to be Visual C# projects. Why should you use this feature? It helps you to simplify your development. You can use the Proxy Classes to quickly add coding to trigger OData service operations. Furthermore it provides Connectivity Helper classes, that abstract the connectivity between your application and the OData service. It leverages the SAP Annotations (a.k.a. SAP Extensions) to the OData protocol, like Labels for Entity Type properties. Also, the GWPAM Logging framework is integrated with the Proxy Classes.

4

Page 5: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

5

Next we will explain step-by-step how to add a SAP Service Reference to your project. To do this we will use the following business scenario as an example: You have been asked to create a Windows application that provides a simple list of Business Partners coming from an SAP system. There is already OData service GWDEMO available, which is exposing this information through the BusinessPartnerCollection. Prerequisites: If you want to build this sample application in your own landscape you have to ensure that the GWDEMO service is registered (via transaction /iwfnd/maint_service). Ideally first test it with the help of the Gateway Client tool (transaction /iwfnd/gw_client). If the BusinessPartnerCollection does not return any data then run transaction SEPM_DG to generate some sample data.

Page 6: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

In the first step you either open an existing Visual Studio project or create a new one. This is going to be the place where you will be adding the SAP Service Reference. Keep in mind that it needs to be a Visual C# project. As for the type, you can choose any type, like Console Application. For the example, we are choosing the Visual C# template Windows Forms Application.

6

Page 7: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

In the second step, now you add the SAP Service Reference. In the Solution Explorer window, right-click on your application and from the context menu choose Add SAP Service Reference. A new window opens offering you two choices: • You can either choose the Explore Services option, which will let you browse

through the catalog of available service or • You can choose the Add Services option. Here you have to provide the URL for the

service.

We will explore both option in more detail on the next slides.

7

Page 8: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

When using the Explore Service option you will be prompted to provide the system information for your SAP NetWeaver Gateway system. Furthermore you need to authenticate to retrieve the Services Catalog. The Explore Service option is great if you do not know the URL of the OData service or if you are not sure which OData services are available. 1. First scan through the list of available services and select one. If you are not sure

which service to use then click the View Service button to get more details including the metadata definition of the service.

2. Next, verify the Proxy Name. It will determine the name of the proxy classes to be generated. Also, keep in mind that if proxy classes with the same name already exist then they will be overwritten.

3. Now click the Generate Proxy button to initiate the generation process.

8

Page 9: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

Besides the Explore Service option you can also choose the Add Services option to add a proxy for any OData service. To use this option you need to know the URL for the OData service. 1. First, enter the URL. 2. Then click the GO button. At this point the service’s Metadata document is being

retrieved and you might have to authenticate. Once retrieved, the metadata is presented to you for your verification.

3. Next check the Proxy Name. If proxy classes with the same name already exist then they will be overwritten.

4. Now click the OK button and the proxy classes will be generated.

On the next slides we will explain what objects are exactly being generated.

9

Page 10: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

The proxy generation will make the following changes to your Visual Studio project: References Three references to GWPAM assemblies are added. These assemblies contain classes that will help with a variety of tasks, like reading the App.config file or providing Single Sign On capabilities. Proxy and Extension classes The <Proxy Name>.cs contains the proxy classes matching the Entity Sets defined in the metadata document of your service. Example: Here you will find class BusinessPartner, which contains all the properties of the Business Partner Entity Set of your OData service. The Extension classes provide handling of SSO, SAP Client and SAP Annotations. Example: If you maintained Labels for your properties in the Service Builder, then these SAP Annotations can be found here and can be accessed in your coding via the SAPPropertyAttributes. More details for each assembly and class have been provided on this slide and can be found in the Development Guide. Other classes and objects are generated which will be explained on the next slide.

10

Page 11: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

In addition to the references and the proxy classes the following classes and objects are being generated: 1. BusinessConnectivityHelper Class: This class handles the connectivity and

authentication to the OData endpoint. If you are using BASIC authentication then you should set a User ID and Password in method HandleSAPConnectivity().

2. App.config: This file contains important configuration settings like the URL of the OData service, the authentication mode and logging settings.

3. ADM file: This file can be used to configure your Global Group Policies. 4. Logger Class: This class provides an API to log necessary information to the Event

Viewer or local file.

11

Page 12: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

Now that all the required references and proxy classes are available, let’s take a look at the changes required to call the OData service to trigger a Query operation. We will make the following changes: • Add UI elements to display the OData Query result and • Add coding to trigger the OData operation and process the result.

First add the following UI elements to the main form of your Windows Forms Application: • First add a DataGridView element, which will be used to display the result. Here we

set the name of the element to dgvBusinessPatner, which you should do too if you want to use the coding provided later.

• Next add a Button, which will be used to trigger the OData Query call. We named it btGetData.

Next, double-click on the button to automatically navigate to the method btGetData_Click(), which is triggered upon a click on the button.

12

Page 13: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

Next we are adding the required coding to the button-click event. The method here is called btGetData_Click(). Copy and paste the coding into your method. Here a high-level explanation on what the coding is doing: • In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps to retrieve the

OData service URL. • Next the service context for your OData service is prepared. Here the URL of the

OData service is required. • The Query operation for the BusinessPartnerCollection is being triggered and the

results are being processed in the foreach() loop. Note: If you chose a Proxy Name different than GWDEMO, then you need to adjust the coding in a number of places.

13

Page 14: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

Now you are ready to test your application. You need to decide on the authentication mode, which can be set in the App.config file. You can choose from Basic Authentication, SAML, or X.509. • For Basic Authentication you should specific a user in the HandleSAPConnectivity()

method of class BusinessConnectivityHelper. • If you are using SAML or X.509 then make sure that the required configurations are

in place.

Build your project and watch out that there are no build error. Next start to debug your application or launch it from the executable. Once you click on the Get Data button the Query operation of the OData service is being triggered. If successful, then you should see the data being displayed in the data grid. If errors occur then you should find them in the Application log of the Even Viewer. The logging behavior can be adjusted through configuration in the App.config file. This concludes the development of our sample application.

14

Page 15: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

Let’s take a look at one additional topic for the Add SAP Service Reference topic. We’ll briefly discuss what to do in the case that the service in your SAP NetWeaver Gateway system changes or if there is a newer version of the service after your initial generation. In this case you simply re-run the Add SAP Service Reference feature again. Here you should consider two options: 1. You can choose the same Proxy Name that you chose during the initial run. The

original proxy and extension classes will be overwritten. When you build your project you might see some syntax errors depending on the changes of the service. Example: The data type of a property has changed which might force you to change your coding and implement a proper type casting.

2. You can choose a new Proxy Name, e.g. choose name GWDEMO_V2 to distinguish it from version 1. This will result in an additional set of proxy and extension classes. Now you will have to carefully adjust your coding to ‘migrate’ it over to the new proxy.

15

Page 16: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

16

This concludes the presentation about the Add a SAP Service Reference feature of SAP NetWeaver Gateway Productivity Accelerator for Microsoft.

Page 17: GWPAM Add SAP Service Reference...• In a first step the file path to the App.config file is being determined. • Next method GetServiceDetails() reads the App.config file and helps

www.sap.com

© 2013 SAP AG. All rights reserved.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP

BusinessObjects Explorer, StreamWork, SAP HANA, and other SAP

products and services mentioned herein as well as their respective

logos are trademarks or registered trademarks of SAP AG in Germany

and other countries.

Business Objects and the Business Objects logo, BusinessObjects,

Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and

other Business Objects products and services mentioned herein as

well as their respective logos are trademarks or registered trademarks

of Business Objects Software Ltd. Business Objects is an SAP

company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL

Anywhere, and other Sybase products and services mentioned herein

as well as their respective logos are trademarks or registered

trademarks of Sybase Inc. Sybase is an SAP company.

Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are

registered trademarks of Crossgate AG in Germany and other

countries. Crossgate is an SAP company.

All other product and service names mentioned are the trademarks of

their respective companies. Data contained in this document serves

informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials

are provided by SAP AG and its affiliated companies ("SAP Group")

for informational purposes only, without representation or warranty of

any kind, and SAP Group shall not be liable for errors or omissions

with respect to the materials. The only warranties for SAP Group

products and services are those that are set forth in the express

warranty statements accompanying such products and services, if

any. Nothing herein should be construed as constituting an additional

warranty. .


Recommended