![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have built a VB application that reads values from SQL server and uses one of the selected values to send a soap request. The application then takes the responses and stores them in a table. The question here and never even considered it is, can I send the SOAP request directly from the server is a stored procedure and eliminate the middleware? |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Sorry Erland! But what do you mean "written in the CLR"? |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I am really finding it hard to believe that this question does not come u more. I already have the soap structure completed, I can pull values from ,y table tou phrae my request. I just can not believe that this is more commonly used method to eliminate the middel ware and have the server do the work. I can not find one example. The applicartion is already completed in vb.net and just want the server to make these request. I can not find one example of a stored proc that does anything in anyway like what I need! I mean am I just asking the question incorrectly? |
#7
| |||
| |||
|
#8
| |||
| |||
|
#9
| |||
| |||
|
|
I have built a VB application that reads values from SQL server and uses one of the selected values to send a soap request. The application then takes the responses and stores them in a table. The question here and never even considered it is, can I send the SOAP request directly from the server is a stored procedure and eliminate the middleware? |
|
Only really relevant if you happen to also be using Oracle, but below is some stuff I've been testing out recently. It uses UTL_HTTP, Pipelined User Defined Functions, CLOBS, and XMLTABLES to call SOAP Web-Services directly from the database and pipe the resultant XML out as a database table that can be joined, sorted etc. Quite sexy and very useful IMHO. Cheers Richard Maher create or replace TYPE TestStaffDetails IS OBJECT ( PersonID varchar2(8), GivenName varchar2(60), Surname varchar2(60), PersonType varchar2(30), PersonSubType varchar2(30), EmailActive varchar2(15), DisplayEmail varchar2(100), OtherEmail varchar2(100) ); create or replace PACKAGE Test_SOAP AS TYPE UserDetails IS TABLE OF TestStaffDetails; TYPE UserFullName IS TABLE OF varchar2(100); FUNCTION wsUserDetails(surname in varchar2, first_name in varchar2) RETURN UserDetails PIPELINED; FUNCTION wsFullName(PersonID in varchar2) RETURN UserFullName PIPELINED; END Test_SOAP; create or replace PACKAGE BODY Test_SOAP AS FUNCTION wsUserDetails(surname in varchar2, first_name in varchar2) RETURN UserDetails PIPELINED AS env clob; soap_resp clob := empty_clob; resp_str varchar2(32767); http_req utl_http.req; http_resp utl_http.resp; resp sys.xmltype; in_xml sys.xmltype; url varchar2(200):='https://test.my.stuff/staffquery/staffquery.asmx'; BEGIN IF (coalesce(length(surname),0) = 0 OR coalesce(length(first_name),0) = 0) THEN RAISE_APPLICATION_ERROR(-20002, 'Invalid argument'); END IF; -- generate_envelope(req, env); env:='<?xml version="1.0" encoding="utf-8"? soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:Body UserDetails xmlns="https://www.my.stuff/staffQuery/" FirstName>'|| first_name ||'</FirstName Surname>'|| surname ||'</Surname /UserDetails /soap:Body /soap:Envelope>'; UTL_HTTP.SET_WALLET ( 'file:' || '/app/ssl/my.stuff', 'mypsswd' ); http_req := utl_http.begin_request(url, 'POST','HTTP/1.1'); utl_http.set_body_charset(http_req, 'UTF-8'); -- utl_http.set_proxy('proxy:80?, NULL); -- utl_http.set_persistent_conn_support(TRUE); -- UTL_HTTP.set_authentication(http_req, ", '3', 'Basic', TRUE ); utl_http.set_header(http_req, 'Content-Type', 'text/xml'); utl_http.set_header(http_req, 'Content-Length', length(env)); utl_http.set_header(http_req, 'SOAPAction', 'https://www.my.stuff/staffQuery/UserDetails'); utl_http.write_text(http_req, env); http_resp := utl_http.get_response(http_req); dbms_lob.createTemporary(soap_resp, true); dbms_lob.open(soap_resp, dbms_lob.lob_readwrite); BEGIN LOOP utl_http.read_text(http_resp, resp_str, 32767); dbms_lob.writeappend (soap_resp, LENGTH(resp_str), resp_str); END LOOP; EXCEPTION WHEN utl_http.end_of_body THEN NULL; END; utl_http.end_response(http_resp); resp := xmltype.createxml(soap_resp).extract( '/soap:Envelope/soap:Body/child::node()' , 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' ); dbms_lob.close(soap_resp); dbms_lob.freeTemporary(soap_resp); for i in ( select Staff.PersonID, Staff.GivenName, Staff.Surname, Staff.PersonType, Staff.PersonSubType, Staff.EmailActive, Staff.DisplayEmail, Staff.OtherEmail from xmltable ( XmlNamespaces('https://www.my.stuff/staffQuery/' as SQ), '/SQ:UserDetailsResponse' passing resp columns xmlresult xmltype path 'SQ:UserDetailsResult/StaffList/Staff' ) soapXML , xmltable ( '*' passing soapXML.xmlresult columns PersonId varchar2(8) path 'PersonID', GivenName varchar2(60) path 'PersonPreferredGivenName', Surname varchar2(60) path 'PersonPreferredSurname', PersonType varchar2(30) path 'PersonType', PersonSubType varchar2(30) path 'PersonSubType', EmailActive varchar2(15) path 'EmailActive', DisplayEmail varchar2(100) path 'DisplayEmail', OtherEmail varchar2(100) path 'OtherMail' ) Staff ) loop pipe row (TestStaffDetails(i.PersonID, i.GivenName, i.Surname, i.PersonType, i.PersonSubType, i.EmailActive, i.DisplayEmail, i.OtherEmail)); -- dbms_output.put_line('hello'||i.PersonID); end loop; RETURN; END; FUNCTION wsFullName(PersonID in varchar2) RETURN UserFullName PIPELINED AS env clob; http_req utl_http.req; http_resp utl_http.resp; resp sys.xmltype; in_xml sys.xmltype; url varchar2(200):='https://test.my.stuff/staffquery/staffquery.asmx'; BEGIN IF (coalesce(length(PersonID),0) = 0) THEN RAISE_APPLICATION_ERROR(-20002, 'Invalid argument'); END IF; -- generate_envelope(req, env); env:='<?xml version="1.0" encoding="utf-8"? soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:Body FullName xmlns="https://www.my.stuff/staffQuery/" StaffNumber>'|| PersonID ||'</StaffNumber /FullName /soap:Body /soap:Envelope>'; UTL_HTTP.SET_WALLET ( 'file:' || '/app/ssl/my.stuff', 'mypsswd' ); http_req := utl_http.begin_request(url, 'POST','HTTP/1.1'); utl_http.set_body_charset(http_req, 'UTF-8'); -- utl_http.set_proxy('proxy:80?, NULL); -- utl_http.set_persistent_conn_support(TRUE); -- UTL_HTTP.set_authentication(http_req, ", '3', 'Basic', TRUE ); utl_http.set_header(http_req, 'Content-Type', 'text/xml'); utl_http.set_header(http_req, 'Content-Length', length(env)); utl_http.set_header(http_req, 'SOAPAction', 'https://www.my.stuff/staffQuery/FullName'); utl_http.write_text(http_req, env); http_resp := utl_http.get_response(http_req); utl_http.read_text(http_resp, env); utl_http.end_response(http_resp); resp := xmltype.createxml(env).extract( '/soap:Envelope/soap:Body/child::node()' , 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' ); for i in ( select soapXML.FullName from xmltable ( XmlNamespaces('https://www.my.stuff/staffQuery/' as SQ), '/SQ:FullNameResponse' passing resp columns FullName varchar2(100) path 'SQ:FullNameResult' ) soapXML ) loop IF i.FullName is not null THEN IF substr(i.FullName, 1, 1) = 'Y' THEN pipe row (substr(i.FullName,2)); -- dbms_output.put_line('hello'||coalesce(i.FullName, 'not found')); END IF; END IF; end loop; RETURN; END; END Test_SOAP; |
![]() |
| Thread Tools | |
| Display Modes | |
| |