Consume an On-Premise HTTP service from ABAP in the Cloud (Scenario : SOAP Service)
A very few number of resources are available for reference as at now, for ABAP in the Cloud Environment, as the use of ABAP Environment on SAP Business Technology Platform (BTP) is not yet being used widely in a global scale. Therefore, finding resources to achieve certain functions and features on ABAP in the cloud would be somewhat challenging for many developers.
This blog will take you through the process of setting up the feature of consuming an external HTTP service hosted on an On-Premise SAP system via ABAP in the cloud, where a standard SOAP service hosted on the S/4 HANA On-Premise system will be consumed.
Before we start, there are many SAP customers who are still using on-premise SAP installations, which were implemented long ago. To get existing business logic into an SAP cloud-based solution, you’ll need to establish a connection in the cloud environment following one of two approaches: RFC destinations or HTTP destinations. These destinations must be specified properly to enable communication between cloud-based and on-premise SAP systems.
As a prerequisite, you must establish the connection to the on-premise system using SAP Connectivity service’s cloud connector. The cloud connector provides secure communications, requiring only an outbound connection from the on-premise environment to SAP BTP.
Therefore for this exercise we need to,
- Set up the ABAP Environment on BTP Cloud Platform.
- Configure SAP Cloud Connector for your SAP BTP Sub account and S/4 HANA On-Premise System.
- Consume the On-Premise SOAP Service from ABAP in the Cloud using HTTP Service.
1. Set up the ABAP Environment on BTP Cloud Platform
For this, please visit my previous blog on Initial Configurations for ABAP in the Cloud – Cloud Foundry Environment
2. Configure SAP Cloud Connector for your SAP BTP Sub Account and S/4 HANA On-Premise System
- First go to your BTP Trial Account and copy the ID under your subaccount.
- Open the cloud connector, Go to -> Clout to On-Premise -> Add Mapping Virtual To Internal System.
- Select Backend Type -> ABAP System
- Protocol -> HTTP
- Enter Host Information
- Give Principal type as none
- Request header as “User Virtual Host”
- Continue till you arrive at the following location and click the “Check Button” and continue.
- Once connection successful, message should appear as follows
3. Consume On-Premise SOAP Service from ABAP in the Cloud using HTTP Service
Prerequisites : A web service configured and exposed via Transaction SOAMANAGER on the On-Premise S/4 HANA system.
For this blog, I have used the standard QUERYBUSINESSUSERIN service configuration on a S/4 On-Premise system.
- Go to SOAMANGER -> Web Service Configuration -> Search for service QUERYBUSINESSUSERIN.
- Select Open Binding WSDL Generation.
- Copy the WSDL URL and paste it on a browser.
- Copy the WSDL content from the browser and save in into a .txt file.
- Go to ADT -> Package -> Other -> Service Consumption Model.
- Set the service consumption mode as “Web Service”.
- Select the .txt file that was downloaded and give a prefix.
- Once created, you’ll see properties and metadata as well as a code sample that you can reuse in your development projects.
- You will also see two helper classes generated, which are proxy classes that can be used to consume the service.
- Create a class to consume the SOAP service and implement the sample code given above.
CLASS zcl_consume_onprem_soap DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES if_oo_adt_classrun. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS zcl_consume_onprem_soap IMPLEMENTATION. METHOD if_oo_adt_classrun~main. TRY. DATA(destination) = cl_soap_destination_provider=>create_by_cloud_destination( i_name = 'S4_HTTP_DESTINATION' i_service_instance_name = '00' ). DATA(proxy) = NEW zsoap_co_query_business_user_i( destination = destination ). DATA(request) = VALUE zsoap_business_user_simple_by( ). proxy->query_business_user_in( EXPORTING input = request IMPORTING output = DATA(response) ). "handle response CATCH cx_soap_destination_error INTO DATA(lo_sde). out->write( lo_sde->get_text( ) ). CATCH cx_ai_system_fault INTO DATA(lo_sf). out->write( lo_sf->get_text( ) ). CATCH zsoap_cx_standard_message_faul INTO DATA(lo_smf). out->write( lo_smf->get_text( ) ). ENDTRY. ENDMETHOD. ENDCLASS.
Your On-Premise SOAP Service is now available for consumption. You can use the sample code that is generated in the service consumption model to simply test this service.
As you see above, with a very limited amount of configurations, we can easily consume a HTTP service that is hosted on an On-Premise system, whether it is SOAP, ODATA or any other appropriate service, via the ABAP Environment on SAP BTP. Similarly, we can also create RFC destinations via the cloud connector and consume RFC’s that are created in a S/4 HANA On-Premise System.
One thing to keep in mind is that we cannot test this on a trial BTP account, as these services are limited only to partner/consumer licensed accounts.
Simple and clear. use cloud connect onprem and build app or service as you like.
utilization of BTP for a traditional customer that is running cloud and onpremise both.
Thank you Barin DESAI !
Hi Anslem Arnolda,
Thank you for the detailed post.
Can you please specify what i_name and i_service_instance_name would be?