 
CREATE OR REPLACE	   
PROCEDURE HTTPTEST IS	   
	   
-- constants	   
HYSM_USER        CONSTANT VARCHAR2(256):= '6502';                                           	   
HYSM_PASS        CONSTANT VARCHAR2(256):= '1103';                                           	   
LOGIN_URI        CONSTANT VARCHAR2(256):=   	   
                   'http://gawl.hysm.de/servlets/HysmOnline';    	   
WORK_URI         CONSTANT VARCHAR2(256):= 	   
                   'http://gawl.hysm.de/servlets/HysmXMLsrv';   	   
	   
- variables	   
v_anfrage        VARCHAR2(32767);	   
v_length         PLS_INTEGER;	   
v_login          VARCHAR2(1024);	   
v_login_length   PLS_INTEGER;	   
v_logout         VARCHAR2(1024);	   
v_logout_length  PLS_INTEGER;	   
	   
login_req        utl_http.req;	   
logout_req       utl_http.req;	   
req              utl_http.req;	   
login_resp       utl_http.resp;	   
logout_resp      utl_http.resp;	   
resp             utl_http.resp;	   
value            VARCHAR2(1024);	   
v_anzahl_cookies PLS_INTEGER;	   
v_cookies        utl_http.cookie_table;	   
	   
BEGIN -- HTTPTEST	   
  -- XML-Sendedokumente zusammensetzen	   
  v_login := '<?xml version="1.0" encoding="ISO-8859-1"?>'	   
             ||'<HYSM-LOGIN>'	   
             ||'<KENN>'||HYSM_USER||'</KENN>'	   
             ||'<PASS>'||HYSM_PASS||'</PASS>'	   
             ||'</HYSM-LOGIN>';	   
	   
  v_login_length := length(v_login);	   
	   
  v_logout := '<?xml version="1.0" encoding="ISO-8859-1"?>'	   
              ||'<HYSM-LOGOUT>'	   
              ||'<LOGOUT>logout</LOGOUT>'	   
              ||'</HYSM-LOGOUT>';	   
	   
  v_logout_length := length(v_logout);	   
	   
  v_anfrage := '<?xml version="1.0" encoding="ISO-8859-1"?>'	   
               || '<HYSM-ANFRAGE><KOPF><ABC>'	   
               ||'OMG</ABC><DE>XY</DE><KENN>'	   
               ||HYSM_USER	   
               ||'</KENN><ARGL>0</ARGL><PERS>'	   
               ||'ANONYMOUS</PERS></KOPF><DETAIL>'	   
               ||'<MODEL>Commodore CBM 8096</MODEL>'	   
               ||'</DETAIL></HYSM-ANFRAGE>';	   
	   
  v_length := length(v_anfrage);	   
	   
  -- Proxy einstellen	   
  UTL_HTTP.set_proxy (proxy => '192.168.101.202:8080',	   
                      no_proxy_domains => NULL);	   
	   
  -- Login-Request zusammenstellen	   
  login_req := utl_http.begin_request(url => LOGIN_URI,	   
                                      method => 'POST',	   
                                http_version => UTL_HTTP.HTTP_VERSION_1_0);	   
	   
  -- Automatische Cookieverwaltung einschalten	   
  UTL_HTTP.set_cookie_support(r => login_req, enable => TRUE);	   
	   
  -- HTTP-Headerzeilen setzen	   
  UTL_HTTP.set_header(r => login_req,	   
                      name  => 'Content-type',	   
                      value => 'application/x-www-form-urlencoded');	   
  UTL_HTTP.set_header(r => login_req,	   
                      name  => 'Content-length',	   
                      value => to_char(v_login_length));	   
  UTL_HTTP.set_header(r => login_req,	   
                      name  => 'Connection',	   
                      value => 'close');	   
  UTL_HTTP.write_text(r    => login_req, data => v_login);	   
	   
  -- Login-Request senden, und Antwort entgegennehmen	   
  login_resp := utl_http.get_response(login_req);	   
	   
  -- Antwort auslesen und ausgeben	   
  BEGIN	   
    LOOP	   
      utl_http.read_line(login_resp, value, TRUE);	   
      dbms_output.put_line(value);	   
    END LOOP;	   
    utl_http.end_response(login_resp);	   
	   
  EXCEPTION	   
    WHEN utl_http.end_of_body THEN	   
      utl_http.end_response(login_resp);	   
  END;	   
	   
  -- Anfrage-Request zusammenstellen	   
  req := utl_http.begin_request(url => WORK_URI,	   
                                method  => 'POST',	   
                                http_version => UTL_HTTP.HTTP_VERSION_1_0);	   
	   
  -- Automatische Cookieverwaltung einschalten	   
  UTL_HTTP.set_cookie_support(r => req, enable => TRUE);	   
	   
  -- HTTP-Headerzeilen setzen	   
  UTL_HTTP.set_header(r => req,	   
                      name  => 'Content-type',	   
                      value => 'application/x-www-form-urlencoded');	   
  UTL_HTTP.set_header(r => req,	   
                      name  => 'Content-length'	   
                      value => to_char(v_length));	   
  UTL_HTTP.set_header(r => req,	   
                      name  => 'Connection',	   
                      value => 'close');	   
  UTL_HTTP.write_text(r => req, data => v_anfrage);	   
	   
  -- Anfrage-Request senden, und Antwort entgegennehmen	   
  resp := utl_http.get_response(req);	   
	   
  -- Antwort auslesen und ausgeben	   
  BEGIN	   
    LOOP	   
      utl_http.read_line(resp, value, TRUE);	   
      dbms_output.put_line(value);	   
    END LOOP;	   
    utl_http.end_response(resp);	   
	   
  EXCEPTION	   
    WHEN utl_http.end_of_body THEN	   
      utl_http.end_response(resp);	   
  END;	   
	   
  -- Logout-Request zusammenstellen	   
  logout_req := utl_http.begin_request(url => LOGIN_URI,	   
                                       method => 'POST',	   
                                       http_version => 	   
                                                UTL_HTTP.HTTP_VERSION_1_0);	   
	   
  -- Automatische Cookieverwaltung einschalten	   
  UTL_HTTP.set_cookie_support(r => logout_req, enable => TRUE);	   
	   
  -- HTTP-Headerzeilen setzen	   
  UTL_HTTP.set_header(r => logout_req,	   
                      name => 'Content-type',	   
                      value => 'application/x-www-form-urlencoded');	   
  UTL_HTTP.set_header(r => logout_req,	   
                      name => 'Content-length',	   
                      value => to_char(v_logout_length));	   
  UTL_HTTP.set_header(r => logout_req,	   
                      name => 'Connection',	   
                      value => 'close');	   
  UTL_HTTP.write_text(r => logout_req, data => v_logout);	   
	   
  -- Anfrage-Request senden, und Antwort entgegennehmen	   
  logout_resp := utl_http.get_response(logout_req);	   
	   
  -- Antwort auslesen und ausgeben	   
  BEGIN	   
    LOOP	   
      utl_http.read_line(logout_resp, value, TRUE);	   
      dbms_output.put_line(value);	   
    END LOOP;	   
    utl_http.end_response(logout_resp);	   
	   
  EXCEPTION	   
    WHEN utl_http.end_of_body THEN	   
      utl_http.end_response(logout_resp);	   
  END;	   
	   
END HTTPTEST;	   
/	 
