簡體   English   中英

PL / SQL不適用於SOAP Web服務

[英]PL/SQL doesn't work with SOAP webservice

PL / SQL SOAP調用不起作用,我正在使用Oracle 11g,其輸出如下:

<?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>

PL / SQL是(在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;

請擴展您的幫助(如果需要,我可以添加預期的輸出)(如果需要,我可以添加預期的輸出)

將SOAPAction標頭添加到您的HTTP請求中:

utl_http.set_header(http_req, 'SOAPAction', 'yourHeader');

您將在服務WSDL中找到SOAPAction值:

<wsdl:operation name="yourOperation">
  <soap:operation soapAction="yourSoapAction" ... />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM