I am calling a webservice from Oracle 11g using UTL_HTTP. I am certain that my certificate and wallet are set up correctly for connecting over HTTPS. The call works consistently for valid business data.
When I pass invalid data (non existant user id in this case) the call to UTL_HTTP.GET_RESPONSE throws an exception:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1369
ORA-29263: HTTP protocol error
I don't get the UTL_HTTP.RESP object returned to investigate any HTTP error code or content. A number of other invalid data use cases have returned responses with error codes but these have not thrown the exception. I am able to process the response for an HTTP error code and get the error message from the response body.
What I have noticed in the particular case throwing the exception is:
The response body is larger than other cases; ~2600 bytes.
The response body contains ampersands (it's an HTML response with escaped XML content within. I have no control over the server response)
I discovered these by calling via curl. Could either of these conditions be the reason for UTL_HTTP.GET_RESPONSE throwing an HTTP protocol error?
Thanks.
It looks that the errors raised by utl_http are intentionally opaque, unless you ask Oracle to be a little more explicit.
To make the error message more detailed when the exception is raised, somewhere in your session invoke:
utl_http.set_response_error_check(true)
Otherwise according to the docs in the utl_http package itself, you can get the error leveraging the following methods in your exception handling code:
utl_http.get_detailed_sqlcode
utl_http.get_detailed_sqlerrm
As for handling large requests, if it is your real problem, chunking the response and accumulating it in a clob may fix your issue:
function get_request(p_url varchar2, p_payload_text varchar2)
return clob
is
v_req utl_http.req;
v_resp utl_http.resp;
v_req varchar2(32767);
v_resp clob;
v_resp_chunked varchar2(32767);
v_xml_resp xmltype;
begin
utl_http.set_response_error_check(true);
v_req := utl_http.begin_request(
url => p_url
, method => 'POST'
, http_version => 'HTTP/1.1'
);
utl_http.set_body_charset(v_req, 'UTF-8');
utl_http.set_persistent_conn_support(false, 0);
utl_http.set_header(v_req, 'Content-Type', 'text/xml;charset=UTF-8');
utl_http.set_header(v_req, 'Content-Length', length(p_payload_text));
utl_http.write_text(v_req, p_payload_text);
v_resp := utl_http.get_response(v_req);
dbms_output.put_line(v_resp_chunked);
dbms_lob.createtemporary(v_resp,true, dbms_lob.session);
begin
loop
utl_http.read_text(v_resp, v_resp_chunked, 32767);
--dbms_output.put_line(v_resp_chunked);
dbms_lob.append(v_resp, v_resp_chunked);
end loop;
exception
when utl_http.end_of_body or UTL_HTTP.TOO_MANY_REQUESTS then
utl_http.end_response(v_resp);
dbms_output.put_line('mess:' ||SQLERRM);
end;
dbms_lob.freetemporary(v_resp);
return v_resp;
end;
ORA-29263: HTTP protocol error is thrown in following scenarios:-
Case 1: URL is not https.
--> Check the URL and make sure it is https and not http.
Case 2: wallet certificate is not set up correctly.
Do you use something like UTL_ENCODE.BASE64_ENCODE for building of request? Try to fix request string using
REPLACE(your_request, UTL_TCP.CRLF, '');
Related
I have created a logic app to receive an http request and validate the content which is fine. But when I receive the 400 error message, it said only that it was expecting an integer but received a string for example. I would like to add the name of the field that generates the error is it possible?
postman response
I added an http response to be executed when the requst fails but it's never triggered.
logic flow
You can assign http response to a variable and then you can check which filed is causing error.
I have reproduced issue from my side and below are steps I followed,
Initially created logic app as shown below,
Payload of http trigger is,
Logic app trigger is enabled with schema validation,
I have tried to run trigger with below payload,
{
"number":1600,
"street_name":"pennsylvania",
"street_type":7
}
Got error "Failed to start a run of logic app alertschlapp. The input body for trigger 'manual' of type 'Request' did not match its schema definition. Error details: 'Invalid type. Expected String but got Integer.'."
Next modified logic app as shown below,
Added three initialize variables action for number, street_name and street_type
number:
street_name:
street_type:
Ran the logic app with below payload,
"number":1600,
"street_name":"pennsylvania",
"street_type":7
Logic app failed with below error,
In this way, you can find out which field value is causing issue.
I get this error:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1-b24 logs.
GlassFish Server Open Source Edition 3.1-b24
when I try to forward from a jsp to another jsp or when I forward in a servlet... The thing is that Y modify some datils from my page and I want to go back to the login-page and log in again to see if the update was successful !... Any ideas on this error ?... Thankx
A NullPointerException is a rather trivial exception and has actually nothing to do with JSP/Servlets, but with basic Java in general (look, it's an exception of java.lang package, not of javax.servlet package). It just means that some object is null while your code is trying to access/invoke it using the period . operator.
Something like:
SomeObject someObject = null;
someObject.doSomething(); // NullPointerException!
The 1st line of the stacktrace tells you in detail all about the class name, method name and line number where it occurred.
Fixing it is relatively easy. Just make sure that it's not null or bypass the access altogether. You should rather concentrate on why it is null and/or why your code is trying to deal with null.
I would like to submit some information collected from user during Inno setup installation to our server via POST.
Obvious solution would be to include an .exe file that the setup would extract into temporary location and launch with parameters. However, I'm wondering - is there is any easier/better way?
Based on jsobo advice of using WinHTTP library, I came with this very simple code that does the trick. Say, you want to send serial number for verification just before the actual installation starts. In the Code section, put:
procedure CurStepChanged(CurStep: TSetupStep);
var
WinHttpReq: Variant;
begin
if CurStep = ssInstall then
begin
if AutoCheckRadioButton.Checked = True then
begin
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
WinHttpReq.Open('POST', '<your_web_server>', false);
WinHttpReq.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
WinHttpReq.Send('<your_data>');
{ WinHttpReq.ResponseText will hold the server response }
end;
end;
end;
The Open method takes as arguments the HTTP method, the URL and whether to do async request and it seems like we need to add SetRequestHeader in order to set the Content-Type header to application/x-www-form-urlencoded.
WinHttpReq.Status will hold the response code, so to check if the server returned successfully:
if WinHttpReq.Status <> 200 then
begin
MsgBox('ERROR', mbError, MB_OK);
end
else
begin
MsgBox('SUCCESS', mbInformation, MB_OK);
end;
https://learn.microsoft.com/en-us/windows/win32/winhttp/winhttprequest lists all methods and properties of the WinHttpRequest object.
Also, to avoid run-time errors (can happen if the host is unreachable) it is a good idea to surround the code with try/except code.
You could always have your installer use curl
to make the http post...
You could write a pascal script right in innosetup to do the call utilizing the winhttp library
Or you could just write a vbscript and execute that with the cscript engine to do the same http call via the winhttp library.
That should point you to at least 3 different options to do what you need.
I think putting the exe in there would be the least error prone but utilizing the winhttp library with the pascal script (used by innosetup) would be the most simple.
I haven't tried it but the ISXKB has an entry for an uninstall survey that uses an HTTP POST:
http://www.vincenzo.net/isxkb/index.php?title=Uninstall_Survey
Thanks in advance for any help received.
I want to allow our client to enter a URL into a text field which then checks whether the URL exists and works.
There are 3 possible outcomes I want to check for:
A status of 200 - OK,
A status of 500 - Server Error,
Or a status of 404 - page not found.
When executing the following code in ASP classic I get a status code of 12007 when I should be getting 404. Is this because it can't find a webserver to return a code of 404?
Function CheckURL(vURL)
ON ERROR RESUME NEXT
Set oXML=Server.CreateObject("MSXML2.XMLHTTP") : oXML.Open "POST",vURL,false : oXML.Send()
CheckURL = oXML.status
Set oXML = nothing
End Function
Or is something amiss here. What status codes am I likely to see other than the standard mentioned above.
The 12007 is a Windows HTTP error which means name hasn't been resolved. You can't get a 200, 404, 500 or any such thing if the host name can't be resolved to an IP address or a connection can't be established to that IP address. In these cases you will get error codes in the 12000s range which aren't HTTP status codes but are windows exception numbers.
See this list for a list of these exception numbers.
BTW, XMLHTTP is not a safe item object to use in ASP. Also why are you using a POST? This is the code I would use:-
Function CheckURL(vURL)
On Error Resume Next
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.3.0")
xhr.Open "HEAD", vURL, false
xhr.Send
CheckURL = xhr.status
End Function
Using HEAD allows you test the URL without actually downloading a potentially large entity body.
Can someone help me with this problem that occurs whenever you run a TRIGGER, but works in a normal PROCEDURE?
TRIGGER:
create or replace
procedure testeHTTP(search varchar2)
IS
Declare
req sys.utl_http.req;<BR>
resp sys.utl_http.resp;<BR>
url varchar2(500);
Begin
url := 'http://www.google.com.br';
dbms_output.put_line('abrindo');
-- Abrindo a conexão e iniciando uma requisição
req := sys.utl_http.begin_request(search);
dbms_output.put_line('preparando');
-- Preparandose para obter as respostas
resp := sys.utl_http.get_response(req);
dbms_output.put_line('finalizando response');
-- Encerrando a comunicação request/response
sys.utl_http.end_response(resp);
Exception
When Others Then
dbms_output.put_line('excecao');
dbms_output.put_line(sys.utl_http.GET_DETAILED_SQLERRM());
End;
close your user session and then the problem is fixed.
Internal there is a limit from 5 http requests.
Might a problem is the missing: utl_http.end_response
or an exception in the app and not a close from the resp object.
modify the code like that:
EXCEPTION
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
UTL_HTTP.END_RESPONSE(resp);
you need to close your requests once you are done with them, it does not happen automatically (unless you disconnect form the db entirely)
It used to be utl_http.end_response, but I am not sure if it is the same api any more.
Usually we need UTL_HTTP.END_RESPONSE(resp); to avoid of ORA-29270: too many open HTTP requests, but I think I reproduced the problem of #Clóvis Santos in Oracle 19c.
If web-service always returns status 200 (success) then too many open HTTP requests never happens. But if persistent connections are enabled and web-service returns status 404, behavior becomes different.
Let`s call something that always return 404.
First call of utl_http.begin_request returns normally and opens new persistent connection. We can check it with select utl_http.get_persistent_conn_count() from dual;. Second call causes an exception inside utl_http.begin_request and persistent connection becomes closed. (Exception is correctly handled with end_response/end_request).
If I continue then each odd execution returns 404 normally and each even execution gives an exception (handled correctly of course).
After some iterations I get ORA-29270: too many open HTTP requests. If web-service returns status 200 everything goes normally.
I guess, it happens because of the specific web-service. Probable it drops persistent connection after 404 and doesn't after 200. Second call tries to reuse request on persistent connection but it doesn't exist and causes request leak.
If I use utl_http.set_persistent_conn_support (false, 0); once in my session the problem disappears. I can call web-service as many times as I need.
Resolution:
Try to switch off persistent connection support. Probable, on the http-server persistent connections work differently for different requests. Looks like a bug.