bonjour , je suis sur jdevelopper 11g ilya un template edit ,des service , et sur oracle xe plusieurs bdd des trigger des fonctions soap.
donc voila en ajoutant une donnée a partir du template edit la table naissance n'est pas remplir , il faut UE LE TRIGGER SE DECLENCHE AVANT l'insertion pour obtenir l'url de la commune du pere grace au service web donc voila un bout de code :
Table naissance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 NAISSANCEID VARCHAR2(100) NOM VARCHAR2(40) - PRENOM VARCHAR2(100) ADDRID VARCHAR2(40) COMMUNEID VARCHAR2(5)
function get_commune :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 CREATE OR REPLACE TRIGGER "NAISSANCE_INSERT" BEFORE INSERT ON NAISSANCE FOR EACH ROW DECLARE NAISSANCEID VARCHAR2(35); COMM varchar2(5); resp XMLType; response varchar2(30000); URL_WILAYA varchar2(100); URL VARCHAR2(100); NOM VARCHAR2(100); DATNAIS_EXCEP EXCEPTION; COMMUNE_INEXIT_EXCEP EXCEPTION; ADDRESS_EXCEP EXCEPTION; BEGIN dbms_output.put_line('1'); :NEW.COMMUNEID := '27000'; SELECT NAISSANCE_SEQ.NEXTVAL INTO NAISSANCEID FROM DUAL; :NEW.NAISSANCEID := :NEW.COMMUNEID||NAISSANCEID; COMM := SUBSTR(:NEW.ID_PERE,1,5); URL_WILAYA:='127.0.0.1:7101'; response := get_commune(COMM, URL_WILAYA); resp:= XMLType.createXML(response); resp:= resp.extract('/url/text()'); URL:=resp.getStringVal(); DBMS_OUTPUT.PUT_LINE('url pere is : '||URL); if URL is null then raise COMMUNE_INEXIT_EXCEP; end if; EXCEPTION WHEN COMMUNE_INEXIT_EXCEP THEN RAISE_APPLICATION_ERROR(-20501,'Erreur : COMMUNE ' ||TO_CHAR(:NEW.COMMUNEID)||' inexistants'||'verifier aussi le deces id '||TO_CHAR(:NEW.NAISSANCEID));
public Commune getCommuneFindById:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 create or replace function get_commune(id in varchar2, url in varchar2) return varchar2 as soap_request varchar2(30000); soap_respond varchar2(30000); http_req utl_http.req; http_resp utl_http.resp; resp XMLType; begin soap_request:= '<?xml version = "1.0" encoding = "UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://wilaya/"> <env:Header/> <env:Body> <ns1:getCommuneFindById> <arg0>'||id||'</arg0> </ns1:getCommuneFindById> </env:Body> </env:Envelope> '; http_req:= utl_http.begin_request ( 'http://'||url||'/wilaya-wilaya-webapp/wilayaWS' , 'POST' , 'HTTP/1.1' ); utl_http.set_header(http_req, 'Content-Type', 'application/soap+xml'); utl_http.set_header(http_req, 'Content-Length', length(soap_request)); utl_http.set_header(http_req, 'SOAPAction', ''); utl_http.write_text(http_req, soap_request); -- DBMS_OUTPUT.PUT_LINE ('request is : '||soap_request); http_resp:= utl_http.get_response(http_req); utl_http.read_text(http_resp, soap_respond); utl_http.end_response(http_resp); resp:= XMLType.createXML(soap_respond); -- DBMS_OUTPUT.PUT_LINE ('commune is : '||soap_respond); resp:= resp.extract('//ns2:getCommuneFindByIdResponse/return' , 'xmlns:ns2="http://wilaya/"' ); -- dbms_output.put_line('commune : '||resp.getStringVal()); return resp.getStringVal(); end;
je test tout les service web jelance le template j'inser je click sur envoyais et rien n'est declenché ni émit
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 /** <code>select o from Commune o where o.communeid like :id</code> */ public Commune getCommuneFindById(String id) { return (Commune)em.createNamedQuery("Commune.findById").setParameter("id", id).getSingleResult(); }
quelqu'un pourrait m'aidez svp merci
Partager