Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Chart
Search :       Advanced Search »
Home » Web Services » Consming SAP Web Services and .NET

Consming SAP Web Services and .NET

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

Author Rank :
Page Views : 6492
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


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

BACK GROUND

SAP and Microsoft .NET can be integrated via couple of options. On the top: SAP Web Services can be consumed in a straight line in .NET web client, ASP.NET. ASP.NET has built in support for the consuming Web Service WSDL and generating the proxy code. Once we have the proxy code, that can be consumed in any .NET client applications like console application, web application, WCF application. 

1.gif

USING VISUAL STUDIO.NET TO 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.gif

  2. It will generate the WSDL for the web service

    3.gif

  3. 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. 

    4.gif
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.gif

  5. System shows the following screen.

    6.gif

  6. Click on the 'Allow block content' as shown below. Which show the generated WSDL.

    7.gif

    8.gif

  7. 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. 

  8. Compile the solution. Now the proxy class is ready to be consumed by .NET clients. Which will be detailed in the next section.

  9. Also following entries are made to the app.config for runtime use to identify the web service.

    9.gif
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

    using
    SAPWebServiceProxyLibrary.CustomerMasterNamespace;

  4. Following are the basic lines of code to be written to asscess the data from SAP system.

    //Creating the Service
    ZSN_WEBSERVICEService
    _proxy = new ZSN_WEBSERVICEService();
    //stores the return row XML data from the SAP web service

    String
    outData;

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

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Srihari Chinna
Good experience in designing the applications and Architecting Enterprise application using SharePoint 2007 technologies and Service Oriented applications using ASP.NET and WCF Services. Also had hands on experience in designing in .NET Web based application using ASP.NET and AJAX.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments
Good learning by Mahesh On August 20, 2010
Thank you for sharing one more wonderful article Srihari. I don't know much about communication between SAP and .NET. Good to know this.
Reply | Email | Modify 
Re: Good learning by Srihari On August 21, 2010
thanks, Mahesh.
Reply | Email | Modify 
Doubts by nathan On August 23, 2010
Srihari, I am developing an application that integrates SAP and .net and have some doubts.

I'm .net developer. All SAP versions support Web service? What sap developers need to make a web service?

Thanks
Reply | Email | Modify 
Re: Doubts by Srihari On August 24, 2010
Hi,

SAP developers will better knwo about the SAP versions supported. for me following are the steps to create a webservice.

Activate change pointers for message type: ex: DEBMASAfter activation of change pointer in the <<Table1>> . whenever changes happens to the table the IDoc will  trigger with all the changed data and create a xml file.Create Function module, ex:, ZSN_WEBSERVICE with RFC Enable function module. Write the all necessary code to get all related data into one XML output string.


I am going to post another artical on consuming .NET web service in SAP that will clear many details of SAP.

Thanks,
Chinna
Reply | Email | Modify 
SAP Web service and .NET CF 2 by Pablo On October 5, 2011
Hi We are trying to connect to a SAP web service from an smart device using .NET Compact Framework. Is it possible? If yes, what is needed? Thanks
Reply | Email | Modify 
Discover the top 5 tips for understanding .NET Interop
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.