web services in abap

19
Generate a webservice in SAP Create a pakage Z_WEB_TUTO in SE80. Create a function group Z_WEB_TUTO_FG: Create a funtion module Z_WEB_TUTO_SUM:note that parameters have to be passed by value and function module has to be RFC callable.

Upload: tatanor

Post on 13-Nov-2014

10.245 views

Category:

Documents


14 download

DESCRIPTION

Provide and consume web service in ABAP with SAP Netweaver

TRANSCRIPT

Page 1: Web Services in Abap

Generate a webservice in SAP

Create a pakage Z_WEB_TUTO in SE80.

Create a function group Z_WEB_TUTO_FG:

Create a funtion module Z_WEB_TUTO_SUM:note that parameters have to be passed by value and function module has to be RFC callable.

Page 2: Web Services in Abap

Check « Remote-Enabled Module »:

Parameters have to be passed by value:

Page 3: Web Services in Abap

Now we can create a webservice from this function module...Call webservice wizard:

Select Service Provider:

Page 4: Web Services in Abap

Enter the name of the service, choose Function Module Endpoint Type

Page 5: Web Services in Abap

Choose function module: if you check Mapping der Namen, name of the parameters will be converted in uppercase without underscore

Page 6: Web Services in Abap

Profile define security parameters: it can be redefined later in transaction SOAMANAGER.If you check « Deploy service », the end point for this service will be autatically created in SOAMANAGER.

Now the webservice is created.

Launch transaction SOAMANAGER: this transaction launches a webdynpro application that is the

Page 7: Web Services in Abap

new configuration interface for webservices.

Select « Single Service Administration » in « Application and Scenario Communication »

Select service Z_WEB_TUTO_SUM and clik on Apply Selection: in « Configuration », you can see the end point that has been created.

You can see more information or change it whenever you want.

The WSDL of this service is available in « Overview », Diplay selected Binding's WSDL URL:

Page 8: Web Services in Abap

You can now test your webservice:in my case I use a software called soapUI but you can test clicking on « Open Web Service navigator for selected binding »(using Minisap, the service for testing is not available in SICF).

With soapUI, you can test this way:

Enter WSDL location:

Enter user & password:

Page 9: Web Services in Abap

You obtain this:

Double-click...and enter user & password for endpoint:

Now we can test Request 1:

Launch request with green button:

Page 10: Web Services in Abap
Page 11: Web Services in Abap

Consume a webservice in SAP

We will create a proxy class dedicated to consume the webservice that we have created.

In SE80, create a proxy object:

Selet Service Consumer:

Select URL/HTTP destination (you can also import WSDL from local file, ESR are standard services)

Page 12: Web Services in Abap

Enter the URL of the WSDL:

Enter pakage and a prefix for objets which will be generated.

Page 13: Web Services in Abap

The lient proxy is created:

Now you have to activate: activate anyway if you have this kind of messages.

Page 14: Web Services in Abap

Now we have to configure Consumer Proxy in SOAMANAGER:

Page 15: Web Services in Abap

In tab configuration, create a new logical port:

You can enter use and password to avoid to get a connexion popup at service call.

Page 16: Web Services in Abap

Click on Save.

We can now test the webservice call: execute with F8

Page 17: Web Services in Abap

Fill Logical port name:

Request is displayed:

If you want to edit request, click on XML-editor(CTRL+F2)

Page 18: Web Services in Abap

Execute...

To use proxy class in a program:

Page 19: Web Services in Abap

Execute: