Consuming SAP Web Services and .NET

No.of Views8428
Bookmarked0 times
Downloads 
Votes0
By  Chinna Srihari   On  18 Aug 2010 23:08:27
Tag : .NET Frameworks , How to
The scope of this document is to describe integration of SAP Web Services and Microsoft .NET using Microsoft Visual Studio.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

The scope of this document is to describe integration of SAP Web Services and Microsoft .NET using Microsoft Visual Studio.

SAP Web Services And Visual Studio .NET Architecture and Overview

Background

Image Loading

Using Visual Studio.NET Generate Proxy from SAP Web Service

There two steps involved the creation of the proxy. First create a wsdl for the given web service and then generate the proxy by consuming the WSDL. I will let you the reason behind it.

A. Creating WSDL from the Web Service URL.

  1. Open the Internet explorer and input the web service URL that is created in SAP server and click enter. Enter the credentials when it asks for. And click on OK button
  2. Image Loading

  3. It will generate the WSDL for the web service
  4. Image Loading
  5. Save the WSDL file to the disk with the WSDL extension and open the WSDL in .NET IDE or in the notepad. Find the 'System' in the WSDL and replace with "SYSTEM" because the namespace System is already reserved in Visual Studio. If you do not change the name of this element here to all capital letters, you will get errors when building the application. The next change you need to make on the WSDL is to rename all instances of "parameters" to "parameter." This is necessary to be able to read the methods of the Web service correctly in Visual Studio. Save the changes for further use to generate the proxy
Image Loading

B. In the second step, Follow the steps to generate the proxy for client.

  1. Open up the Microsoft Visual Studio any version. Create a blank solution with the same if SAPDotNetIntegration.
  2. Create a new class library project, by adding a new project to the solution. Name it is SAPWebServiceProxyLibrary.  The purpose of creating it as separate library is the it can be reference in .net client application for use.
  3. Right click oin the SAPWebServiceProxyLibrary project and click on 'Add web referance' context menu.
  4. Enter the Disk path of the WSDL generated in the first step in the URL drop down and click on 'Go' button.
  5. Image Loading
  6. System shows the following screen.
  7. Image Loading
  8. Click on the 'Allow block content' as shown below. Which show the generated WSDL.
  9. Image Loading
    Image Loading
  10. Enter 'SAPWebServiceNamespace' in the 'Web reference name' text box and click on 'Add Referance' button. Which will generate the .NET proxy class of the client to consume.
  11. Compile the solution. Now the proxy class is ready to be consumed by .NET clients. Which will be detailed in the next section.
  12. Also following entries are made to the app.config for runtime use to identify the web service.
  13. Image Loading

Consuming Proxy in .NET Client

Follow the steps to create and read the data by using the proxy.

  1. Add a new 'ASP.NET Web application' to the SAPDotNetIntegration solution. And name it as AspDotNetClient.
  2. Add the reference to the SAPWebServiceProxyLibrary.dll compiled and saved on the disk. By right clicking on the AspDotNetClient, and clicking on the 'Add reference context' menu.
  3. Add the following statement to the code behind
  4. using SAPWebServiceProxyLibrary.CustomerMasterNamespace;
  5. Following are the basic lines of code to be written to asscess the data from SAP system.
//Creating the ServiceZSN_WEBSERVICEService
_proxy = new ZSN_WEBSERVICEService();
//stores the return row XML data from the SAP web serviceString outData;

//Setting the User Credentials_proxy.Credentials = new NetworkCredential("loginName", "password");
//We have a stateful communication therefore we have to use a //CookieContainerCookieContainer _cookie = new CookieContainer();
_proxy.CookieContainer = _cookie;
// p_filepath_app is the input parameter to identify the specific SAP web // serviceoutData = _proxy.ZsnWebservice("xmlfilepathonthesapserver");

 That's all. happy coding.

 
Sign Up to vote for this article
 
About Author
 
Chinna Srihari
Occupation-Software Engineer
Company-
Member Type-Junior
Location-India
Joined date-17 Jun 2010
Home Page-
Blog Page-
Having 12 + years of IT experience, 2.5 years as Technical Management experience and 1.5 year of onsite coordinator experience and rest 8+ years of technical activities including Project Leader, Tech Lead, Designer, PQL, and Developer experience in Quality Management System (CMM-level 5, SEI-CMM-level 5).
 
 
Other popularSectionarticles
    In this article i will explain about extension method and how to create in .NET
    Published Date : 28/Jan/2011
    New version of ASP.NET provides lots of way of binding data to the data controls like Grid View, Repeater etc. You can now bind this controls with strong type.
    Published Date : 07/Mar/2013
    Let us start this article by a small chat between customer and developer. Scenario 1 Customer: - How’s your application performance? Subjective developer: - Well it’s speedy, it’s the best …huuh aaa ooh it’s a like rocket. Scenario 2 Customer: - How’s your application performance? Quantitative developer: - With 2 GB RAM , xyz processor and 20000 customer records the customer screen load in 20 secs. I am sure the second developer looks more promising than the first developer. In this
    Published Date : 10/May/2010
    Ask any developer which is the best place in a .NET class to clean unmanaged resources?, 70% of them will say the destructor. Although it looks the most promising place for cleanup it has a huge impact on performance and memory consumption. Writing clean up code in the destructor leads to double GC visits and thus affecting the performance multifold times. In order to validate the same we will first start with bit of theory and then we will actually see how GC algorithm performance is impacte
    Published Date : 06/May/2010
    One of the important factors for performance degradation in .NET code is memory consumption. Many developers just concentrate on execution time to determine performance bottle necks in a .NET.
    Published Date : 05/May/2010
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top