Professional Documents
Culture Documents
(Is) RFC-To-Web Service Scenario
(Is) RFC-To-Web Service Scenario
by Neeraja
This document describes how the Custom RFC client application in SAP R/3 System invokes a free Web
service (that is hosted over the internet) using SAP XI. For our demo purpose, we have used a free web
service available on the Internet. Details for the same are provided in the next section.
About the web service:
In this example scenario we will be using GetQuote method of Web service DelayedStockQuote. This
method retrieves the Stock quote for the given Stock symbol. The method GetQuote has an input that
takes in two parameters Stock Symbol and License Key and returns the following information.
StockSymbol,
LastTradeAmount,
LastTradeDateTime,
StockChange,
OpenAmount,
DayHigh,
DayLow,
StockVolume,
PrevCls,
ChangePercent,
FiftyTwoWeekRange,
EarnPerShare,
PE,
CompanyName.
Link to webservice:
http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?op=GetQuote
WSDL of the webservice:
http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?WSDL
Download WSDL from the above link.
1.
1.1 Create
RFC
destination:
To
create
the
RFC
go
to
TCODE:
SM59
Create
new
destination
of
type
T
(TCP/IP)
Make sure you select Registered Server Program option before writing your program ID
Write
your
program
ID
(remember
it's
case-sensitive)
In the gateway host and gateway service write the values of your "Application system" - business
system(R/3
System)
Export:
Source
code:
Code snippet
REPORT
ZTEST_WEBSERVICE.
parameters:
p_stsym(30).
data:
StockSymbol
LastTradeAmount
LastTradeDateTime
StockChange
OpenAmount
DayHigh
DayLow
StockVolume
PrevCls
EarnPerShare
companyname
QuoteError
CALL
FUNCTION
EXPORTING
ST_SYM
StockSymbol
LastTradeAmount
StockChange
OpenAmount
DayHigh
DayLow
StockVolume
PrevCls
EarnPerShare
companyname
type
type
type
type
type
type
type
type
type
type
type
type
'ZN_GET_QUOTE'
p_stsym
LKEY
=
=
=
=
=
=
=
=
=
=
QUOTEERROR
if
quoteerror
NE
'true'
write:
/'StockSymbol:',StockSymbol,
/'LastTradeAmount:',LastTradeAmount,
/'LastTradeDateTime:',LastTradeDateTime,
/'StockChange:',StockChange,
/'OpenAmount:',OpenAmount,
/'DayHigh:',DayHigh,
/'DayLow:',DayLow,
/'StockVolume:',StockVolume
/'PrevCls:',PrevCls,
/'EarnPerShare:',EarnPerShare,
/'companyname:',companyname,
/'QuoteError:',QuoteError.
else.
write:/
'Invalid
endif.
and
Continued...
char30,
char30,
char30,
char30,
char30,
char30,
char30,
char30,
char30,
char30,
char30,
char30.
destination
=
'0'
'RFC'
IMPORTING
StockSymbol
LastTradeAmount
StockChange
OpenAmount
DayHigh
DayLow
StockVolume
PrevCls
EarnPerShare
companyname
QuoteError.
quoteerror
NE
'TRUE'.
Stock
symbol'.
Note: Usually when we import the WSDL as an External Definition, we get the relevant messages for the
request and response structures along with it.
the
RFC
ZN_GET_QUOTE
created
in
the
previous
step
from
R/3
system.
Note: Usually when we import the RFC from R/3 system, we get the relevant messages for the request and
response structures along with it.
2.3 Define Message Interface
As imported WSDL and RFC messages can be used as Data types, Message types and outbound message
interface we dont require creating those.
Define inbound synchronous message Interface
Here we need to create two mappings, first between RFC Request (ZN_GET_QUOTE.Request) to SOAP
Request (GetQuoteSoapIn) and second between SOAP Response (GetQuoteSoapOut) to RFC Response
(ZN_GET_QUOTE.Response).
Request mapping
Response mapping
Continued...
Make sure the Program id specified here and the Program id specified in the RFC destination created above
are same.
3.2 Create receiver communication channel
Create Receiver communication channel (SOAP adapter) under the Receiver business service.
We
need
to
specify
the
following
in
the
SOAP
adapter;