"InternalError" in resource when consuming a function that returns xmltype in Oracle

,

I created a function in my Oracle database, which returns a simple xmltype.

function fnc_retool (
  p_test number
) return xmltype as
  v_result xmltype;
begin  
  v_result := xmltype('
    <test type="object">
      <id type="number">999</id>
      <key type="string">484220449406748</key>
    </test>
  ');
  
  return v_result;
end;

But when I call this function in resource, connected to my DB, with the code (example):

declare
  v_test xmltype;
begin
  select my_schema.pkg_temp.fnc_retool(p_test => 0) into v_test from dual;
end;

I receveid the error:

name:"InternalError"
message:"Unexpected end of JSON input"

I think I found the issue with my query, probably not xmltype related, but with the query itself. When I change to this:

select my_schema.pkg_temp.fnc_retool(p_test => 0) as v_test from dual

I got success result.