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

dmp in cl_http_client

Former Member
0 Likes
883

Any idea how to solve my dump ?? Im working with 4.6C version...

I have the follow code:

destination = 'HTTP EXTERNO'. '' a RFC configuration

*

call method cl_http_client=>create_by_destination

exporting destination = destination

importing client = http_client

exceptions

destination_not_found = 01

internal_error = 02

argument_not_found = 03

destination_no_authority = 04

plugin_not_active = 05

others = 06.

call method client->request->set_header_field

exporting

name = '~request_method'

value = 'POST'.

call method client->request->set_header_field

exporting

name = '~server_protocol'

value = 'HTTP/1.0'.

call method client->request->set_header_field

exporting

name = 'content-type'

value = 'text/xml'.

CALL METHOD http_client->request->set_cdata

EXPORTING

data = wf_string "variable holding the xml string

offset = 0

length = rlength.

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 wf_string1 .

wf_string1 = http_client->response->get_cdata( ).

*

When I run my program I get the follow dump :

"Attempt to access a component using 'NULL' object reference (points

to nothing).

An object reference must point to an object (an instance of a class)

before you can use it to access components (variable: " ").

Either the reference has not yet been set, or it has been reset to

'NULL' by a CLEAR statement."

I did a debug and the error occurs when Im executing the

"call method client->request->set_header_field"

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
759

the following call returns the instantiated http_client you should use it

call method cl_http_client=>create_by_destination
exporting destination = destination
importing client = <b>http_client</b>
exceptions
destination_not_found = 01
internal_error = 02
argument_not_found = 03
destination_no_authority = 04
plugin_not_active = 05
others = 06.

so instead of 
call method<b> client</b>->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.

you should use
call method<b> http_client</b>->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.

Regards

Raja

3 REPLIES 3
Read only

Former Member
0 Likes
759

Hi Cristina,

In "call method client->request->set_header_field" which class "client" refers to and have you created reference to the class and created object. In this case it appears like you are using object called client without instantiating it.

Thanks,

Ramesh

Read only

0 Likes
759

Hi Ramesh

Thank u very much for ur help.

I dont know methods, class very well.

I did declared the "client" as below

DATA: client TYPE REF TO if_http_client.

Actually this code I copied from examples in SDN and others ABAP forums.

But I still get the error.

Any idea will be more than welcome.

Br.

Cristina

Read only

athavanraja
Active Contributor
0 Likes
760

the following call returns the instantiated http_client you should use it

call method cl_http_client=>create_by_destination
exporting destination = destination
importing client = <b>http_client</b>
exceptions
destination_not_found = 01
internal_error = 02
argument_not_found = 03
destination_no_authority = 04
plugin_not_active = 05
others = 06.

so instead of 
call method<b> client</b>->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.

you should use
call method<b> http_client</b>->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.

Regards

Raja