Web Services 如何在PL/SQL SOAP WSDL Web服务调用中指定基本身份验证

lyfkaqu1  于 2022-11-15  发布在  其他
关注(0)|答案(1)|浏览(152)

我尝试使用PL/SQL从Oracle Applications EBS服务器调用Oracle Fusion Cloud Web服务。我可以从SOAPUI成功执行Web服务调用,但在SOAPUI中,验证(基本验证)是在单独的窗口中指定的。我的目的是使用SOAPUI中的工作SOAP信封,但如何在PL/SQL(Oracle 11 g)中指定Web服务基本验证?
从google上看,基本的身份验证可以包含在SOAP信封的头中。然而,所有的例子都引用了http://docs.oasis-open.org,这是一个我不知道是否可以信任的网站,特别是当它使用http并要求PasswordText作为其url的一部分时。请看这个例子:

<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-9419978" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:Username>admin</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password></wsse:UsernameToken></wsse:Security>
</soapenv:Header>

dba还必须设置一个ACL和一个wallet(没有密码)。
我现在的代码是:

create or replace PROCEDURE p_soap_request(p_username IN VARCHAR2, p_password IN VARCHAR2
--, p_proxy IN VARCHAR2
) IS
    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
    -- UTL_HTTP.SET_PROXY(p_proxy);
    -- Define the SOAP request according the the definition of the web service being called
    soap_request:= '<?xml version = "1.0" encoding = "UTF-8"?>'||
                   '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'||
                   '  <SOAP-ENV:Body>'||
                   '    <m:DownloadRequest xmlns:m="http://www.website.net/messages/GetDetails">'||
                   '      <m:UserName>'||p_username||'</m:UserName>'||
                   '      <m:Password>'||p_password||'</m:Password>'||
                   '    </m:DownloadRequest>'||
                   '  </SOAP-ENV:Body>'||
                   '</SOAP-ENV:Envelope>';

    http_req:= utl_http.begin_request
              ( 'http://www.website.net/webservices/GetDetailsService.asmx'
              , '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
    END LOOP;
    utl_http.end_response(http_resp);
    resp:= XMLType.createXML(soap_respond); -- Convert CLOB to XMLTYPE
  END;

我不确定用什么替换服务器的<m:DownloadRequest xmlns:m="http://www.website.net/messages/GetDetails">。也不确定如何指定wallet。
我的SOAPUI信封是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:submitESSJobRequest>
         <typ:jobPackageName>/oracle/apps/ess/financials/commonModules/shared/common/interfaceLoader</typ:jobPackageName>                             
         <typ:jobDefinitionName>InterfaceLoaderController</typ:jobDefinitionName>
         <!--Zero or more repetitions:-->
<typ:paramList>15</typ:paramList><!--GL Costing-->
<typ:paramList>17518</typ:paramList><!--UCM File Number-->
<typ:paramList>N</typ:paramList>
<typ:paramList>N</typ:paramList>
<typ:paramList>#NULL</typ:paramList>
      </typ:submitESSJobRequest>
   </soapenv:Body>
</soapenv:Envelope>

SOAP WSDL URL为:
https://your.domain.fin.region.oraclecloud.com:443/publicFinancialCommonErpIntegration/ErpIntegrationService?WSDL

y53ybaqx

y53ybaqx1#

最后得到它的工作与此代码:

declare
l_envelope       varchar2(32767);
l_http_request   utl_http.req;
l_http_response  utl_http.resp;
begin 
   utl_http.set_wallet
   (
      'file:/oracle/db/11.2.0/admin/EBST/wallet'
      ,'walletpassword'
   );
   l_envelope := '<?xml version="1.0"?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:submitESSJobRequest>
         <typ:jobPackageName>/oracle/apps/ess/financials/commonModules/shared/common/interfaceLoader</typ:jobPackageName>                             
         <typ:jobDefinitionName>InterfaceLoaderController</typ:jobDefinitionName>
         <!--Zero or more repetitions:-->
<typ:paramList>15</typ:paramList><!--GL Costing-->
<typ:paramList>17518</typ:paramList><!--UCM File Number-->
<typ:paramList>N</typ:paramList>
<typ:paramList>N</typ:paramList>
<typ:paramList>#NULL</typ:paramList>
      </typ:submitESSJobRequest>
   </soapenv:Body>
</soapenv:Envelope>';
   -- dbms_output.put_line(l_envelope);
   l_http_request := utl_http.begin_request
   (
      'https://username:password@yourdomain.com:443/publicFinancialCommonErpIntegration/ErpIntegrationService?WSDL', 
      'POST', 
      'HTTP/1.1'
   );
   utl_http.set_header(l_http_request, 'Content-Type', 'text/xml');
   utl_http.set_header(l_http_request, 'Content-Length', length(l_envelope));
   utl_http.set_header(l_http_request, 'SOAPAction', 'http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/submitESSJobRequest');
   utl_http.write_text(l_http_request, l_envelope);
   l_http_response := utl_http.get_response(l_http_request);
   utl_http.read_text(l_http_response, l_envelope);
   utl_http.end_response(l_http_response); 
end;

相关问题