Cookbook: Consuming an SAP Web Service in Visual Studio 2005 (C#)

Similar documents
Salesforce Integration Using PI: How to Perform Query and Other DML Operations Using the Enterprise WSDL

Table of Contents. Passing Data across Components through Component Controller between Two Value Nodes

Configuration of Enterprise Services using SICF and SOA Manager

SAP BW - Excel Pivot Chart and Pivot Table report (Excel)

Creating Web Service from Function Modules/BAPIs & Integrating with SAP Interactive Forms

Standard SAP Configuration of SMS through HTTP with Third Party SMS Gateway

ABAP Proxy Interfacing

Display Options in Transaction SE16

Exposing RFC as Web Service and Consuming Web Service in Interactive Forms in ABAP

SAP CRM 7.0 E2C Setup: CRM via Toolset

Step by Step Guide for Language Translation Tool

Reverse Transport Mechanism in SAP BI

Salesforce.com Integration Using SAP PI: A Case Study

SAP CRM Campaign Automation

Deleting the User Personalization done on Enterprise Portal

A Step-by-Step guide on SMTP Configuration and File to Mail Scenario Using Process Integration Scenario in PI 7.1

Step by Step Guide How to Copy Flat File from Other Application Server to BI and Load through Info Package

Deploying Crystal Reports on Top of a SAP BI Query

Restricting Search Operators in any Search View

Forgot or Lock "Administrator or J2EE_ADMIN" Password

ALE Settings, for Communication between a BW System and an SAP System

Tutorial - Creating Pop Up Window Using New Features in WebDynpro Java CE 7.1 Ehp1

How to Integrate CRM 2007 WebClient UI with SAP NetWeaver Portal

Step by Step Procedure to Create Broadcasters, to Schedule and to Enhance of SAP- BI Queries from Query Designer

Creating Transaction and Screen Variants

Creating New Unit of Measure in SAP BW

Step by Step guide of Report-to- Report Interface in BW Reporting

Step by Step Procedure to Block and Debug a CIF Queue Flowing from R/3 to APO System

SAP NetWeaver Developer Studio 7.30 Installation Guide

Creating Content Using SO10 Objects and Text Symbols

Step by Step Procedures to Load Master Data (Attribute and Text) from FlatFile in BI 7.0

Configuring HTTPs Connection in SAP PI 7.10

Quick Viewer: SAP Report Generating Tool

ABAP Debugging Tips and Tricks

XSLT Mapping in SAP PI 7.1

Data Extraction and Retraction in BPC-BI

Web Application Designer for Beginners

How to Modify, Create and Delete Table Entries from SE16

BW Performance Monitoring

SAP FI - Automatic Payment Program (Configuration and Run)

How to Create an ecatt?

Creation and Configuration of Business Partners in SAP CRM

ABAP How To on SQL Trace Analysis

Step By Step Procedure to Create Logical File Path and Logical File Name

Web Dynpro ABAP: ALV and Table in Popup Window

Table of Content. SAP Query creation and transport Procedure in ECC6

Business Scenario Using GP/Web Dynpro with Back and Forth 3 Level Process and Dynamic Approvers in a Loop

Data Flow from LBWQ/SMQ1 to RSA7 in ECC and Delta Extraction in BI

Workflow Troubleshooting and Monitoring in SAP ECC 6.0

Create Automatic Mail Notification/ Alert for Process Chain Monitoring

Deleting the Requests from the PSA and Change Log Tables in Business Intelligence

How to Generate Stack Xml for Ehp4 and Above Upgrade

Understanding BEx Query Designer: Part-2 Structures, Selections and Formulas

Extractor in R/3 and Delta Queue

SAP CRM 7.0 for Newbies: (Part 1) Simple BOL Object Creation for CRM Webclient UI

Working with the ERP Integration Service of EMC Documentum Process Services for SAP

Understanding BW Non Cumulative Concept as Applicable in Inventory Management Data Model

Release Strategy Enhancement in Purchase Order

Consuming Services in SOA Manager

Implementing TinyMCE JavaScript HTML Editor for Web Page Composer (WPC) within the SAP Portal

Creating Mobile Applications on Top of SAP, Part 1

Integrating Siebel CRM with Microsoft SharePoint Server

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

How to Assign Transport Request for Language Translation?

Message handling in SAP CRM Web UI

Sending an Image File Through XI in a File-to-Mail Scenario

Adobe Document Service Configuration and Troubleshooting Guide

Process Controlled Workflow SRM 7.0 (Using BRF)

Direct Subcontracting Process (SAP SD & MM)

webcrm API Getting Started

Transfer of GL Master from Source SAP System to a Target SAP System through IDOCS

Setting up On line Account

Connecting to SAP BW with Microsoft Excel PivotTables and ODBO

Creating and Scheduling Publications for Dynamic Recipients on SAP Business Objects Enterprise

Compounding in Infoobject and Analyzing the Infoobject in a Query

LSMW: Upload Master Data using Batch Input Recording

Order Split Usage in Production Orders

Accept And Refund Payments In A PayPal Personal Account

Web Dynpro: Multiple ALV Grids and Layouts in ALV

Multi Provider Creation Based on Sales and Planning Info Cubes

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

SAP CRM Middleware Configurations

Splitting the Custom Container & Display more than one ALV

Using PI to Exchange PGP Encrypted Files in a B2B Scenario

Deploying JDBC drivers in PI 7.1x Systems

Working with SAP BI 7.0 Data Transfer Process (DTP)

Guidelines for Effective Data Migration

Integrated Testing Solution Using SAP Solution Manager, HP-QC/QTP and SAP TAO

Enterprise Self Service Quick start Guide

NATIONAL STOCK EXCHANGE OF INDIA LIMITED DEPARTMENT : PRIMARY MARKET. Download Ref No : NSE/CMTR/32597 Date : June 17, 2016

PUBLIC Password Manager for SAP Single Sign-On Implementation Guide

CRM - Word Connector (CWC) For the vtiger CRM User s Manual Manual Version 1.0

Configuration Guide - OneDesk to SalesForce Connector

BI 7.0 and EP 7.0 Integration using Template Installer

USER MANUAL KNOWLEDGE CENTER - PORTAL

SAP CRM System 6.0/7.0. For more information, visit the Customer Relationship Management homepage

How To Use Syntheticys User Management On A Pc Or Mac Or Macbook Powerbook (For Mac) On A Computer Or Mac (For Pc Or Pc) On Your Computer Or Ipa (For Ipa) On An Pc Or Ipad

Service Enrolment Document. Version: 1.0. September, July, e-transaction Aggregation and Analysis Layer. User and Technical Manual

Business Partner in the Human Resources (HR) System

Enrollment Process for Android Devices

Transcription:

Applies To: Microsoft Visual Studio 2005 Microsoft.Net Framework 1.1 Access to SAP NetWeaver Exchange Infrastructure 3.0 (SAP employees can use X3A) Summary The aim of this article is to explain the method to consume a Web Service using Windows forms in Microsoft Visual Studio 2005. Please note that this is a technical document and I have used a small web service to demonstrate the process of implementation. Prerequisite: Beginner level knowledge of Visual Studio 2005 and C# and Object oriented concepts. By: Vikas Aggarwal Company: SAP Labs India Date: 22 March 2006 Table of Contents Applies To:...1 Summary...1 Table of Contents...1 Scenario...2 Adding Web Service to Visual Studio Project...3 Additional Notes...10 Author Bio...15 Disclaimer & Liability Notice...15 1

Scenario Employee details need to be fetched based on Employee ID from a backend R/3 system using a web service. Create a Web Service in an R/3 system and note the URL to the WSDL file. URL for WSDL used in this case: http://pwdf2813.wdf.sap.corp:50031/sap/bc/srt/xip/sap/emplqueryresponse_in?sap-client=100&wsdl=1.1 The Web Service generates the output as shown in the following web browser screenshot. 2

Adding Web Service to Visual Studio Project Create a new Windows application project: EmployeeInfo. Create a Windows form (EmployeeQueryForm) as shown below with the required fields. Give meaningful names to all fields. Select option Menu >> Project >> Add Web Reference. Enter the URL in the field as shown below and select Go button 3

Enter User id and password for the server when asked. 4

Enter the same User id and password once more when asked. Details of Web service will be fetched. 5

Enter a name for the service and select Add Reference. Visual Studio will create a proxy for the web service and place it the namespace EmployeeQueryService. You can see the classes and parameters created in the Object Browser. Open EmployeeQueryForm.cs code in text editor. Add the following using directives at the top of the code. using EmployeeInfo.EmployeeQueryService; using System.Net; The list of methods is available in the object browser. 6

Now our task is to call this method with right parameters just like any other method call and populate the required fields with the return parameters. Enter the following code in the click event of the Submit button. String EmplID; String EmpName; String EmpEmail; String EmpPhoneNumber; EmplID = textemplid.text; // Instantiate the Webservice EmplQueryResponse_InService EmployeeQueryService = new EmplQueryResponse_InService(); 7

try { // Pass Login details to access the Web Service NetworkCredential credentials = new NetworkCredential("AGGARWALVI", "password"); EmployeeQueryService.Credentials = credentials; // Call the web service EmployeeQueryService.EmplQueryResponse_In(ref EmplID, out EmpName, out EmpEmail, out EmpPhoneNumber); // Populate the return parameters in the text fields textempname.text = EmpName; textempphonenumber.text = EmpPhoneNumber; textempemail.text = EmpEmail; // Exception handler catch (Exception ex) { MessageBox.Show("Error fetching Employee details: " + ex.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Now you can compile and run the program to get the details as follows. 8

Click the Submit button. 9

Additional Notes While adding a web service to the project, it might happen the WSDL is read incorrectly and some of the parameters are missing in the generated proxy code. Proxy code can be found in the file Reference.cs In this case you will have to change the proxy code manually. Please note that changing the proxy code manually may cause incorrect behavior, if not handled carefully. If anything goes wrong, web reference can be updated and all changes made will be reset. For example, in this case, Employee Name is missing in the output parameters. Drill down to the method EmplQueryResponse_In and make the following changes. The missing parameters will be listed above the method implementation. Code Before change: [return: System.Xml.Serialization.XmlElementAttribute("EmpName", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string EmplQueryResponse_In([System.Xml.Serialization.XmlElementAttribute(Form=System.X ml.schema.xmlschemaform.unqualified)] ref string EmplID, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaFo rm.unqualified)] out string EmpEmail, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaFo rm.unqualified)] out string EmpPhoneNumber) { object[] results = this.invoke("emplqueryresponse_in", new object[] { EmplID); EmplID = ((string)(results[1])); EmpEmail = ((string)(results[2])); EmpPhoneNumber = ((string)(results[3])); return ((string)(results[0])); Code After change: public string EmplQueryResponse_In([System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] ref string EmplID, [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] out string EmpName, 10

[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] out string EmpEmail, [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] out string EmpPhoneNumber) { object[] results = this.invoke("emplqueryresponse_in", new object[] { EmplID); EmplID = ((string)(results[1])); EmpName = ((string)(results[2])); EmpEmail = ((string)(results[3])); EmpPhoneNumber = ((string)(results[4])); return ((string)(results[0])); Drill down to the class implementation EmplQueryResponse_InCompletedEventArgs and make the following changes. Code before change: public partial class EmplQueryResponse_InCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { private object[] results; internal EmplQueryResponse_InCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userstate) : base(exception, cancelled, userstate) { this.results = results; public string Result { 11

return ((string)(this.results[0])); public string EmplID { return ((string)(this.results[1])); public string EmpEmail { return ((string)(this.results[2])); public string EmpPhoneNumber { return ((string)(this.results[3])); Code after change: public partial class EmplQueryResponse_InCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { 12

private object[] results; internal EmplQueryResponse_InCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userstate) : base(exception, cancelled, userstate) { this.results = results; public string Result { return ((string)(this.results[0])); public string EmplID { return ((string)(this.results[1])); public string EmplName { get 13

{ return ((string)(this.results[2])); public string EmpEmail { return ((string)(this.results[3])); public string EmpPhoneNumber { return ((string)(this.results[4])); 14

Author Bio I am working as a Development Specialist at SAP Labs India. I have an engineering degree in Electronics & telecommunication from Mumbai University. I started my career at Infosys Technologies Ltd. In July 2003. I joined SAP Labs in May 2004. During this period at SAP, I have worked on Adobe forms and ESA enabling and Web Service creation for ERP Operations Area. Disclaimer & Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 15