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: 

Error while writing a code for sending SMS in METHOD http_client_receive

Former Member
0 Kudos
220

Hi friends,

I have a requirement, where i have to send a SMS from SAP system, i tried follwing codes but in both it is giving me same error. HTTP path mensioned below[ztest_02] is provided by service provider.

I tried the same url in explorer and i received the SMS properly.

REPORT ztest_02.

CONCATENATE

'http://hapi.smsapi.org/SendSMS.aspx?UserName=xyz&password=586998&MobileNo=919836789543'

'&SenderID=serdc&CDMAHeader=919833678945&Message=Hirdffan' INTO wf_string .

CALL METHOD cl_http_client=>create_by_url

EXPORTING

url = wf_string

IMPORTING

client = http_client

EXCEPTIONS

argument_not_found = 1

plugin_not_active = 2

internal_error = 3

OTHERS = 4.".......................THIS IS WORKING FINE .. RETURNS SY-SUBRC = 0

CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2.".......................THIS IS WORKING FINE .. RETURNS SY-SUBRC = 0

CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.".......................NOT WORKING FINE .. RETURNS SY-SUBRC = 1

-


I COPIED ANOTHER CODE FROM NET WHICH IS AS FOLLOWS AS GIVES SAME SY-SUBRC IN SAME METHOD.

CONCATENATE 'http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName='

p_cnt INTO http_url .

CALL METHOD cl_http_client=>create_by_url

EXPORTING

url = http_url

IMPORTING

client = http_client

EXCEPTIONS

argument_not_found = 1

plugin_not_active = 2

internal_error = 3

OTHERS = 4. " ...RETURNS SY-SUBRC = 0

http_client->request->set_header_field( name = '~request_method'

value = 'GET' ).

http_client->send( ).

CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3

OTHERS = 4. '".........THIS RETURNS SY-SUBRC = 0

My question is why it is failing in same call...

Is there any authorisation issues?

Any call is missing in between?

Is there any network issue?

pls help........

Edited by: kiran chorge on Mar 11, 2010 7:42 AM

2 REPLIES 2

Former Member
0 Kudos
118

Hi Krian,

You can start by checking if your http requests go through a proxy server, and if yes, have they been set on your application server. Check with your BASIS team for more info on this.

As i do not have access to an system right now, i am not able to test your code...to see if there is anything wrong with that.

All the best,

Chen

aditya_niyogi
Participant
0 Kudos
118

Hi Kiran,

I just resolved this error in my system. If you are running on AIX, then your DNS server will most likely not be configured. To fix this you just have to make the HTTP call without the domain name.

Just ping the HTTP and find out which IP it is going to, then rewrite your HTTP address as below :

http://<IP ADDRESS>/SendSMS.aspx?UserName=xyz&password=586998&MobileNo=919836789543'

'&SenderID=serdc&CDMAHeader=919833678945&Message=Hirdffan

This should resolve your error. Also the HTTP message you are getting in the given method actually refers to the problem in conversion of a domain name to an IP address as the DNS server is not available. So everything is most likely working fine.

Thanks & Regards,

Aditya