PL/SQL SOAP Call doesn't work and i am using Oracle 11g It gives the output like:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
<faultstring>no SOAPAction header!</faultstring>
<detail>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">testvm564.de.test.com</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
And the PL/SQL is(WHICH Works fine in SOAP UI):
declare
soap_request VARCHAR2(30000);
soap_respond CLOB;
http_req utl_http.req;
http_resp utl_http.resp;
resp XMLType;
soap_err exception;
v_code VARCHAR2(200);
v_msg VARCHAR2(1800);
v_len number;
v_txt Varchar2(32767);
BEGIN
-- Define the SOAP request according the the definition of the web service being called
soap_request:= '<?xml version = "1.0" encoding = "UTF-8"?>'||
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.test.com/dta/TestData/2/0" xmlns:urn="urn:core.bo.service.sim.test.com">'||
'<soapenv:Header/>'||
' <soapenv:Body>'||
' <ns:GetRoleAssignmentRequest>'||
' <ns:auth>'||
' <urn:user>'||'testUser'||'</urn:user>'||
' <urn:password>'||'testPass'||'</urn:password>'||
' </ns:auth>'||
' </ns:GetRoleAssignmentRequest>'||
' </soapenv:Body>'||
'</soapenv:Envelope>';
http_req:= utl_http.begin_request
( 'http://test.test.com/testWebService/services/testService20SOAP?wsdl/getRoleAssignment'
, 'POST'
, 'HTTP/1.1'
);
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header(http_req, 'Download', ''); -- header requirements of particular web service
utl_http.write_text(http_req, soap_request);
http_resp:= utl_http.get_response(http_req);
utl_http.get_header_by_name(http_resp, 'Content-Length', v_len, 1); -- Obtain the length of the response
FOR i in 1..CEIL(v_len/32767) -- obtain response in 32K blocks just in case it is greater than 32K
LOOP
utl_http.read_text(http_resp, v_txt, case when i < CEIL(v_len/32767) then 32767 else mod(v_len,32767) end);
soap_respond := soap_respond || v_txt; -- build up CLOB
dbms_output.put_line('Aneesh'||soap_respond);
END LOOP;
utl_http.end_response(http_resp);
resp:= XMLType.createXML(soap_respond); -- Convert CLOB to XMLTYPE
END;
Please extend your help (I can add the expected output if it is required) (I can add the expected output if it is required)
Add SOAPAction Header to your HTTP request:
utl_http.set_header(http_req, 'SOAPAction', 'yourHeader');
you will find SOAPAction value in service WSDL:
<wsdl:operation name="yourOperation">
<soap:operation soapAction="yourSoapAction" ... />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.