0 Replies Latest reply: Apr 27, 2009 7:49 AM by 698374 RSS

    sending BLOB to web service

    698374
      Hi,

      The requirement is sending image blob format to web service and web service will create this image in the specified path.

      To achieve this target I should send parameters to web service using UTL_HTTP.

      This web service should receive two parameters through the form POST method:

      · BLOB image as parameter # 1 (the element name is “blob”)

      · Destination as parameter # 2 (the element name is “DestPath”)

      The code that I used as follow:

      DECLARE
      v_blob BLOB;
      v_req UTL_HTTP.req;
      v_resp UTL_HTTP.resp;
      v_text_data VARCHAR2 (4000);
      vn_buff_size BINARY_INTEGER := 32767;
      v_temp_text VARCHAR2 (4000);
      v_text varchar2 (4000);
      BEGIN
      SELECT col INTO v_blob FROM TEST;

      UTL_HTTP.close_persistent_conns;
      UTL_HTTP.set_persistent_conn_support (FALSE);
      UTL_HTTP.set_transfer_timeout (10);
      v_req :=
      UTL_HTTP.begin_request ('http://10.100.1.94/AspUpload/DynBLOBSave.asp',
      'POST',
      'HTTP/1.0');
      UTL_HTTP.set_header (v_req, 'User-Agent', 'Mozilla/4.0');
      UTL_HTTP.set_header (v_req, 'content-type', 'multipart/form-data');
      UTL_HTTP.SET_HEADER (v_req,
      'Content-type',
      'application/x-www-form-urlencoded');
      UTL_HTTP.SET_HEADER (v_req,
      'Content-length',
      LENGTH ('c:\test_image.jpg'));
      UTL_HTTP.write_raw (v_req, v_blob);
      UTL_HTTP.write_text (v_req, 'c:\test_image.jpg');

      v_resp := UTL_HTTP.get_response (v_req);

      BEGIN
      LOOP
      UTL_HTTP.read_text (v_resp, v_text_data, vn_buff_size);
      v_text := v_text || v_text_data;
      END LOOP;
      EXCEPTION
      WHEN UTL_HTTP.end_of_body
      THEN
      UTL_HTTP.end_response (v_resp);
      END;

      DBMS_OUTPUT.put_line ('v_temp_text= ' || v_text);
      END;

      but these parameters do not reach web service. So, the image is not created.

      Thanks for your support
      Attia