19255987 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: roberto-faccini

Post on 16-May-2015

547 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: 19255987 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: 19255987 web-services-in-abap

Check « Remote-Enabled Module »:

Parameters have to be passed by value:

Page 3: 19255987 web-services-in-abap

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

Select Service Provider:

Page 4: 19255987 web-services-in-abap

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

Page 5: 19255987 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: 19255987 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: 19255987 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: 19255987 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: 19255987 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: 19255987 web-services-in-abap
Page 11: 19255987 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: 19255987 web-services-in-abap

Enter the URL of the WSDL:

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

Page 13: 19255987 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: 19255987 web-services-in-abap

Now we have to configure Consumer Proxy in SOAMANAGER:

Page 15: 19255987 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: 19255987 web-services-in-abap

Click on Save.

We can now test the webservice call: execute with F8

Page 17: 19255987 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: 19255987 web-services-in-abap

Execute...

To use proxy class in a program:

Page 19: 19255987 web-services-in-abap

Execute: