Application Development and Automation 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: 
Read only

How call HTTPS URI and receive the response in ABAP

MNaveen
Product and Topic Expert
Product and Topic Expert
0 Likes
1,577

Hello all,

I have requirment where i am trying to call an https URl from ABAP and pass an XML string and receive the response. However i am not sure how can i acheive this.

For example, the bleow code in java acheives the same thing but i want to do something similar in ABAP.

* Send data to OnDemand
		 */
		urlConnection = (HttpsURLConnection) (new URL(ONDEMAND_URI)).openConnection();
		urlConnection.setDoInput(true);
		urlConnection.setDoOutput(true);
		
		urlConnection.setRequestMethod("POST");
		urlConnection.setRequestProperty("Authorization", authHeader);
		urlConnection.setRequestProperty("Content-length", "" + dataBytes.length);
		urlConnection.setRequestProperty("Content-Type", "text/xml");
		
		urlConnection.getOutputStream().write(dataBytes);
		
		/*
		 * Ensure succesful data upload by ensuring HTTP Status Code 200.
		 */
 		if(urlConnection.getResponseCode() != 201) {
			throw new Exception("Failed dataSet upload.\n" 
					+ "HTTP " + urlConnection.getResponseCode() 
					+ ": " + urlConnection.getResponseMessage());
		}

It would be really helpful if you could give some detail explanation or links where such information is available. Thanks a lot in advacne.

Warm Regards,

Naveen M

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,231

Hi, first thing to do is of course an abap proxy client.

This can be created in SE80 under enterprice service. You need the WSDL of the service and the

abap proxy (with input and output structures) is automatically generated.

When you have the abap proxy, you can use it any other abap class.

In will write a zreport program with ....

DATA: lo_proxy TYPE REF TO PROXY,

lf_output TYPE proxy_output_structure,

lf_input TYPE proxy_input_structure.

  • Create Proxy instance

CREATE OBJECT lo_proxy.

  • Method Call

TRY.

CALL METHOD lo_proxy->method_name

EXPORTING

INPUT = lf_input

IMPORTING

OUTPUT = lf_output.

CATCH cx_ai_system_fault.

sy-subrc = 1.

CATCH yfiqcx_fault_message .

sy-subrc = 2.

CATCH cx_ai_application_fault.

sy-subrc = 3.

ENDTRY.

Hope it can help you.

3 REPLIES 3
Read only

Former Member
0 Likes
1,232

Hi, first thing to do is of course an abap proxy client.

This can be created in SE80 under enterprice service. You need the WSDL of the service and the

abap proxy (with input and output structures) is automatically generated.

When you have the abap proxy, you can use it any other abap class.

In will write a zreport program with ....

DATA: lo_proxy TYPE REF TO PROXY,

lf_output TYPE proxy_output_structure,

lf_input TYPE proxy_input_structure.

  • Create Proxy instance

CREATE OBJECT lo_proxy.

  • Method Call

TRY.

CALL METHOD lo_proxy->method_name

EXPORTING

INPUT = lf_input

IMPORTING

OUTPUT = lf_output.

CATCH cx_ai_system_fault.

sy-subrc = 1.

CATCH yfiqcx_fault_message .

sy-subrc = 2.

CATCH cx_ai_application_fault.

sy-subrc = 3.

ENDTRY.

Hope it can help you.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,231

You will find more information in [SAP library - Example Program: Executing an HTTP Request|http://help.sap.com/SAPHELP_NW04S/helpdata/EN/1f/93163f9959a808e10000000a114084/frameset.htm]

Read only

MNaveen
Product and Topic Expert
Product and Topic Expert
0 Likes
1,231

Hi,

Thanks for the replies.

I tried using CL_HTTP_CLIENT class and it worked fine for my requirment.

Warm Regards,

Naveen