Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to expose a bapi as Rest webservice to consume in web applications

Former Member
0 Kudos

Hello experts , i now seriously need your suggestion here. Is there a way to expose a BAPI as a rest webservice which can be consumed by a web application in the end.

What is ICF ( Internet Communication Framework) ? Does this help in generating web service from BAPI ?

Netweaver Gateway might help to generate services but may not be recommended here in our scenario.

9 REPLIES 9

Former Member
0 Kudos

David,

Open up the FM in SE37 and chose the below menu path.

UTILITIES->MORE UTILITIES - > CREATE A WEB SERVICE - > FROM THE FUNCTION MODULE.

Once you are there, SAP will take you thru various steps thru which you can expose the FM as a web service to be consumed from web applications.

Thanks,

Vikram.M

matt
Active Contributor
0 Kudos

This will get you a SOAP web service. David Clavey wants a REST webservice.

Former Member
0 Kudos

Please refer Real Web Services with REST and ICF for creation of rest services in sap. The BAPI will have to be called in your handler class.

I think your best bet would be to transfer the data in the body of the http request and use simple transformation(with multiple roots) to convert the xml data to sap formats. GZIP can also be used to compress the data that is being sent. We have done this successfully in one of our projects.

However this approach(RESTful Service) would involve more work when compared to the approach suggested by Vikram. If SOAP based services are ok, then you should go ahead with Vikram's approach.

0 Kudos

This message was moderated.

0 Kudos

You can't call a SOAP web service via a GET request so clicking on a URL will not work. Restless services can be build by implementing an ABAP class that implements the interface IF_HTTP_EXTENSION. You'll have to implement the method in the interface. The method gets a parameter server which can be used to access the data in the HTTP request.


With the method server->request->get_form_fields you can get the parameters in the URL. You can use them to send data to your REST service.


The anwer to the call should be added to the HTTP response (server->response).


Then you'll have to create a new node in SICF and set the class as HTTP handler.


More information here:


Creating SICF Service Nodes and Including Handlers - Components of SAP Communication Technology - SA...


Best regards,


Frank

0 Kudos

This message was moderated.

0 Kudos

Hi Juan,

unfortunately the setting have to be done on the network, it's either a firewall or less likely a NAT issue.

I would advise to not open the firewall for the ECC system though. It would be better to use e.g. a reverse proxy that only opens a way for that one interface.

Best regards,

Frank

0 Kudos

Thanks Frank,

looks like reverse proxies are only applicable to SOAP(SOAMANAGER).

is there another way to allow open up a Restful webservice  safely?

thanks

0 Kudos

Hi Juan,

any HTTP reverse proxy or server should work as your service is based on the HTTP protocol.

Example for nginx: https://www.nginx.com/resources/admin-guide/reverse-proxy/

Example for apache: Running a Reverse Proxy with Apache:

Best regards,

Frank