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: 

How to get the response from a Web Service

michael_fallenbchel
Active Participant
0 Kudos

Hi experts,

I've got a web service that response me a "save as" dialog (to save the image).

I now want that image as a xstring.

Tried it this way:

CALL METHOD cl_http_client=>create_by_url
  EXPORTING
    url                = url_pic
  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.

DATA: x_result TYPE xstring.
x_result = http_client->response->to_xstring( ).

It works, I have a xstring after that. When I save this via GUI-DOWNLOAD (after converting to binary) I got a image-file.

Problem is that it has now a filesize of 550kb - when I call the Web Service direct from my internet explorer it just have 55 kb.

Where is the mistake or how to get the response correctly?

Regards

Michael

2 REPLIES 2

michael_fallenbchel
Active Participant
0 Kudos

Answered on my own:

Just have to use

x_result = http_client->response->get_data( ).

instead of

x_result = http_client->response->to_xstring( ).

Just don't knwo why the filesize is wrong also - but I can work with this image!

michael_fallenbchel
Active Participant
0 Kudos

If anybody knows how to reduce the size of the picture please let me know...