You are on page 1of 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.
Check « Remote-Enabled Module »:

Parameters have to be passed by value:


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

Select Service Provider:


Enter the name of the service, choose Function Module Endpoint Type
Choose function module: if you check Mapping der Namen, name of the parameters will be
converted in uppercase without underscore
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
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:
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:


You obtain this:

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

Now we can test Request 1:

Launch request with green button:


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)
Enter the URL of the WSDL:

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


The lient proxy is created:

Now you have to activate: activate anyway if you have this kind of messages.
Now we have to configure Consumer Proxy in SOAMANAGER:
In tab configuration, create a new logical port:

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

We can now test the webservice call: execute with F8


Fill Logical port name:

Request is displayed:

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


Execute...

To use proxy class in a program:


Execute:

You might also like