Invalid request when calling REST-webservice with UTL_HTTP.

10-11  Source: Network gathering  Views:12 

Advertisement
Hello,
When i try to send some data to a REST-webservice i get as response "INVALID REQUEST"
I Think it is about the request-body that seems to be no UTF-8.
I tried to set the characterset with utl_http.set_body_charset(t_http_req, 'UTF-8').
But when i read the characterset with utl_http.get_body_charset(t_charset);, is still get "ISO-8859-1"
I am using: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
Some help would realy be appreciated because i am out of options trying to get the code working..
======MY CODE==========
create or replace procedure ipm40_send_bekendmaking(p_bdmg_id in number)
as
r_bekendmaking ipm40_bekendmakingen%rowtype;
r_gemeente ipm40_gemeenten%rowtype;
l_url httpuritype;
t_http_req utl_http.req;
t_http_resp utl_http.resp;
t_request_body varchar2(32767);
t_respond varchar2(32767);
-- t_teller integer := 1;
-- t_output varchar2(2000);
t_start number := 1;
t_body_lengte number;
t_chunkdata varchar2(4000);
t_tijd_1 varchar2(256);
t_tijd_2 varchar2(256);
t_timeout integer;
t_length number;
t_charset varchar2(256);
begin
select *
into r_bekendmaking
from ipm40_bekendmakingen
where id = p_bdmg_id;
select *
into r_gemeente
from ipm40_gemeenten
where gmte_code = r_bekendmaking.gmte_code;
l_url := httpuritype.createuri('http://zwolle.stadsbeheer.com:82/apex/ipm40bekendmaking?p_bdmg_id='||r_bekendmaking.id);
t_request_body := l_url.getClob();
/* request that exceptions are raised for error Status Codes */
--Utl_Http.Set_Response_Error_Check ( enable => true );
/* allow testing for exceptions like Utl_Http.Http_Server_Error */
--Utl_Http.Set_Detailed_Excp_Support ( enable => true );
utl_http.set_transfer_timeout(300);
t_http_req:= utl_http.begin_request( r_gemeente.url_webservice_bekendmakingen
, 'POST'
, 'HTTP/1.1');
utl_http.set_body_charset(t_http_req, 'UTF-8');
utl_http.get_body_charset(t_charset);
utl_http.set_authentication(t_http_req,r_gemeente.user_webservice_bekendmakingen,r_gemeente.pw_webservice_bekendmakingen);
t_length := length(t_request_body);
utl_http.set_header(t_http_req, 'Content-Type', 'application/xml charset=UTF-8');
utl_http.set_header(t_http_req, 'Content-Length', t_length);
utl_http.set_header(t_http_req, 'Transfer-Encoding', 'chunked' ); --
t_body_lengte := dbms_lob.getlength(t_request_body);
loop
t_chunkdata := dbms_lob.substr(t_request_body, 2000, t_start);
utl_http.write_text ( t_http_req, t_chunkdata );
t_start := t_start + 2000;
if t_start > t_body_lengte
then
exit;
end if;
end loop;
t_http_resp:= utl_http.get_response(t_http_req);
utl_http.read_text(t_http_resp, t_respond);
utl_http.end_response(t_http_resp);
if instr(t_respond,'Successfully document processed') != 0
then
update ipm40_bekendmakingen
set ind_status = 'S'
, datum_verzonden = sysdate
, response = t_respond
where id = r_bekendmaking.id;
else
update ipm40_bekendmakingen
set ind_status = 'F'
, datum_verzonden = null
, response = t_respond
where id = r_bekendmaking.id ;
end if;
commit;
exception
when others
then
t_tijd_2 := to_char(sysdate,'HH24:MI:SS');
t_respond := substr(sqlerrm,1,2000);
update ipm40_bekendmakingen
set ind_status = 'F'
, datum_verzonden = null
, response = t_respond
where id = r_bekendmaking.id ;
commit;
end;
===THE RESPOND=============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to process the request:
<PRE>
POST /pushxml/pushxml-bm HTTP/1.0
Authorization: Basic Ymtfc21hcnRob2xkaW5nOllyZXMzdlFR
Content-Type: application/xml charset=UTF-8
Content-Length: 2096
Transfer-Encoding: chunked
Connection: close
</PRE>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid Request
</STRONG>
</UL>
<P>
Some aspect of the HTTP Request is invalid. Possible problems:
<UL>
<LI>Missing or unknown request method
<LI>Missing URL
<LI>Missing HTTP Identifier (HTTP/1.0)
<LI>Request is too large
<LI>Content-Length missing for POST or PUT requests
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<P>Your cache administrator is [email protected]
<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Fri, 12 Aug 2011 17:33:24 GMT by asd2cc001.asp4all.nl (squid)
</ADDRESS>
</BODY></HTML>
Always check the access_log and error_log files of the Apache web server in such a case. This will identify whether the error comes from Apache itself, mod_plsql, the Apex run-time engine, or the Oracle database.
I see that you're creating a HTTP/1.1 in PL/SQL - however, the web server response indicates a HTTP/1.0 call was received. Unusual. And could be part of the problem.
Related articles
  • Invalid request when calling REST-webservice with UTL_HTTP. 10-11

    Hello, When i try to send some data to a REST-webservice i get as response "INVALID REQUEST" I Think it is about the request-body that seems to be no UTF-8. I tried to set the characterset with utl_http.set_body_charset(t_http_req, 'UTF-8'). But

  • "invalid request" when calling Apache Soap 2.2 webservice using 8.1.1 11-30

    I have tried setting soap-style to RPC as advised in the documentation but keep getting this same error. Server is Apache Soap 2.2. Another test client using Apache Soap 2.3.1 got the same error. I am trying to call a webservice in a WLI process flow

  • Call secure RestFul WebService with basic authorization via https 11-30

    Hi, is there a way to call a secure RestFul WebService with basic authorization via https from APEX? Database: Oracle 11g XE APEX: 4.2.1 I have a solution by calling the WebService from Java which was called from the database via scheduled job (execu

  • Error when calling a Webservice's public method in Forms10g 10-11

    Hi, I'm getting the following error when calling a webservice's public method, i'm using Forms10g 10.1.2.3 java.rmi.RemoteException; nested exception is: HTTP transport error javax.xml.soap.SOAPException java.security.PrivilegedActionException javax.

  • Call a Webservice with SAML securty in PI 7.0 10-11

    Hi experts, I need to call a Webservice with SAML security from PI 7.0, Is It possible? or only It is possible with PI 7.1? Thanks in advance, Jose ManuelHi Jose, Let me answer your questuion first : No, using PI 7.0 I dont think its posible.. Below

  • Is it possible to call a webservice with just the url to its WSDL 11-30

    hi all can anyone tell me if it is possible to call a webservice with just the url to its WSDL file. must we create the proxy class for webservice client? thanksif you are in the context of a J2EE 1.4 container, you do not need to generate any stub,

  • RESTful webservice with Jersey 11-30

    Hey all, I'm building a RESTful webservice with Jersey on top of my EJB layer. This all goes well, the simple CRUD operations seem to work, but now I seem to have some trouble to add the extra functionality. I've got a category which I can get by id

  • Calling a webservice with SOAP Receiver 10-11

    Hi Guys,    Im calling web service from XI using SOAP. I could call the webservice using XML Spy, It is working fine.In XML spy I could se the response (variable out , type double).    When i call the same web service from XI It doesnt give any error

  • Global rules not kicking off when calling CHECKIN_NEW webservice 11-30

    Hi All, We are trying to call CHECKIN_NEW/CHECKIN_UNIVERSAL web services with mandatory fields like doctype, securitygroup, title, primary file etc.. It is working fine, but the global rules were not kicking off. Ex: Say, we have a rule that says Fie

  • Application crashes when calling DLL built with LabVIEW 2011 10-11

    Hello everybody, Our application calls DLLs built with LabVIEW 2010 SP1. We installed LabVIEW 2011 and built some DLLs. So far so good. If we start our application and run 2010 DLLs it still works fine. If we run a 2011 DLL just once no error happens

  • Restful webservice with basic authentication 10-11

    Hi, i am running the following: Oracle: 11.2.... ApexListener: 2..... Glassfish: 3.0... Apex: 4.2.1 I have successfully established some restful webservices. Now i want to add a basic authentication to them against an APEX Authentication Scheme which

  • Calling a REST webservice with pl/sql and parse XML 10-11

    Hi I hope someone is able to help me with this task. I'm newbie with Oracle APEX, have not developed advanced applications yet. A few days ago I installed one of the package application with customer and order. I want to integrate with online shoppin

  • Problem with array param when calling a webservice from a BPM Process 10-11

    Hi. I have a web service and uses an array as parameter. The array (named "atributos") as part of a business object is defined here: <xs:schema targetNamespace="http://xmlns.oracle.com/bpm/bpmobject/DataTypes/TrackPCPDOTrans" ...>

  • Why is UTL_DBWS is doing a POST when calling a webservice?? 11-30

    Hi everyone, I was testing the UTL_DBWS package with a 10.2.0.2.0 database to get a call to a webservice on an Oracle AS. My PL/SQL code is like this: declare l_service sys.UTL_DBWS.service; l_call sys.UTL_DBWS.call; l_result ANYDATA; l_wsdl_url VARC

  • Unable to call REST webservice 11-30

    Hi all, I'm trying to create a REST web service reference in Apex 4.1 (as a demo only). It's a call to http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXMLclient.php with 5 input parameters. When I test the web service in Apex B

  • Connection time out error when calling a webservice on ICF 10-11

    Hi    We have a webservice exposed on ECC 5.0 on the ICF. However, when we invoke the webservice - after 10 seconds , we get a error message Error reading server response: The operation has timed-out I checked ICMAN parameters icm/conn_timeout - and

  • Not found error message from LabVIEW runtime when called from VC++ with statically linked MFC 10-11

    I have a dll built using LabVIEW 6i. I am calling the dll from a VC++ application. When the application loads I get an error pop-up 'cannot find LabVIEW runtime'. If I change the VC++ code to dynamically load MFC (using the loadlibrary function) or d

  • 64bit OraOLEDB failed when calling stored procedure with Ref Cursor 10-11

    Hi everyone, I used the ADO VB sample provided with the Oracle 10g provider installation. But I compiled it in 64bit Visual Studio 2005 and ran on Windows 2003 x64 server. The function call "cmd.Execute" when it is trying to call a stored proced

  • How to call rest service with POST Http method in SMP2.3 HWC? 11-30

    Hi Experts,    I am doing a sample for Rest Service in smp. http://192.168.1.119:8086/Test/services/Products I am calling the above service in the smp it is pulling the data from the service with GET Http Method. Now i want to call this service for l

  • Call ABAP WebService with Elips Studio /Flex 11-30

    Hi everybody, Does somebody has experience with Elips Studio for Flex? I can't find much about it.. I would lik to call my SAP Webservices into my Elips project. (I know it's not the same as a regular Flex project, there are some differents...) Can s