1

Здравствуйте,

С помощью кода PL SQL я получаю ответ от сервера в ввиде строки XML.

Вот, собственно, сам код, которым я получаю XML.

create or replace procedure publish_cinema_even
is
  req utl_http.req;
  res utl_http.resp;
  url varchar2(4000) := 'https://alsytto.onlyoffice.eu/api/2.0/[email protected]&password=password';
  name varchar2(4000);
  buffer varchar2(4000); 
  content varchar2(4000) := '{}';

begin
  utl_http.set_wallet ('file:c:\app\wallet2','test1234');
  utl_http.set_detailed_excp_support (true);
  req := utl_http.begin_request(url, 'POST',' HTTP/1.1');

  --UTL_HTTP.set_wallet('file:/c:\app\oraUser\product\12.1.0\dbhome_1\BIN\wallets', 'test1234');
  --utl_http.set_header(req, 'user-agent', 'mozilla/4.0'); 
  --utl_http.set_header(req, 'content-type', 'application/json'); 
  utl_http.set_header(req, 'Content-Length', length(content));

  utl_http.write_text(req, content);
  res := utl_http.get_response(req);
  -- process the response from the HTTP call
  begin 
    loop
      utl_http.read_line(res, buffer);
      dbms_output.put_line(buffer);
    end loop;
    utl_http.end_response(res);
  exception
    when utl_http.end_of_body 
    then
      utl_http.end_response(res);
  end;
end publish_cinema_even;

И после получаю такой ответ от сервера:

<result><count>1</count><status>0</status><statusCode>201</statusCode><response><token>oAf5U23dQqn0cSQzNuOwN7CLW7R+fiv4xV5Te7/YZ9IERMivUwUiQA9abO2U+maXGgygOwIZtLoLWFN04q1k4AV0+vGOsJiQadjt+4iOq0vs5mNImF5DsknhPsN9qA1N</token><expires>2017-09-14T10:53:56.2760087+03:00</expires><sms>false</sms><phoneNoise /></response></result>

Помогите распарсить этот ответ и записать token в переменную.

1 ответ 1

1

Для получения token из xml находящего в переменной buffer в переменную token используйте следующий запрос:

 select extractValue(xmltype(buffer),'//token') into token from DUAL;

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.