DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_XML_UTIL

Source


1 package body irc_xml_util as
2 /* $Header: irxmlutl.pkb 120.2.12020000.2 2012/07/03 11:57:21 ranchala ship $ */
3 --
4 g_proxy varchar2(255);
5 g_wallet_path varchar2(255);
6 g_wallet_password varchar2(255);
7 --
8 -- -------------------------------------------------------------------------
9 -- |-------------------------< getWFXMLElement >---------------------------|
10 -- -------------------------------------------------------------------------
11 --
12 procedure getWFXMLElement
13 (itemtype  in     varchar2,
14 itemkey    in     varchar2,
15 actid      in     number,
16 funcmode   in     varchar2,
17 resultout     out nocopy varchar2) is
18 --
19 XPathTag varchar2(32767);
20 EventDocument CLOB;
21 Event wf_event_t;
22 parser xmlparser.parser;
23 event_doc xmldom.DOMDocument;
24 itemValue varchar2(32767);
25 responseAttr varchar2(32767);
26 --
27 begin
28 
29 if (funcmode='RUN') then
30 
31   XPathTag:=wf_engine.getActivityAttrText
32   (itemtype => itemtype
33   ,itemkey  => itemkey
34   ,actid    => actid
35   ,aname    => 'TAG');
36 
37   responseAttr:=wf_engine.getActivityAttrText
38   (itemtype => itemtype
39   ,itemkey  => itemkey
40   ,actid    => actid
41   ,aname    => 'ATTR');
42 
43   Event:=wf_engine.getActivityAttrEvent
44   (itemtype => itemtype
45   ,itemkey  => itemkey
46   ,actid    => actid
47   ,name    => 'EVENT');
48 
49   if (XPathTag is not null and responseAttr is not null) then
50 
51     EventDocument:=Event.getEventData();
52     itemValue:=irc_xml_util.valueOf(EventDocument,XPathTag);
53 
54     wf_engine.setItemAttrText
55     (itemtype => itemtype
56     ,itemkey  => itemkey
57     ,aname    => responseAttr
58     ,avalue   => itemValue);
59   end if;
60 end if;
61 resultout:='COMPLETE';
62 exception
63   when others then
64     begin
65       xmlparser.freeParser(parser);
66       xmldom.freeDocument(event_doc);
67     exception
68     when others then
69       null;
70     end;
71 end getWFXMLElement;
72 --
73 -- -------------------------------------------------------------------------
74 -- |----------------------------< valueOf >---------------------------------|
75 -- -------------------------------------------------------------------------
76 --
77 function valueOf(doc xmldom.DOMDocument,xpath varchar2) return varchar2 is
78 --
79 retval varchar2(32767);
80 --
81 begin
82 --
83   if (not xmldom.IsNull(doc)) then
84     xslprocessor.valueOf(xmlDom.makeNode(doc),xpath,retval);
85   end if;
86   return retval;
87 end valueOf;
88 --
89 -- -------------------------------------------------------------------------
90 -- |----------------------------< valueOf >---------------------------------|
91 -- -------------------------------------------------------------------------
92 --
93 function valueOf(doc CLOB,xpath varchar2) return varchar2 is
94 --
95 retval varchar2(32767);
96 xmldoc xmldom.DOMDocument;
97 parser xmlparser.parser;
98 --
99 begin
100 
101   parser:=xmlparser.newParser;
102   xmlparser.parseClob(parser,doc);
103   xmldoc:=xmlparser.getDocument(parser);
104   xmlparser.freeParser(parser);
105   retval:=irc_xml_util.valueOf(xmldoc,xpath);
106   xmldom.freeDocument(xmldoc);
107   return retval;
108 exception
109   when others then
110     xmlparser.freeParser(parser);
111     xmldom.freeDocument(xmldoc);
112     return null;
113 end valueOf;
114 --
115 -- -------------------------------------------------------------------------
116 -- |----------------------------< valueOf >---------------------------------|
117 -- -------------------------------------------------------------------------
118 --
119 function valueOf(doc varchar2,xpath varchar2) return varchar2 is
120 --
121 retval varchar2(32767);
122 xmldoc xmldom.DOMDocument;
123 parser xmlparser.parser;
124 --
125 begin
126 
127   parser:=xmlparser.newParser;
128   xmlparser.parseBuffer(parser,doc);
129   xmldoc:=xmlparser.getDocument(parser);
130   xmlparser.freeParser(parser);
131   retval:=irc_xml_util.valueOf(xmldoc,xpath);
132   xmldom.freeDocument(xmldoc);
133   return retval;
134 exception
135   when others then
136     xmlparser.freeParser(parser);
137     xmldom.freeDocument(xmldoc);
138     return null;
139 end valueOf;
140 --
141 -- -------------------------------------------------------------------------
142 -- |----------------------------< http_get >--------------------------------|
143 -- -------------------------------------------------------------------------
144 --
145 function http_get(url varchar2) return varchar2 is
146 --
147 retval varchar2(32767);
148 l_proxy varchar2(255);
149 begin
150   if(g_proxy is null) then
151     g_proxy:=fnd_profile.value('WEB_PROXY_HOST');
152   end if;
153   if(g_proxy is not null) then
154     l_proxy:=hr_util_web.proxyforURL(substr(url,1,2000));
155   end if;
156   if(lower(substr(url,1,5))='https') then
157     if (g_wallet_path is null) then
158       g_wallet_path:='file:'||fnd_profile.value('FND_DB_WALLET_DIR');
159     end if;
160     if (g_wallet_password is null) then
161       g_wallet_password:=fnd_preference.eget('#INTERNAL','WF_WEBSERVICES','EWALLETPWD', 'WFWS_PWD');
162     end if;
163     retval:=UTL_HTTP.REQUEST(url   => url
164                            ,proxy => l_proxy
165                            ,wallet_path=>g_wallet_path
166                            ,wallet_password=>g_wallet_password
167                            );
168   else
169     retval:=UTL_HTTP.REQUEST(url   => url
170                            ,proxy => l_proxy
171                            );
172   end if;
173   return retval;
174 end http_get;
175 --
176 -- -------------------------------------------------------------------------
177 -- |------------------------< http_get_pieces >-----------------------------|
178 -- -------------------------------------------------------------------------
179 --
180 function http_get_pieces(url varchar2
181                         ,max_pieces number) return utl_http.html_pieces is
182 --
183 retval utl_http.html_pieces;
184 l_proxy varchar2(255);
185 begin
186   utl_http.SET_BODY_CHARSET(fnd_profile.value('ICX_CLIENT_IANA_ENCODING'));
187   if(g_proxy is null) then
188     g_proxy:=fnd_profile.value('WEB_PROXY_HOST');
189   end if;
190   if(g_proxy is not null) then
191     l_proxy:=hr_util_web.proxyforURL(substr(url,1,2000));
192   end if;
193   if(lower(substr(url,1,5))='https') then
194     if (g_wallet_path is null) then
195       g_wallet_path:='file:'||fnd_profile.value('FND_DB_WALLET_DIR');
196     end if;
197     if (g_wallet_password is null) then
198       g_wallet_password:=fnd_preference.eget('#INTERNAL','WF_WEBSERVICES','EWALLETPWD', 'WFWS_PWD');
199     end if;
200     retval:=UTL_HTTP.REQUEST_PIECES(url   => url
201                            ,max_pieces=>max_pieces
202                            ,proxy => l_proxy
203                            ,wallet_path=>g_wallet_path
204                            ,wallet_password=>g_wallet_password
205                            );
206   else
207     retval:=UTL_HTTP.REQUEST_PIECES(url   => url
208                            ,max_pieces=>max_pieces
209                            ,proxy => l_proxy
210                            );
211   end if;
212   return retval;
213 end http_get_pieces;
214 end irc_xml_util;