Decoding base64 data
454278Aug 15 2007 — edited Aug 15 2007Hi,
I am making a webservice call, the result of which is an XML document.
One of the elements is base64 encoded (an image), which i need to write to a file, i.e. re-create the image.
I am trying to go through the UTL_ENCODE package, but would really appreciate if anyone can help me in this.
The structure of the XML Document is :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<FaxBarcodeResponse xmlns="http://tempuri.org/">
<FaxBarcodeResult>
<FaxID>int</FaxID>
<DocumentImage>
<Bytes>base64Binary</Bytes>
<ContentType>string</ContentType>
<DocumentName>string</DocumentName>
<ShowPDF>boolean</ShowPDF>
<Size>int</Size>
</DocumentImage>
</FaxBarcodeResult>
</FaxBarcodeResponse>
</soap:Body>
</soap:Envelope>
The pl/sql code is:
.....
http_req:= utl_http.begin_request
( 'http://niws.mynewimageexpress.net/apolloservicev20.asmx'
, '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', 'http://tempuri.org/FaxBarcode');
utl_http.write_text(http_req, soap_request);
http_resp:= utl_http.get_response(http_req);
utl_http.read_text(http_resp, soap_respond);
utl_http.end_response(http_resp);
....
The XML at this point is in a VARCHAR2 variable.
How should i proceed from here? Should i convert the XML into XMLType, extract the node I am interested in, decode it and write (RAW) to file?
Any guidance would be greatly appreciated.
Thanks
Ashish