|
|
|
UTL_HTTP - Temporary Redirect или как найти новый location
|
|||
|---|---|---|---|
|
#18+
Суть проблемы в том, что отправляя первый soap запрос по http каналу я авторизуюсь в системе, при этом происходит редирект (http_resp.status_code is :307; http_resp.reason_phrase is :Temporary Redirect) на уникальный location, который который необходимо подставлять для последующих запросов. Как я понял, новый локейшен автоматически пропишется со слов оракла (The URL and method fields in the REQ record will be updated to the last redirected URL and the method used to access the URL.), но на самом деле он шлет запрос все по старому адресу. Так вопрос стоит в том - как найти новый location? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.07.2016, 17:45 |
|
||
|
UTL_HTTP - Temporary Redirect или как найти новый location
|
|||
|---|---|---|---|
|
#18+
Сначало шлется запрос с такими параметрами: POST / HTTP/1.1 Content-Type: text/xml;charset=UTF-8 SOAPAction: "Notification" User-Agent: Jakarta Commons-HttpClient/3.1 Host: 111.22.20.100:8001 Content-Length: 201 А потом идет редирект и получаем новый Location ( как его вытянуть из запроса через оракл?!): HTTP/1.1 307 Temporary Redirect Location: http://111.22.20.100:8001/00500000 Server: Huawei web server Content-Type: text/xml; charset="utf-8" Content-Length: 407 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.08.2016, 11:08 |
|
||
|
UTL_HTTP - Temporary Redirect или как найти новый location
|
|||
|---|---|---|---|
|
#18+
Решил проблему с поиском нового Адреса, куда шлется запрос: код FOR i IN 1 .. utl_http.get_header_count(http_resp) LOOP utl_http.get_header(http_resp, i, name, value); if name = 'Location' then new_address := trim(value); end if; Но вот проблема, когда я открываю новое соединение и шлю запрос, пишет, что адрес невалиден. Вопрос как в рамках одной сессии изменить адрес в функции utl_http.begin_request? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.12.2016, 11:55 |
|
||
|
UTL_HTTP - Temporary Redirect или как найти новый location
|
|||
|---|---|---|---|
|
#18+
lsd-super, Приведите полный образец кода ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.12.2016, 12:10 |
|
||
|
UTL_HTTP - Temporary Redirect или как найти новый location
|
|||
|---|---|---|---|
|
#18+
env, КОДdeclare error_log varchar2(2000); v_active_contracts number(3); v_active_sim number(3); v_state_count number(3); v_check_contracts number(3); v_state_msisdn varchar2(20); v_user varchar2(30); http_req utl_http.req; http_resp utl_http.resp; request_env varchar2(32767); response_env varchar2(32767); error_details varchar2(32767); http_req2 utl_http.req; http_resp2 utl_http.resp; request_env2 varchar2(32767); response_env2 varchar2(32767); name VARCHAR2(256); value VARCHAR2(1024); new_address varchar2(1000); begin request_env := '<soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <LGI> <OPNAME>>US</OPNAME> <PWD>PASS</PWD> </LGI> </soapenv:Body> </soapenv:Envelope>'; http_req := utl_http.begin_request('http://10.1.34.21:8001/', 'POST', utl_http.HTTP_VERSION_1_1); utl_http.set_header(http_req, 'Content-Type', 'text/xml; charset=utf-8'); utl_http.set_header(http_req, 'Content-Length', length(request_env)); utl_http.set_header(http_req, 'Connection', 'keep-alive'); utl_http.write_text(http_req, request_env); http_resp := utl_http.get_response(http_req); FOR i IN 1 .. utl_http.get_header_count(http_resp) LOOP utl_http.get_header(http_resp, i, name, value); if name = 'Location' then new_address := trim(value); end if; END LOOP; utl_http.read_text(http_resp, response_env); dbms_output.put_line(response_env); utl_http.end_response(http_resp); --utl_http.end_request(http_req); dbms_output.put_line(new_address); --dbms_lock.sleep(5); request_env := '<soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ADD_KI> <HLRSN>1</HLRSN> <IMSI>863456789102228</IMSI> <OPERTYPE>ADD</OPERTYPE> <KIVALUE>11111111111111111111111111111111</KIVALUE> <CARDTYPE>SIM</CARDTYPE> <ALG>COMP128_1</ALG> </ADD_KI> </soapenv:Body> </soapenv:Envelope>'; http_req2 := utl_http.begin_request(new_address, 'POST', utl_http.HTTP_VERSION_1_1); utl_http.set_header(http_req2, 'Content-Type', 'text/xml; charset=utf-8'); utl_http.set_header(http_req2, 'Content-Length', length(request_env)); utl_http.write_text(http_req2, request_env); http_resp := utl_http.get_response(http_req2); utl_http.read_text(http_resp, response_env); dbms_output.put_line(response_env); -- utl_http.end_response(http_resp); utl_http.end_response(http_resp); end; ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.12.2016, 12:41 |
|
||
|
|

start [/forum/topic.php?fid=52&msg=39284417&tid=1886823]: |
0ms |
get settings: |
10ms |
get forum list: |
20ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
168ms |
get topic data: |
9ms |
get forum data: |
2ms |
get page messages: |
46ms |
get tp. blocked users: |
1ms |
| others: | 236ms |
| total: | 498ms |

| 0 / 0 |
