[英]xml soap response parse pdf file oracle
I am consuming a SOAP base service which is returning a pdf file in response, i want to parse response into a blob type.我正在使用一个 SOAP 基础服务,它返回一个 pdf 文件作为响应,我想将响应解析为 blob 类型。 I have below code to consume soap service , however i am getting pdf file but its failed open or download as its invalid file.
我有下面的代码来使用soap服务,但是我得到了pdf文件,但它打开失败或下载为无效文件。
declare
p_ref_no varchar2(100) := '290313008810';
l_key varchar2(100) := post_shipments_shipper.getKey('LIVE');
l_envelope CLOB;
l_xml XMLTYPE;
l_result varchar2(2000);
l_pdf clob;
l_pdf_file blob;
pragma autonomous_transaction;
begin
l_envelope := '<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sms="http://track.smsaexpress.com/secom/SMSAWebserviceIntl">
<soapenv:Body>
<sms:getPDF>
<sms:awbNo>'||p_ref_no||'</sms:awbNo>
<sms:passKey>'||l_key||'</sms:passKey>
</sms:getPDF>
</soapenv:Body>
</soapenv:Envelope>';
-- Get the XML response from the web service.
l_xml := APEX_WEB_SERVICE.make_request(
p_url => 'http://track.smsaexpress.com/SECOM/SMSAwebServiceIntl.asmx',
p_action => 'http://track.smsaexpress.com/secom/SMSAWebserviceIntl/getPDF',
p_envelope => l_envelope
);
-- Display the whole SOAP document returned.
-- DBMS_OUTPUT.put_line('l_xml= ' || l_xml.getClobVal());
-- RETURN l_xml.getClobVal();
l_pdf := APEX_WEB_SERVICE.parse_xml_clob(
p_xml => l_xml,
p_xpath => '//getPDFResult',
p_ns => 'xmlns="http://track.smsaexpress.com/secom/SMSAWebserviceIntl"'
);
l_pdf_file := APEX_WEB_SERVICE.CLOBBASE642BLOB(l_pdf);
delete from shipment_labels;
insert into shipment_labels values (l_pdf_file,'abc.pdf','application/pdf',l_pdf);
commit;
end;
I am trying to to parse pdf file and inserting into a table with column type blob , however file contents are invalid and unable to open as media.我正在尝试解析 pdf 文件并插入到列类型为 blob 的表中,但是文件内容无效并且无法作为媒体打开。
I think the issue is in your parse_xml_clob
call.我认为问题出在您的
parse_xml_clob
调用中。 If you look at your l_pdf values which are getting saved in the table, I think they will look like this:如果您查看保存在表中的 l_pdf 值,我认为它们将如下所示:
<getPDFResult xmlns="http://track.smsaexpress.com/secom/SMSAWebserviceIntl">...your base64Binary...</getPDFResult>
But you only want the inside text.但是您只需要内部文本。 Based on the example in the documentation , you want the XPath to return the text node(s) inside the
<getPDFResult>
node, not the node itself.根据文档中的示例,您希望 XPath 返回
<getPDFResult>
节点内的文本节点,而不是节点本身。
l_pdf := APEX_WEB_SERVICE.parse_xml_clob(
p_xml => l_xml,
p_xpath => '//getPDFResult/text()',
p_ns => 'xmlns="http://track.smsaexpress.com/secom/SMSAWebserviceIntl"'
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.