cancel
Showing results for 
Search instead for 
Did you mean: 

sending an xml file to a HTTPS RFC Destination

0 Kudos
1,194

I have created an xml output file via ABAP and want to pass this file to an HTTPS RFC destination we have set up. Any tips on the best way to do this without going down the XI or BC route?

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

you need to use cl_http_client class

DATA: http_client TYPE REF TO if_http_client .

DATA: wf_string TYPE string .

DATA: wf_string1 TYPE string .

CALL METHOD cl_http_client=>create
  EXPORTING
    host          = 'www.xxxxx.com'
    service       = '80'
    scheme        = '2'  "1 fot http 2 https
  IMPORTING
    client        = http_client.

 
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = '~request_method'
    value = 'POST'.
 
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = '~server_protocol'
    value = 'HTTP/1.1'.
 
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = 'Content-Type'
    value = 'text/xml; charset=utf-8'.
 
 
 
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( ).
 

hope this helps

regards

raja

0 Kudos

I had a similar view, but as I already have the RFC destination set up I thought I could use functions such as:

call method cl_http_client=>create_by_destination

exporting destination = dest

importing client = 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 FUNCTION 'RFC_READ_HTTP_DESTINATION'

EXPORTING

DESTINATION = dest

AUTHORITY_CHECK = ' '

IMPORTING

  • RFCTYPE =

SERVICENR = servicenr

SERVER = server

  • TRACE =

  • LANGUAGE =

  • CLIENT =

  • USER =

  • PASSWORD =

  • DESCRIPTION =

  • PROXY_HOST =

  • PROXY_SERVICE =

PATH_PREFIX = uri

  • DESTLOCK =

  • AUTHORITY =

  • SLOGIN =

  • SAMEUSR =

EXCEPTIONS

AUTHORITY_NOT_AVAILABLE = 1

DESTINATION_NOT_EXIST = 2

INFORMATION_FAILURE = 3

INTERNAL_FAILURE = 4

OTHERS = 5.

then proceed to the set data and send commands, am I on the right track and what format do I need to pass the table, which contains the xml file, to the set data command.

Answers (1)

Answers (1)

Former Member
0 Kudos

Brian, having just gone through this, the most difficult part was installing the correct certificate (transaction STRUST). Also HTTPS must be started in the ICM.

Buster hale

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If you need some screen shots (specifically for the STRUST setup) have a look at the following weblog:

/people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap

0 Kudos

Thanks Buster, found that as well however have already authenticated that the certification is working by converting standard idocs into xml and passing those.