on 12-28-2005 1:09 AM
I have some problems to send a PDF FILE to a http server using if_http_client class with for example methods :
CALL METHOD client->request->set_header_field
CALL METHOD client->send
CALL METHOD client->receive
I dont want to use FM SO_NEW_DOCUMENT_ATT_SEND_API1, SO_NEW_DOCUMENT_ATT_SEND_MAPI , SO_NEW_DOCUMENT_SEND_API1
Could someone please give me a sample abap program doing this ?
It could be great.
Thanks
A snippet of code that works for me.
response->set_header_field( name = 'content-type'
value = 'application/pdf' ).
some Browsers have caching probs when loading PDF
response->set_header_field(
name = 'cache-control'
value = 'max-age=0' ).
l_pdf_xstring contains PDF data
l_pdf_len = XSTRLEN( l_pdf_xstring ).
response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
navigation->response_complete( ).
End of code
I am pretty sure SAP delivers an example that runs a smartform via a BSP and reders it as a PDF. Can't seem to find it though.
Cheers
Graham Robbo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to SDN.
1. upload the pdf file to a itab using GUI_UPLOAD (file type 'BIN') ( i assume that you are doing this abap program and not in BSP page)
2. create a instance of cl_http_client
call method cl_http_client=>create
exporting
host = 'www.server.com'
service = '80'
scheme = '1'
importing
client = http_client.
3. set header fields.
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 = 'application/pdf' .
call method http_client->request->set_data
exporting
data = <xstring holding the uploaded content>
offset = 0
length = rlength.
call method http_client->request->set_header_field
exporting
name = 'Content-Length'
value = txlen.
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 is clear.
Regards
Raja
Message was edited by: Durairaj Athavan Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
rlength is of type i and this will hold the lenght of the uploaded pdf content.
rlength is moved txlen because the method only accepts only char type variable.
wf_string1 is of type string and it will hold the message returned by the calling server.
check out this weblog where i have used this code.
/people/durairaj.athavanraja/blog/2004/09/20/consuming-web-service-from-abap
Hope this helps.
Regards
Raja
reward points by cliking the radiobutton for helpful answers. this is SDN way of saying thanks.
Thanks so lot, Raja, for your disponibility and your help,
See below the return status code I had from the HTTP SERVER after implementing the ABAP code :
**********************************************************
Error 406--Not Acceptable
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.7 406 Not Acceptable
The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.
Unless it was a HEAD request, the response SHOULD include an entity containing a list of available entity characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. Depending upon the format and the capabilities of the user agent, selection of the most appropriate choice may be performed automatically. However, this specification does not define any standard for such automatic selection.
Note: HTTP/1.1 servers are allowed to return responses which are not acceptable according to the accept headers sent in the request. In some cases, this may even be preferable to sending a 406 response. User agents are encouraged to inspect the headers of an incoming response to determine if it is acceptable. If the response could be unacceptable, a user agent SHOULD temporarily stop receipt of more data and query the user for a decision on further actions.
**********************************************************
Is there any other solution (other class, other methods) to do that because it 's not working or perhaps something wrong ?
Can you help me please.
TIA
is the receving server can accept pdf content. there is nothing wrong with your program, but you need to check with the receving server whether it can accept pdf.
and also check what kind of response they send.
you may need to use accept headers which is explained here
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Regards
Raja
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.