06-16-2010 8:58 AM
i have to call login.ford.com.tr for authentication with u2018https://login.xxx.com/authenticate.aspx?userid=&password=u2019
But i have to call u2018https://fosnapp.xxx.com/get_orders.aspx?order_id=u2018 to get data.
As you see the host name of this two address is different.
If i create two CL_HTTP_CLIENT instance for each link ( http_authentication and http_data ) in my program. I could not get any data by http_data instance. (I think this is normal because each instance creates its own session)
If i create only one instance for u2018https://fosnapp.xxx.comu2019 than call two link by this instance. It gives error that says you are not logged in.
Below is summary of my code. What can i do for this complex case? Thanks.
Musa
call method cl_http_client=>create_by_url
exporting
url = lv_url
SSL_ID = 'XXX'
importing
client = http_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
http_client->request->set_header_field( name = '~request_method'
value = 'POST' ).
CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = '~request_uri'
VALUE = lv_login_all.
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.
gv_str = http_client->response->get_cdata( ).
CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = '~request_uri'
VALUE = lv_data_url.
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.
gv_str = http_client->response->get_cdata( ).
Edited by: MusaCEBE on Jun 16, 2010 9:58 AM
06-16-2010 1:33 PM
This is not a Web Dynpro related question and therefore doesn't belong in this form. I am moving it to ABAP general.
You definetely can't use two different instances of CL_HTTP_CLIENT (as you found out) as you would have two different sessions and authentication can't be shared between them.
Otherwise I can't say why you aren't getting authenticated. You should be able to change URLs between calls as you have done. What authentication mechanism is the site using? Some form of cookie based authentication. Do you have your CL_HTTP_CLIENT set to accept cookies? Can you look at the request/response object in the debugger and see the cookie?
It is really difficult to speculate further without knowing more about the authentication mechanism being used.
07-01-2010 1:52 PM
Hi Mr. Thomas
How can i get the values into a variable?
I can see the cookie value byi debugging http_client->receive_cookies method while i call receive method of http_client.
But i can not get the values into program variable.
I have used http_client->response->get_cookies( changing cookies = cookies ).
Regards.
Musa
07-01-2010 6:18 PM
07-04-2010 4:45 PM
Mr. Thomas I know how to read the values if it returns any value into cookies internal table. But it returns the cookies internal table with null value . I see the values when i set the attribute IF_HTTP_CLIENTPROPERTYTYPE_ACCEPT_COOKIE of the client instance with value IF_HTTP_CLIENTCO_PROMPT in foreground.
09-23-2010 6:12 AM
Hi MusaCEBE and Mr. Thomas,
I am facing the same problem as you did. Can you please tell me, how did you solved it.
09-23-2010 3:34 PM
Hi i could not solve the problem with abap. We developed another application by using another programming language for this issue.
But i think you should create an instance for authantication. After authantication you should get the cookies .
Then create a new instance for other link and before send and receive methods set cookies ( which you got from authantication session ) for other link in ABAP.
We did not have enough time to solve this in ABAP. Hope you will solve. If you solve please let me know how you have solved.
Here is the code(another programming language), may be it will help you.
req = (HttpWebRequest)WebRequest.Create(@"https://login.xxx.com/authenticate.aspx?userid=xxx&password=xxx");
req.CookieContainer = cc;
HttpWebResponse httpResponse = (HttpWebResponse)req.GetResponse();
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(@"https://yyy.com/postxml.aspx");
httpRequest.CookieContainer = cc;
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml";
Edited by: MusaCEBE on Sep 23, 2010 4:34 PM