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 send an XML file via HTTP_POST

Former Member
0 Kudos

I have an ABAP program that creates an XML file and I need to somehow post this XML file to a webserver and read the HTTP Response that it sends back. I see that there is a function module called HTTP_POST but I've never used it before. I also see that there are a number of ABAP Objects related to HTTP. Has anyone done this before.

I'm on SAP 4.7 (6.20)

Thank you,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Tony,

if you are trying to post a simple XML message, you have to use the HTTP adapter which has the URL

http://servername:8000/sap/xi/adapter_plain

<REMOVED BY MODERATOR>

Cheers,

Chaitanya.

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:57 PM

17 REPLIES 17

Former Member
0 Kudos

Check this link...

Regards,

Maha

Former Member
0 Kudos

Hi Tony,

if you are trying to post a simple XML message, you have to use the HTTP adapter which has the URL

http://servername:8000/sap/xi/adapter_plain

<REMOVED BY MODERATOR>

Cheers,

Chaitanya.

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:57 PM

0 Kudos

Currently we just have 1 R/3 Enterprise (4.7 / 6.20) box running in PRD. Do I need to set up another system with XI in order to do this communication via HTTP? We currently don't have an XI system, but I could set one up. I guess I'm looking for the best way to configure our SAP R/3 system to communicate via HTTP POST. I thought I could do it directly from our R/3 box. What are the best practices? Thank you

0 Kudos

Hi Tony,

You dont need XI you can directly communicate over HTTP and thats why the application server is now called SAP Web Application Server . as Gaurav mentioned you can just use CL_HTTP_CLIENT class to make your program work like a http client which can send requests and receive response.

if you just do a where used list for cl_http_client class you should find few samples. If you still have problem, post your issues here.

Regards

Raja

0 Kudos

check this weblog for sample code on how to post xml over http.

/people/durairaj.athavanraja/blog/2004/09/20/consuming-web-service-from-abap

Regards

Raja

0 Kudos

Thanks for the reply. I tried to run your sample program but it fails when it tries the http_client->receive (RC = 1). Is there something that needs to be installed or configured before you can communicate via HTTP?

Thank you,

0 Kudos

I checked transaction SICF and every node was inactive. Do I need to configure something in this transaction? Also, do I need to add an entry into the HOST file of the WEBAS? If so, what is the entry?

Thanks for all your help.

0 Kudos

OK, I changed the instance profile to use port 8050 instead of 8000 and that got me past my http_communication_failure error. However, now I get

ABAP XML formatting error in XML node of type "element", name: "abap"

wf_string1 does contain an XML message, however it still throws an error during the XLST transformation.

Thank you,

0 Kudos

I tried to take what I learned from your example and apply it to my ABAP program. However, I realized that I'm trying to post to HTTPS and my program fails with the same old error: http_communication_failure. So, I set the profile parameter as such:

icm/server_port_2

PROT=HTTPS,PORT=8443,EXTBIND=1

However, I can't activate the service. Here is the log when I try to activate:

[Thr 8064] =================================================

[Thr 8064] = SSL Initialization on PC with Windows NT

[Thr 8064] = (640_REL,Jan 15 2006,mt,ascii,SAP_UC/size_t/void* = 8/32/32)

[Thr 8064] *** ERROR => DlLoadLib: LoadLibrary(E:\usr\sap\DEV\SYS\exe\run\sapcrypto.dll) Error 126 [dlnt.c 237]

[Thr 8064] Error 126 = "The specified module could not be found."

[Thr 8064] *** ERROR => secudessl_LoadLibrary(): Unable to load "E:\usr\sap\DEV\SYS\exe\run\sapcrypto.dll" [ssslsecu.c 352]

[Thr 8064] *** ERROR => Loading of SSL library failed NO SSL available!

[Thr 8064] =================================================

[Thr 8064] <<- ERROR: SapSSLInit(read_profile=1)==SSSLERR_LIB_NOT_FOUND

[Thr 8064] *** ERROR => IcmIActivateService: SapSSLInit (rc=-1): SSSLERR_LIB_NOT_FOUND [icxxserv.c 760]

[Thr 8064] *** ERROR => IcmHandleMonServMsg: IcmActivateService failed for 8443, 2(rc=-14) [icxxmsg.c 1771]

0 Kudos

for HTTPS check this weblog.

/people/thomas.jung3/blog/2005/05/13/calling-webservices-from-abap-via-https

Regards

Raja

0 Kudos

Raja,

I'm trying to post and XML file via HTTP Post to:

https://gatewaybeta.fedex.com:443/GatewayDC

How can I obtain the certificate from this address? Is that possible? In the weblog provided the web service was internal so the developer had control over the service and access to the cert.

Thank you,

0 Kudos

I went to www.fedex.com and exported their SSL cert. I then imported it into SAP via STRUST. However, I still get the same http_communication_error. The XML needs to be posted to this address: 'https://gatewaybeta.fedex.com:443/GatewayDC'

Here is my code:

Note: wf_string contains the XML

CALL METHOD cl_http_client=>create

EXPORTING

host = 'https://gatewaybeta.fedex.com'

service = '443'

scheme = '2'

  • proxy_host = wf_proxy

  • proxy_service = wf_port

IMPORTING

client = http_client.

http_client->propertytype_logon_popup = http_client->co_disabled.

wf_user = '' .

wf_password = '' .

  • proxy server authentication

CALL METHOD http_client->authenticate

EXPORTING

proxy_authentication = 'X'

username = wf_user

password = wf_password.

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 = '~request_uri'

value = 'https://gatewaybeta.fedex.com:443/GatewayDC'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Type'

value = 'text/xml; charset=utf-8'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Length'

value = txlen.

*CALL METHOD http_client->request->set_header_field

  • EXPORTING

  • name = 'SOAPAction'

  • value = 'https://gatewaybeta.fedex.com:443/GatewayDC'

.

CALL METHOD http_client->request->set_cdata

EXPORTING

data = wf_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( ).

0 Kudos

I think I have the HTTPS service setup correctly. HTTPS is started, the cert is loaded into STRUST and the HTTP Library is in the kernel directory. Below is the log from SMICM:

[Thr 7524] Mon Dec 17 12:51:07 2007

[Thr 7524] *** WARNING => Connection request from (17/18/0) to host: https://gatewaybeta.fedex.com, service: 443 failed (NIEHOST

RM-T17, U18, 300 TRAIMO, TRAIMOXP, 12:51:07, M0, W2, SE38, 2/2 [icxxconn.c 2121]

Thanks again for your help. I think I'm very close to solving my problem.

0 Kudos

It's working now. I just needed to use "gatewaybeta.fedex.com" instead of https://gatewaybeta.fedex.com.

Thanks for all your help. <REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:58 PM

0 Kudos

Glad to know its working fine now. sorry i was on holiday and couldnt reply to your thread immediately

Former Member
0 Kudos

Hi,

Use class CL_HTTP_CLIENT. there is a method SET_HEADER_FIELD , u can use POST in that.

It will be something like below:

data: client type ref to if_http_client.

  • ur code to call the webservice API (method CREATE or CREATE_BY_URL

CALL METHOD client->request->set_header_field

EXPORTING

name = '~request_method'

value = 'POST'.

It will work.

cheers

gaurav

Former Member
0 Kudos

Hi,

How to export the ssl certificate from FedEx site. and import into STRUST.

Could you please help on this.

I am working on calling fedex web service for proof of delivery,

Thanks for your help in advance

Raju