DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_HTTP

Source


1 PACKAGE BODY fnd_http AS
2 /* $Header: AFSCHTPB.pls 115.3 99/07/16 23:28:56 porting ship  $ */
3 
4 chr_newline varchar2(1) := '
5 ';
6 
7 -- Makes a http request to a java servlet. Parses the returned HTML
8 -- page and stores the values in the OUT parameters.
9 -- p_result is the value returned from the java servlet.This is
10 -- usually true or false, but it may also be error codes.
11 -- If the java program had any other information to return, these are
12 -- returned as a PL/SQL table of name-value pairs.
13 -- If the call failed, then the errors from the error stack are
14 -- returned in a PL/SQL table of encoded messages.
15 -- The caller should call fnd_message.set_encoded and fnd_message.get
16 -- to get the entire translated message.
17 
18 PROCEDURE java_serv( p_url IN VARCHAR2,
19 		     p_result OUT VARCHAR2,
20 		     p_output_tab OUT output_tab_type,
21 		     p_encoded_errors_tab OUT error_tab_type)
22   IS
23      serv_result VARCHAR2(25000);
24 
25      res_start INTEGER;
26      res_end INTEGER;
27 
28      out_list_start INTEGER;
29      out_list_end INTEGER;
30      out_start INTEGER;
31      out_end INTEGER;
32      out_list VARCHAR2(10000);
33      out_name_value VARCHAR2(300);
34      equal_pos INTEGER;
35      name VARCHAR2(30);
36      value VARCHAR2(240);
37 
38 
39      err_stack_start INTEGER;
40      err_stack_end INTEGER;
41      err_start INTEGER;
42      err_end INTEGER;
43      err_stack VARCHAR2(10000);
44      i INTEGER;
45 
46 BEGIN
47 
48    serv_result:=utl_http.request(p_url);
49    res_start:=Instr(serv_result,'<P>',1,1);
50    IF res_start=0 THEN
51       p_result:='false';
52       RETURN;
53    END IF;
54    res_start:=res_start+3;
55    res_end:=Instr(serv_result,'</P>',res_start,1);
56    p_result:=Ltrim(Rtrim(Substr(serv_result,res_start,res_end-res_start),fnd_http.chr_newline),fnd_http.chr_newline);
57 
58 
59    I:=1;
60    out_list_start:=Instr(serv_result,'<P>',1,2);
61    IF out_list_start=0 THEN
62       p_result:='false';
63       RETURN;
64    END IF;
65    out_list_start:=out_list_start+3;
66    out_list_end:=Instr(serv_result,'</P>',out_list_start,1);
67    out_list:=Substr(serv_result,out_list_start,out_list_end-out_list_start);
68    out_start:=1;
69    out_end:=out_list_end;
70 
71    WHILE true LOOP
72       out_end:=Instr(out_list,'<BR>',out_start,1);
73       EXIT WHEN out_start>out_end;
74       out_name_value:=Substr(out_list,out_start,out_end-out_start);
75       equal_pos:=Instr(out_name_value,'=',1,1);
76       p_output_tab(i).name:=Ltrim(Rtrim(Substr(out_name_value,1,equal_pos-1),fnd_http.chr_newline),fnd_http.chr_newline);
77       p_output_tab(i).value:=Ltrim(Rtrim(Substr(out_name_value,equal_pos+1,out_end-equal_pos),fnd_http.chr_newline),fnd_http.chr_newline);
78       out_start:=out_end+4;
79       i:=i+1;
80    END LOOP;
81 
82    i:=1;
83    err_stack_start:=Instr(serv_result,'<P>',1,3);
84    IF err_stack_start=0  THEN
85       p_result:='false';
86       RETURN;
87    END IF;
88    err_stack_start:=err_stack_start+3;
89    err_stack_end:=Instr(serv_result,'</P>',err_stack_start,1);
90    err_stack:=Substr(serv_result,err_stack_start,err_stack_end-err_stack_start);
91    err_start:=1;
92    err_end:=err_stack_end;
93    WHILE TRUE LOOP
94       err_end:=Instr(err_stack,'<BR>',err_start,1);
95       EXIT WHEN err_start>err_end;
96       p_encoded_errors_tab(i):=Ltrim(Rtrim(Substr(err_stack,err_start,err_end-err_start),fnd_http.chr_newline),fnd_http.chr_newline);
97       err_start:=err_end+4;
98       i:=i+1;
99    END LOOP;
100 
101   EXCEPTION WHEN OTHERS THEN
102      p_result:='false';
103 END;
104   END fnd_http;