Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to call web service with usertoken APEX_WEB_SERVICE.make_request

IBRAHIM SAYYEDDec 1 2019

Dear Oracle PLSQL/Apex Experts,

I am trying call a JDE web service using APEX_WEB_SERVICE.make_request package and procedure and this webservice will not accept basic authentication.

It is working fine When I call webservice using user token security which is generated from SOAP UI, but is will work upto token expire.

After user token expire it encounters error.

InvalidSecurityToken

Security token failed to validate. weblogic.xml.crypto.wss.SecurityTokenValidateResult@52252641[status: false][msg UNT Error:Message older than allowed MessageAge]

Can any one suggest how to generate user token time from plsql and call the webservice successfully.

Header Generated from SOAP UI:

   <soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

   <wsse:UsernameToken wsu:Id="UsernameToken-9649B9C71C1FE291541575177871532102">

   <wsse:Username>Username</wsse:Username>

   <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>

   <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">p+fEsuVpsq0GCyBMdBQGFw==</wsse:Nonce>

   <wsu:Created>2019-12-01T05:24:31.532Z</wsu:Created></wsse:UsernameToken>

   </wsse:Security>

   </soapenv:Header>

below is the sample script I am using to call webservice :

declare

  l_envelope  CLOB;

  l_xml       XMLTYPE;

  l_result    VARCHAR2(32767);

BEGIN

  -- Build a SOAP document appropriate for the web service.

  l_envelope := '<soapenv:Envelope xmlns:orac="http://oracle.e1.bssv.JP58LV01/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

   <wsse:UsernameToken wsu:Id="UsernameToken-9649B9C71C1FE291541575177871532102">

   <wsse:Username>Username</wsse:Username>

   <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>

   <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">p+fEsuVpsq0GCyBMdBQGFw==</wsse:Nonce>

   <wsu:Created>2019-12-01T05:24:31.532Z</wsu:Created></wsse:UsernameToken>

   </wsse:Security>

   </soapenv:Header>

   <soapenv:Body>

      <orac:leaveCalculation>

         <!--Optional:-->

         <CEverestEventPoint01>?</CEverestEventPoint01>

         <!--Optional:-->

         <jdOvertimeFromDate>?</jdOvertimeFromDate>

         <!--Optional:-->

         <jdRequisitionDate>?</jdRequisitionDate>

         <!--Optional:-->

         <mnAddressNumber>1111</mnAddressNumber>

         <!--Optional:-->

         <mnLeaveDuration>1</mnLeaveDuration>

         <!--Optional:-->

         <szLeaveType>AL</szLeaveType>

      </orac:leaveCalculation>

   </soapenv:Body>

</soapenv:Envelope>';

  -- Get the XML response from the web service.

  l_xml := APEX_WEB_SERVICE.make_request(

   p_url      => 'URL',

   p_action   => 'https://...../leaveCalculation',

    p_envelope => l_envelope,

    p_username  => 'Username'   ,

    p_password  => 'Password'  ,   

    p_wallet_path => 'p_wallet_path',

    p_wallet_pwd  => 'p_wallet_pwd'

  );

-- UTL_HTTP.SET_AUTHENTICATION(http_req, username, password);

  -- Display the whole SOAP document returned.

  DBMS_OUTPUT.put_line('l_xml=' || l_xml.getClobVal());

  -- Pull out the specific value of interest.

  l_result := APEX_WEB_SERVICE.parse_xml(

    p_xml   => l_xml,

    p_xpath => '//return/text()',

    p_ns    => 'xmlns:ns1="https://bssv92.km.qa/PD910/JDE_BPMS_Manager?wsdl"'

  );

  DBMS_OUTPUT.put_line('l_result=' || l_result);

  DBMS_OUTPUT.put_line('l_result=' || l_result);

END;

/

Thanks and regards,

Ibrahim Sayyed.

Comments
Post Details
Added on Dec 1 2019
0 comments
626 views