我想从PL/SQL代码调用webservice,它将接受itemnumber作为输入参数,并返回约8个输出参数,其中一些是字符串而几个将在base64binay编码的PDF文件。从PL/SQL调用SOAP Web服务时获取415不支持的介质类型错误
当我从SoapUI测试相同的WSDL时,它返回正确的响应。
但是在我的PL/SQL代码中,我得到415 Unsupported Media Type Error。你能帮我解决这个问题吗,我陷入了过去5天的这个错误。提前致谢。
下面是我的虚拟代码,一旦它工作正常,那么我需要转换成一个适当的功能。
declare
soap_request varchar2(30000);
soap_respond CLOB;
soap_respond_temp CLOB;
http_req utl_http.req;
http_resp utl_http.resp;
l_resp XMLType;
i integer;
instr_start integer;
instr_end integer;
l_orgname varchar2(30000);
l_description VARCHAR2(250);
l_long_description VARCHAR2(1000);
l_segment1 VARCHAR2(250);
l_item_type VARCHAR2(100);
l_isbn VARCHAR2(100);
l_match_score NUMBER;
l_pdh_id NUMBER;
l_cross_reference_id NUMBER;
l_soap_request CLOB;
l_soap_response CLOB;
l_soap_resp_raw LONG RAW;
l_buffer_size NUMBER (10) := 512;
l_substring_msg VARCHAR2 (512);
l_string_request VARCHAR2 (512);
l_raw_data RAW (512);
buffer VARCHAR2 (32767);
i NUMBER;
eob BOOLEAN := FALSE;
resultvar VARCHAR2 (30000);
begin
--Item number 104PT is I/p parameter below to the SOAP webservice
soap_request:= '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:grad="http://grades.web.spec.quality.asmorg.com/">
<soap:Header/>
<soap:Body>
<grad:getGradeInfoForRM>
<strRMItem>104PT</strRMItem>
</grad:getGradeInfoForRM>
</soap:Body>
</soap:Envelope>';
http_req:= utl_http.begin_request
('http://112.18.28.38:81/Itemspec/ItemGradeWSPort'
, 'POST'
, 'HTTP/1.1'
);
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header(http_req, 'SOAPAction', '');
utl_http.write_text(http_req, soap_request);
http_resp:= utl_http.get_response(http_req);
--dbms_output.put_line('got the soap response');
dbms_output.put_line('Response> status_code: "' ||http_resp.status_code || '"');
dbms_output.put_line('Response> reason_phrase: "' ||http_resp.reason_phrase || '"');
dbms_output.put_line('Response> http_version: "' ||http_resp.http_version || '"');
DBMS_LOB.createtemporary (l_soap_response, TRUE);
fnd_file.put_line(fnd_file.log,'After create temporary');
WHILE NOT (eob)
LOOP
BEGIN
dbms_output.put_line ('before read_text');
UTL_HTTP.read_text (http_resp, buffer, 32767);
fnd_file.put_line(fnd_file.log,'Printing Buffer '||buffer);
dbms_output.put_line('Printing Buffer '||buffer);
IF buffer IS NOT NULL AND LENGTH (buffer) > 0
THEN
fnd_file.put_line(fnd_file.log,'Appending to l_soap_response using DBMS writeappend');
dbms_output.put_line (' Appending to l_soap_response using DBMS writeappend');
DBMS_LOB.writeappend (l_soap_response, LENGTH (buffer), buffer);
END IF;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
fnd_file.put_line(fnd_file.log,'end of body');
eob := TRUE;
END;
END LOOP;
UTL_HTTP.end_response (http_resp);
fnd_file.put_line (fnd_file.log,'before XMLTYPE Call');
dbms_output.put_line ('before XMLTYPE Call');
l_resp := XMLTYPE.createxml (l_soap_response);
DBMS_LOB.freetemporary (l_soap_response);
fnd_file.put_line(fnd_file.log,'--after XMLTYPE Call');
dbms_output.put_line ('after XMLTYPE Call');
resultvar := l_resp.getstringval();
fnd_file.put_line(fnd_file.log,'--after getstringval Call');
fnd_file.put_line (fnd_file.log,resultvar);
fnd_file.put_line (fnd_file.log,'End DateTime:- ' || SYSTIMESTAMP);
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
dbms_output.put_line('end of body');
UTL_HTTP.end_response(http_resp);
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
UTL_HTTP.END_RESPONSE(http_resp);
WHEN OTHERS THEN
dbms_output.put_line('others eception '||SQLERRM);
end;
这里打印日志消息:
响应> STATUS_CODE: “415” 响应> reason_phrase:前XMLTYPE呼叫前read_text “不支持的媒体类型” 别人eception ORA-31011:XML解析失败 ORA-19202:在XML处理中发生错误 LPX-00229:输入源为空