You are on page 1of 17

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Applies to:
SAP Web Application Server (WAS) 6.40, 7.0 and CE (7.1). For more information, visit the Web Services homepage.

Summary
The main objective of this tutorial is to create a Web Service whose end point is a Remote Function Module and consuming that web service in Adobe Flex 3 Application using Web Service Introspection Method. You can now easily develop your favorite Flex based client application that consumes SAP RFCs as Web Services. Web Service Introspection Method will generate client proxy classes from WSDL signatures. Author: Vivek Khedekar

Company: Larsen & Toubro Infotech Ltd. Created on: 5 August 2009

Author Bio
Vivek Khedekar works at Larsen & Toubro Infotech Ltd., as a SAP Technical Consultant. He has primarily worked on SAP technologies like ABAP, ALE-IDoc, WebDynpro Java, Adobe Interactive Forms and also tried hands on integrating Adobe Flex, AIR with SAP via RFCs and Web Services.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 1

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Table of Contents
Creating Simple RFC..........................................................................................................................................3 Generating Web Service Using WS Wizard .......................................................................................................5 Create a Flex Project ..........................................................................................................................................9 Web Service Introspection................................................................................................................................11 Script to Call the Web Service Proxy................................................................................................................14 Running the Application....................................................................................................................................15 Related Content................................................................................................................................................16 Disclaimer and Liability Notice..........................................................................................................................17

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Creating Simple RFC


Go to SE37 to create simple function module which will return a simple calculation. We will pass a value to the webservice and that web service will call the function module in SAP and return that value to Flex application.

In the Import Tab we are importing a Data with Type Integer.

In Export Tab FM is returning the calculated value.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 3

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

In the Source tab we are adding following code

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 4

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Generating Web Service Using WS Wizard


Now we have to create a web service for this function module.

Press continue.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 5

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Provide the name and description of the FM. This may not be same as FM name

Press continue.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 6

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Select Basic Authorization and must check the Release for Runtime.

Click Complete

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 7

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Now you can access the wsdl as: http://<host>:<port>/sap/bc/srt/rfc/sap/<RFC Name>?sap-client=<client>&wsdl=1.1 For our example it is: http://<host>:<port>/sap/bc/srt/rfc/sap/ZTEST_INTRO?sap-client=800&wsdl=1.1
Note: You can skip the generation of web service using wizard and use wsdl as:

http:// <host>:<port>/sap/bc/soap/wsdl11?services=ZTEST_INTRO

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 8

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Create a Flex Project


In your Adobe Flex Builder, create a new Flex Project.

Name your project ZTEST_FLEX.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 9

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Confirm with Finish. The Flex project is created. In ZTEST_FLEX.mxml add design as below:

Here is the code generated


<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Label x="31" y="21" text="Enter any Integer Value :"/> <mx:TextInput x="176" y="19" width="100" id="TxtIP"/> <mx:Label x="31" y="49" text="Square of above value :"/> <mx:Text x="176" y="49" width="100" id="TxtOP"/> <mx:Button x="139" y="77" label="Get Calc From SAP" click="init()"/> </mx:Application>

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 10

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Web Service Introspection


In the flex builder Menu go to Data->Import Web Service

Enter the WSDL and press next

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 11

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Enter SAP user id and Password

Press Finish

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 12

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

You will see below files are generated

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 13

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Script to Call the Web Service Proxy


Add below Action script to call the Web Service Proxy.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 14

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Running the Application


Build the Flex Application and Press Run. Enter the value and press Button.

After entering valid Login credentials application will gives the output.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 15

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

Related Content
Welcome to the Flex and SAP Web Services Quickstart Consuming ABAP Web Services using Flex Adobe Flex For more information, visit the Web Services homepage.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 16

Consumption of SAP RFC in Adobe Flex 3 Application Using Web Service Introspection Method

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

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 17

You might also like