on 09-25-2008 3:40 PM
Hi Everyone,
I have a simple requirement which is to retrieve the HTML of a BSP which is password protected. This is not a problem as the code for this is all over SDN and looks something like this
function z_get_html_body .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(URL) TYPE STRING
*" EXPORTING
*" VALUE(BODY) TYPE XSTRING
*" VALUE(BODY_SIZE) TYPE I
*" EXCEPTIONS
*" SYSTEM_ERROR
*"----------------------------------------------------------------------
data: client type ref to if_http_client,
lv_body_size type string.
call method cl_http_client=>create_by_url
exporting
url = url
importing
client = client.
call method client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
raising system_error.
endif.
call method client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
raising system_error.
endif.
body = client->response->get_data( ).
lv_body_size = xstrlen( body ).
move lv_body_size to body_size.
call method client->close.
endfunction.
The problem is that since the URL is password protected by SAP, I need to encode the system user name and password into the URL so that the URL is like this
http://<username>:<pwd>@<server>:<port>/mybsp/index.html
But this means that I must store the username and password in some table somewhere where it can be viewed by anyone with SE16 access.
I am hoping there is a better way.
One option I did consider was using an RFC destination of type H (HTTP connection to R/3 system) and then specifying the username and password in the logon details. This works great but it leaves me with the following issues:
1. What If i dont want to access index.html but another page? Do I need to create an RFC destination for each page I want to access?
2. What if I need to pass parameters? How do I do that as the parameters to be passed will be determined at runtime by my code.
Perhaps the whole RFC destination is a dead end and there is a better way but I look forward to yoru ideas.
Alon
if you are just trying to get the BSP pagesource checkout this program
BSP_SHOW_SOURCE
else if you are trying to execute the page
then
option 1:
pass the user id pwd as importing parameter of the FM
call method cl_http_client=>create_by_url
exporting
url = url
importing
client = http_client
exceptions
others = 1.
http_client->propertytype_logon_popup = http_client->co_disabled.
call method http_client->authenticate
exporting
proxy_authentication = ' '
username = wf_user
password = wf_password.
option 2:
call method cl_http_client=>create_by_url
exporting
url = url
importing
client = http_client
exceptions
others = 1.
http_client->propertytype_logon_popup = http_client->co_disabled.
call method http_client->send_sap_logon_ticket .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An excellent suggestion. Thank you. Option 2 comes very close to what I need unfortunately I dont think it will work.
The problem is my program will run in batch and so the batch user wont have a MYSAPPSSO2 cookies to send. So the I am afraid the login will fail.
Unless you are aware of some way for the batch user to get a MYSAPSSO2 cookie...
Alon
Thanks Raja,
SSO is configured correctly as we use it for other things. I tested the BSP that you sent and it indicated that all was well and a MYSAPSSO2 cookie was set.
Here is what doesnt make sense to me. How does your batch user get the MYSAPSSO2 cookie? It has to authenticate somewhere in order for the system to set the cookie. Perhaps this is a setting when you schedule the batch job? Very weird....
Edited by: Alon Raskin on Oct 1, 2008 9:45 AM
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.