Struggling with this piece of getting to work

From: Vamshi Damidi <dbaprimatics_at_gmail.com>
Date: Thu, 4 Oct 2012 20:30:40 -0400
Message-ID: <CAKshVhwWun_0yAgX8CcdRp4zhjEWqZ9uQ+L=UfQZ2EOhjqKxXw_at_mail.gmail.com>



All experts,
I am trying to write aws webservice with plsql based on some links i got them from blogs
Based on these url's i wrote this code.
http://jastraub.blogspot.com/2009/07/hmacsha256-in-plsql.html http://jastraub.blogspot.com/2009/11/flexwsapi-no-on-samplecodeoraclecom.html search code.google.com for plsql utils.
which has fantastic plsql utilities.
set serveroutput on
declare
  l_signature     varchar2(4000);
  l_response      clob;
  l_parm_name_tab wwv_flow_global.vc_arr2;
  l_parm_val_tab  wwv_flow_global.vc_arr2;
  i number;
  secure varchar2(1);
l_timestamp varchar2(50) := ( to_char(sysdate + 4/24,'YYYY-MM-DD')||'T'||to_char(sysdate+4/24,'hh24:mi:ss')||'-04:00'); -- Apex Specific
  l_security_group_id NUMBER :=
apex_util.find_security_group_id('VDAMIDI');
  l_val                VARCHAR2(4000);
  v_arr                wwv_flow_global.vc_arr2;
-- Apex Specific Completed

begin
-- Apex Specific

  wwv_flow_api.set_security_group_id(l_security_group_id);   apex_application.g_flow_id := '1';
  apex_custom_auth.define_user_session('VDAMIDI', 1756183794381675);

  • Apex Specific Completed

--compute the signature

  l_signature := amazon_signature('GET'||chr(10)||'ec2.amazonaws.com '||chr(10)||'/'||chr(10)||'AWSAccessKeyId='||AWSACCESSKEY||'&Action=DescribeRegions&Timestamp='||apex_util.url_encode(l_timestamp)||'&Version=2012-08-15',AWSSECRETKEY);

--create the tables of parameter names and values
  l_parm_name_tab :=
apex_util.string_to_table('AWSAccessKeyId:Action:Version:Timestamp:Signature',':');
--need to use ~ instead of : for separator since timestamp will contain :
  l_parm_val_tab :=
apex_util.string_to_table(AWSACCESSKEY||'~DescribeRegions~2012-08-15~'||l_timestamp||'~'||wwv_flow_utilities.url_encode2(l_signature),'~');
--need to add l_signature to the table separately, it may contain any
character
--l_parm_val_tab(l_parm_val_tab.count + 1) := l_signature;

      for i in 1..l_parm_name_tab.count
   loop

      dbms_output.put_line (l_parm_name_tab(i) ||'|'||l_parm_val_tab(i));    end loop;

--make the REST request

  l_response := flex_ws_api.make_rest_request(

      p_url => 'http://ec2.amazonaws.com/',
      p_http_method => 'GET',
      p_parm_name => l_parm_name_tab,
      p_parm_value => l_parm_val_tab );

--populate a collection with the response
  apex_collection.create_or_truncate_collection('P1_ITEMSEARCH_RESPONSE');   apex_collection.add_member(

      p_collection_name   => 'P1_ITEMSEARCH_RESPONSE',
      p_clob001           => l_response );

--populate a collection for any response http headers returned
  apex_collection.create_or_truncate_collection('P1_RESP_HEADERS');

  for i in 1.. flex_ws_api.g_headers.count loop     apex_collection.add_member(

      p_collection_name => 'P1_RESP_HEADERS',
      p_c001 => flex_ws_api.g_headers(i).name,
      p_c002 => flex_ws_api.g_headers(i).value,
      p_c003 => flex_ws_api.g_status_code);
  end loop;

end;
/

i keep getting message signature not valid.

Any help would be greatly appreciated.

Thanks
Vamshi .D

--
http://www.freelists.org/webpage/oracle-l
Received on Fri Oct 05 2012 - 02:30:40 CEST

Original text of this message