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: 

using web service in sap

Former Member
0 Kudos

Hello all,

I have a requirement to use a web service in sap how to use web service in abap program,

anyone can give the sample code for that?

Moderator Message: This question has been extensively talked-about. Please search for relevant information.

Edited by: kishan P on May 19, 2011 12:19 PM

1 ACCEPTED SOLUTION

praveen_reddy2
Active Participant
0 Kudos

Calling a web service in ABAP that validates an email id

REPORT zvalidate_email.PARAMETERS: p_mail(100) LOWER CASE. " E-Mail id to be verifiedDATA: http_client TYPE REF TO if_http_client .DATA: w_string TYPE string ,

w_result TYPE string ,

r_str TYPE string .DATA: result_tab TYPE TABLE OF string.START-OF-SELECTION .

CLEAR w_string .

CONCATENATE

'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email=' p_mail

INTO

w_string . CALL METHOD cl_http_client=>create_by_url

EXPORTING

url = w_string

IMPORTING

client = http_client

EXCEPTIONS

argument_not_found = 1

plugin_not_active = 2

internal_error = 3

OTHERS = 4. CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2. CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

CLEAR w_result .

w_result = http_client->response->get_cdata( ). REFRESH result_tab .

SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab . READ TABLE result_tab INTO r_str INDEX 2.

IF r_str+44(1) = 't'.

WRITE:/ 'Valid email address'.

ELSE.

WRITE:/ 'Invalid email address'.

ENDIF.

3 REPLIES 3

praveen_reddy2
Active Participant

praveen_reddy2
Active Participant
0 Kudos

Calling a web service in ABAP that validates an email id

REPORT zvalidate_email.PARAMETERS: p_mail(100) LOWER CASE. " E-Mail id to be verifiedDATA: http_client TYPE REF TO if_http_client .DATA: w_string TYPE string ,

w_result TYPE string ,

r_str TYPE string .DATA: result_tab TYPE TABLE OF string.START-OF-SELECTION .

CLEAR w_string .

CONCATENATE

'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email=' p_mail

INTO

w_string . CALL METHOD cl_http_client=>create_by_url

EXPORTING

url = w_string

IMPORTING

client = http_client

EXCEPTIONS

argument_not_found = 1

plugin_not_active = 2

internal_error = 3

OTHERS = 4. CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2. CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

CLEAR w_result .

w_result = http_client->response->get_cdata( ). REFRESH result_tab .

SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab . READ TABLE result_tab INTO r_str INDEX 2.

IF r_str+44(1) = 't'.

WRITE:/ 'Valid email address'.

ELSE.

WRITE:/ 'Invalid email address'.

ENDIF.

Former Member
0 Kudos

Thanks praveenreddys

this program is with me but i am not able to understand anything.

using method...... and all how to use it can you please explain me.