Blob to base64 encoded XML
Hi,
We have a table with two columns (Name varchar2, Picture Blob).
How do we get XML output containing rows from table, with Picture (blob column) being base64 encoded.
Note: I have tried using utl_encode.base64_encode, but getting error due to large size of Picture.
Thanks,
Yj
I am not sure what you finally want to accomplish (create a binary xml?), but to base64 encode a blob you could do it »stepwise«:
declare
bl blob; /* your picture blob */
bl_enc blob; /* encoded blob */
offset integer := 1;
amt integer := 20000;
begin
dbms_lob.createtemporary (bl_enc, false);
while dbms_lob.substr (bl, amt, offset) is not null
loop
dbms_lob.append (bl_enc, utl_encode.base64_encode (dbms_lob.substr (bl, amt, offset)));
offset := offset + amt;
end loop;
convert_to_xml(bl_enc);
dbms_lob.freetemporary (bl_enc);
end;
/
Similar Messages
-
Problem with base64 encoding an xml file with accented characters
Oracle 10.2.0.1.0 Enterprise Edition running under windows 2003 server
DB Characterset UTF-8
I have a routine which takes an xml file and base64 encodes it, and the base64encoded text is stored in a clob column of a table.
The xml file is stored in UTF-8 format.
The routine works correctly, except when there are accented characters.
I am using dbms_lob.loadclobfrom file to load the file.
DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
DBMS_LOB.LoadCLOBFromFile(
DEST_LOB => dest_clob
, SRC_BFILE => src_clob
, AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
, DEST_OFFSET => dst_offset
, SRC_OFFSET => src_offset
, BFILE_CSID =>dbms_lob.default_csid
, LANG_CONTEXT => lang_ctx
, WARNING => warning
DBMS_LOB.CLOSE(src_clob);base 64 encoded xml with accented character -- incorrect
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxncDpBcHBs
aWNhdGlvblByb2ZpbGUgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAx
L1hNTFNjaGVtYS1pbnN0YW5jZSINCiAgICB4c2k6c2NoZW1hTG9jYXRpb249Imh0
dHA6Ly9uYW1lc3BhY2VzLmdsb2JhbHBsYXRmb3JtLm9yZy9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z
eXN0ZW1zLXByb2ZpbGVzLzEuMS4wL0dQLnN5c3RlbXMucHJvZmlsZXMuMS4xLjAu
QXBwbGljYXRpb25Qcm9maWxlLnhzZCINCiAgICB4bWxuczpncD0iaHR0cDovL25h
bWVzcGFjZXMuZ2xvYmFscGxhdGZvcm0ub3JnL3N5c3RlbXMtcHJvZmlsZXMvMS4x
LjAiDQogICAgVW5pcXVlSUQ9Ik1FIiBQcm9maWxlVmVyc2lvbj0iMS4xLjAiIEVy
cmF0YVZlcnNpb249IjAiPg0KICAgIDxncDpEZXNjcmlwdGlvbj5Gb3J1bSBUZXN0
PC9ncDpEZXNjcmlwdGlvbj4NCiAgICA8Z3A6RGF0YUVsZW1lbnQgTmFtZT0iYWNj
ZW50IiBFeHRlcm5hbD0idHJ1ZSIgVHlwZT0iQnl0ZVN0cmluZyIgRW5jb2Rpbmc9
IkhFWCIgRml4ZWRMZW5ndGg9ImZhbHNlIiBMZW5ndGg9IjE2IiBSZWFkV3JpdGU9
InRydWUiIFVwZGF0ZT0idHJ1ZSIgT3B0aW9uYWw9InRydWUiIC8+ICAgIA0KPC9n
cDpBcHBsaWNhdGlvblByb2ZpbGU+DQo=the xml file in use is
<?xml version="1.0" encoding="UTF-8"?>
<gp:ApplicationProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://namespaces.globalplatform.org/systems-profiles/1.1.0 http://namespaces.globalplatform.org/systems-profiles/1.1.0/GP.systems.profiles.1.1.0.ApplicationProfile.xsd"
xmlns:gp="http://namespaces.globalplatform.org/systems-profiles/1.1.0"
UniqueID="ME" ProfileVersion="1.1.0" ErrataVersion="0">
<gp:Description>Forum Test</gp:Description>
<gp:DataElement Name="áccent" External="true" Type="ByteString" Encoding="HEX" FixedLength="false" Length="16" ReadWrite="true" Update="true" Optional="true" />
</gp:ApplicationProfile>The file is being loaded from a windows xp professional 32 bit system.
If I just convert the xml text of the file using
select utl_raw.cast_to_varchar2(
utl_encode.base64_encode(
utl_raw.cast_to_raw(
'<?xml version="1.0" encoding="UTF-8"?>
<gp:ApplicationProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://namespaces.globalplatform.org/systems-profiles/1.1.0 http://namespaces.globalplatform.org/systems-profiles/1.1.0/GP.systems.profiles.1.1.0.ApplicationProfile.xsd"
xmlns:gp="http://namespaces.globalplatform.org/systems-profiles/1.1.0"
UniqueID="ME" ProfileVersion="1.1.0" ErrataVersion="0">
<gp:Description>Forum Test</gp:Description>
<gp:DataElement Name="áccent" External="true" Type="ByteString" Encoding="HEX" FixedLength="false" Length="16" ReadWrite="true" Update="true" Optional="true" />
</gp:applicationprofile>'
))) from dual;I get the following
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGdwOkFwcGxp
Y2F0aW9uUHJvZmlsZSB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEv
WE1MU2NoZW1hLWluc3RhbmNlIgogICAgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRw
Oi8vbmFtZXNwYWNlcy5nbG9iYWxwbGF0Zm9ybS5vcmcvc3lzdGVtcy1wcm9maWxl
cy8xLjEuMCBodHRwOi8vbmFtZXNwYWNlcy5nbG9iYWxwbGF0Zm9ybS5vcmcvc3lz
dGVtcy1wcm9maWxlcy8xLjEuMC9HUC5zeXN0ZW1zLnByb2ZpbGVzLjEuMS4wLkFw
cGxpY2F0aW9uUHJvZmlsZS54c2QiCiAgICB4bWxuczpncD0iaHR0cDovL25hbWVz
cGFjZXMuZ2xvYmFscGxhdGZvcm0ub3JnL3N5c3RlbXMtcHJvZmlsZXMvMS4xLjAi
CiAgICBVbmlxdWVJRD0iTUUiIFByb2ZpbGVWZXJzaW9uPSIxLjEuMCIgRXJyYXRh
VmVyc2lvbj0iMCI+CiAgICA8Z3A6RGVzY3JpcHRpb24+Rm9ydW0gVGVzdDwvZ3A6
RGVzY3JpcHRpb24+CiAgICA8Z3A6RGF0YUVsZW1lbnQgTmFtZT0iw6FjY2VudCIg
RXh0ZXJuYWw9InRydWUiIFR5cGU9IkJ5dGVTdHJpbmciIEVuY29kaW5nPSJIRVgi
IEZpeGVkTGVuZ3RoPSJmYWxzZSIgTGVuZ3RoPSIxNiIgUmVhZFdyaXRlPSJ0cnVl
IiBVcGRhdGU9InRydWUiIE9wdGlvbmFsPSJ0cnVlIiAvPiAgICAKPC9ncDphcHBs
aWNhdGlvbnByb2ZpbGU+Edited by: Keith Jamieson on Jul 13, 2012 9:59 AM
added code tag for last base64 encoded objectNot sure if utl_i18n is already there in version prior to 11.2.0.2.
But on above mentioned version I can do the simplified method
SQL> SELECT utl_i18n.raw_to_char (
utl_encode.base64_encode (
xmltype (
'<?xml version="1.0" encoding="UTF-8"?>
<gp:ApplicationProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://namespaces.globalplatform.org/systems-profiles/1.1.0 http://namespaces.globalplatform.org/systems-profiles/1.1.0/GP.systems.profiles.1.1.0.ApplicationProfile.xsd"
xmlns:gp="http://namespaces.globalplatform.org/systems-profiles/1.1.0"
UniqueID="ME" ProfileVersion="1.1.0" ErrataVersion="0">
<gp:Description>Forum Test</gp:Description>
<gp:DataElement Name="áccent" External="true" Type="ByteString" Encoding="HEX" FixedLength="false" Length="16" ReadWrite="true" Update="true" Optional="true" />
</gp:ApplicationProfile>').getblobval (
NLS_CHARSET_ID ('utf8'))),
'utf8')
x
FROM DUAL
X
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGdwOkFwcGxp
Y2F0aW9uUHJvZmlsZSB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEv
WE1MU2NoZW1hLWluc3RhbmNlIiB4c2k6c2NoZW1hTG9jYXRpb249Imh0dHA6Ly9u
YW1lc3BhY2VzLmdsb2JhbHBsYXRmb3JtLm9yZy9zeXN0ZW1zLXByb2ZpbGVzLzEu
MS4wIGh0dHA6Ly9uYW1lc3BhY2VzLmdsb2JhbHBsYXRmb3JtLm9yZy9zeXN0ZW1z
LXByb2ZpbGVzLzEuMS4wL0dQLnN5c3RlbXMucHJvZmlsZXMuMS4xLjAuQXBwbGlj
YXRpb25Qcm9maWxlLnhzZCIgeG1sbnM6Z3A9Imh0dHA6Ly9uYW1lc3BhY2VzLmds
b2JhbHBsYXRmb3JtLm9yZy9zeXN0ZW1zLXByb2ZpbGVzLzEuMS4wIiBVbmlxdWVJ
RD0iTUUiIFByb2ZpbGVWZXJzaW9uPSIxLjEuMCIgRXJyYXRhVmVyc2lvbj0iMCI+
CiAgPGdwOkRlc2NyaXB0aW9uPkZvcnVtIFRlc3Q8L2dwOkRlc2NyaXB0aW9uPgog
IDxncDpEYXRhRWxlbWVudCBOYW1lPSLDoWNjZW50IiBFeHRlcm5hbD0idHJ1ZSIg
VHlwZT0iQnl0ZVN0cmluZyIgRW5jb2Rpbmc9IkhFWCIgRml4ZWRMZW5ndGg9ImZh
bHNlIiBMZW5ndGg9IjE2IiBSZWFkV3JpdGU9InRydWUiIFVwZGF0ZT0idHJ1ZSIg
T3B0aW9uYWw9InRydWUiLz4KPC9ncDpBcHBsaWNhdGlvblByb2ZpbGU+Cg==
1 row selected.which encodes and decodes properly on my system even with accented characters. -
Parsing a UTF-8 encoded XML Blob object
Hi,
I am having a really strange problem, I am fetching a database BLOB object containing the XMLs and then parsing the XMLs. The XMLs are having some UTF-8 Encoded characters and when I am reading the XML from the BLOB, these characters lose their encoding, I had tried doing several things, but there is no means I am able to retain their UTF encoding. The characters causing real problem are mainly double qoutes, inverted commas, and apostrophe. I am attaching the piece of code below and you can see certain things I had ended up doing. What else can I try, I am using JAXP parser but I dont think that changing the parser may help because, here I am storing the XML file as I get from the database and on the very first stage it gets corrupted and I have to retain the UTF encoding. I tried to get the encoding info from the xml and it tells me cp1252 encoding, where did this come into picture and I couldn't try it retaining back to UTF -8
Here in the temp.xml itself gets corrupted. I had spend some 3 days on this issue. Help needed!!!
ResultSet rs = null;
Statement stmt = null;
Connection connection = null;
InputStream inputStream = null;
long cifElementId = -1;
//Blob xmlData = null;
BLOB xmlData=null;
String xmlText = null;
RubricBean rubricBean = null;
ArrayList arrayBean = new ArrayList();
rs = stmt.executeQuery(strQuery);
// Iterate till result set has data
while (rs.next()) {
rubricBean = new RubricBean();
cifElementId = rs.getLong("CIF_ELEMENT_ID");
// get xml data which is in Blob format
xmlData = (oracle.sql.BLOB)rs.getBlob("XML");
// Read Input stream from blob data
inputStream =(InputStream)xmlData.getBinaryStream();
// Reading the inputstream of data into an array of bytes.
byte[] bytes = new byte[(int)xmlData.length()];
inputStream.read(bytes);
// Get the String object from byte array
xmlText = new String(bytes);
// xmlText=new String(szTemp.getBytes("UTF-8"));
//xmlText = convertToUTF(xmlText);
File file = new File("C:\\temp.xml");
file.createNewFile();
// Write to temp file
java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.FileWriter(file));
out.write(xmlText);
out.close();What the code you posted is doing:
// Read Input stream from blob data
inputStream =(InputStream)xmlData.getBinaryStream();Here you have a stream containing binary octets which encode some text in UTF-8.
// Reading the inputstream of data into an
into an array of bytes.
byte[] bytes = new byte[(int)xmlData.length()];
inputStream.read(bytes);Here you are reading between zero and xmlData.length() octets into a byte array. read(bytes[]) returns the number of bytes read, which may be less than the size of the array, and you don't check it.
xmlText = new String(bytes);Here you are creating a string with the data in the byte array, using the platform's default character encoding.
Since you mention cp1252, I'm guessing your platform is windows
// xmlText=new new String(szTemp.getBytes("UTF-8"));I don't know what szTemp is, but xmlText = new String(bytes, "UTF-8"); would create a string from the UTF-8 encoded characters; but you don't need to create a string here anyway.
//xmlText = convertToUTF(xmlText);
File file = new File("C:\\temp.xml");
file.createNewFile();
// Write to temp file
java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.FileWriter(file));This creates a Writer to write to the file using the platform's default character encoding, ie cp1252.
out.write(xmlText);This writes the string to out using cp1252.
So you have created a string treating UTF-8 as cp1252, then written that string to a file as cp1252, which is to be read as UTF-8. So it gets mis-decoded twice.
As the data is already UTF-8 encoded, and you want the output, just write the binary data to the output file without trying to convert it to a string and then back again:// not tested, as I don't have your Oracle classes
final InputStream inputStream = new BufferedInputStream((InputStream)xmlData.getBinaryStream());
final int length = xmlData.length();
final int BUFFER_SIZE = 1024; // these two can be
final byte[] buffer = new byte[BUFFER_SIZE]; // allocated outside the method
final OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
for (int count = 0; count < length; ) {
final int bytesRead = inputStream.read(buffer, 0, Math.min(BUFFER_SIZE, (length - count));
out.write(buffer, 0, bytesRead);
count += bytesRead;
}Pete -
Convert canvas.toDataURL('image/jpeg') to java.sql.Blob.
I am using oracle adf so I am able to action a backing bean from javascript and pass in parameters as a map. I pass in the canvas.toDataURL('image/jpeg') which I then try to decode in my bean. Using BASE64Decoder and the converting the bytearray to a file I can see the image is corrupted as I can't open the file thus converting the bytearray to blob is also a waste.
Has anyone any ideas on base64 encoding from canvas.toDataURL to file or Blob?Use Case:
A jsf page that enables a user to take photos using the HTML5 canvas feature - interact with webcam -, take photos and upload to profile
1. I have created the jsf page with the javascript below; this pops up as a dialog and works okay and onclick an upload image, triggers the snapImage javascript function below and sends the imgURL parameter to the serverside managedbean
<!-- java script-->
function snapImage(event){
var canvas = AdfPage.PAGE.findComponent('canvas');
AdfCustomEvent.queue(event.getSource(),"getCamImage",{imgURL:canvas.toDataURL('image/jpeg'),true);
event.cancel();
<!-- bean -->
public void getCamImage(ClientEvent ce){
String url=(String)ce.getAttributes().get("imgURL");
decodeBase64URLToBlob(url);
private BlobDomain decodeBaseB4URLToBlob(String url64){
BASE64Decoder de=new BASE64Decoder();
byte[] bytes=de.decode(url64);
File file=new File("abc.jpg");
InputStream in = new ByteArrayInputStream(bytes);
BufferedImage bImageFromConvert = ImageIO.read(in);
in.close();
ImageIO.write(bImageFromConvert, "jpg", file);
return createBlobDomainFromFile(file);
----problem---
Accessing the generated jpeg file shows the image is corrupted, probably missing bytes or encode/decoder issues.and the blob image after uploading to database is saved as a binary stream which ondownload doesnt render as an image or anything i know of.
Is there anyways of achieving the conversion without errors? -
Support on 'Base64 encoding in XML gateway Web service SOAP content'
Hi Experts,
IHAC who's requirement is as follows:
They are currently using Web service protocol to send order information from Oracle Applications to their trading partner.
But need to encode the payload in base64 encoding in the SOAP request.
Further details:
=====================================================================
Current SOAP request is,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bac="http://backend.ws.gtas.gridnode.com">
<soapenv:Header/>
<soapenv:Body>
<bac:backendImport4>
<bac:username>?</bac:username>
<bac:password>?</bac:password>
<bac:recipient>?</bac:recipient>
<bac:contentFileName>?</bac:contentFileName>
<bac:content>
<EMPLOYEE>
<EMPLOYEE_DATA>
<EMAIL_ADDRESS/>
<EMPLOYEE_ID>81</EMPLOYEE_ID>
<EMPLOYEE_NUM>2</EMPLOYEE_NUM>
<FIRST_NAME/>
<FULL_NAME>Eddi.S,</FULL_NAME>
<LAST_NAME>Eddi.S</LAST_NAME>
<MIDDLE_NAME/>
</EMPLOYEE_DATA>
</EMPLOYEE>
</bac:content>
<bac:docType>?</bac:docType>
</bac:backendImport4>
</soapenv:Body>
</soapenv:Envelope>
Required SOAP request with base64 encoding is:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bac="http://backend.ws.gtas.gridnode.com">
<soapenv:Header/>
<soapenv:Body>
<bac:backendImport4>
<bac:username>?</bac:username>
<bac:password>?</bac:password>
<bac:recipient>?</bac:recipient>
<bac:contentFileName>?</bac:contentFileName>
<bac:content>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9J25vJz8+DQo8IURPQ1RZUEUgRU1QTE9ZRUU+DQo8IS0tIE9yYWNsZSBlWHRlbnNpYmxlIE1hcmt1cCBMYW5ndWFnZSBHYXRld2F5IFNlcnZlciAgLS0+DQo8RU1QTE9ZRUU+DQogIDxFTVBMT1lFRV9EQVRBPg0KICAgIDxFTUFJTF9BRERSRVNTLz4NCiAgICA8RU1QTE9ZRUVfSUQ+ODE8L0VNUExPWUVFX0lEPg0KICAgIDxFTVBMT1lFRV9OVU0+MjwvRU1QTE9ZRUVfTlVNPg0KICAgIDxGSVJTVF9OQU1FLz4NCiAgICA8RlVMTF9OQU1FPkVkZGkuUyw8L0ZVTExfTkFNRT4NCiAgICA8TEFTVF9OQU1FPkVkZGkuUzwvTEFTVF9OQU1FPg0KICAgIDxNSURETEVfTkFNRS8+DQogIDwvRU1QTE9ZRUVfREFUQT4NCjwvRU1QTE9ZRUU+DQo=
</bac:content>
<bac:docType>?</bac:docType>
</bac:backendImport4>
</soapenv:Body>
</soapenv:Envelope>
The issue in question is the content within the element <bac:content>.
Base64 encoding of the payload
<EMPLOYEE>
<EMPLOYEE_DATA>
<EMAIL_ADDRESS/>
<EMPLOYEE_ID>81</EMPLOYEE_ID>
<EMPLOYEE_NUM>2</EMPLOYEE_NUM>
<FIRST_NAME/>
<FULL_NAME>Eddi.S,</FULL_NAME>
<LAST_NAME>Eddi.S</LAST_NAME>
<MIDDLE_NAME/>
</EMPLOYEE_DATA>
</EMPLOYEE>
is
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9J25vJz8+DQo8IURPQ1RZUEUgRU1QTE9ZRUU+DQo8IS0tIE9yYWNsZSBlWHRlbnNpYmxlIE1hcmt1cCBMYW5ndWFnZSBHYXRld2F5IFNlcnZlciAgLS0+DQo8RU1QTE9ZRUU+DQogIDxFTVBMT1lFRV9EQVRBPg0KICAgIDxFTUFJTF9BRERSRVNTLz4NCiAgICA8RU1QTE9ZRUVfSUQ+ODE8L0VNUExPWUVFX0lEPg0KICAgIDxFTVBMT1lFRV9OVU0+MjwvRU1QTE9ZRUVfTlVNPg0KICAgIDxGSVJTVF9OQU1FLz4NCiAgICA8RlVMTF9OQU1FPkVkZGkuUyw8L0ZVTExfTkFNRT4NCiAgICA8TEFTVF9OQU1FPkVkZGkuUzwvTEFTVF9OQU1FPg0KICAgIDxNSURETEVfTkFNRS8+DQogIDwvRU1QTE9ZRUVfREFUQT4NCjwvRU1QTE9ZRUU+DQo=
========================================================================
Is there a way in XML gateway to encode the payload automatically to base64 encoding so that it can accommodate the unicode
Is there any way to encode the order information from EBS tables to base64 format in the outbound SOAP request ? Is this supported . If yes, how.?
Does this involve customization. Is it possible to use encoder/decoder provided in sites such as XSL on top of XML : http://gandhimukul.tripod.com/xslt/base64-xslt.html
Basically, They are trying to use XML Gateway to send and receive messages to a Trading Partner via SOAP. The issues is
1. Outbound: The TP web service can only receive xml content that is encoded in base 64 binary format. How do we configure to encode content using base64
2. Inbound: They want to receive messages using the SOAP architecture into XML gateway.
Please let us know if you have any detailed configuration document for this purpose. Please advise and share relevant details.
regards,
AjithHi Gurvinder,
Thanks for looking into this. Just to clarify again.
example XML content:
<?xml version="1.0" encoding="UTF-8" standalone='no'?>
<!DOCTYPE EMPLOYEE>
<!-- Oracle eXtensible Markup Language Gateway Server -->
<EMPLOYEE>
<EMPLOYEE_DATA>
<EMAIL_ADDRESS/>
<EMPLOYEE_ID>81</EMPLOYEE_ID>
<EMPLOYEE_NUM>2</EMPLOYEE_NUM>
<FIRST_NAME/>
<FULL_NAME>Eddi.S,</FULL_NAME>
<LAST_NAME>Eddi.S</LAST_NAME>
<MIDDLE_NAME/>
</EMPLOYEE_DATA>
</EMPLOYEE>
Sample Soap message that needs to be sent to our service provider is as follows
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
- <soapenv:Body>
- <ns5:backendImport5 xmlns:ns5="http://backend.ws.gtas.gridnode.com">
<ns5:username>admin</ns5:username>
<ns5:password>admin1</ns5:password>
<ns5:recipient>GT424</ns5:recipient>
<ns5:contentFileName>cabotTest.xml</ns5:contentFileName>
<ns5:content>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9J25vJz8+DQo8IURPQ1RZUEUgRU1QTE9ZRUU+DQo8IS0tIE9yYWNsZSBlWHRlbnNpYmxlIE1hcmt1cCBMYW5ndWFnZSBHYXRld2F5IFNlcnZlciAgLS0+DQo8RU1QTE9ZRUU+DQogIDxFTVBMT1lFRV9EQVRBPg0KICAgIDxFTUFJTF9BRERSRVNTLz4NCiAgICA8RU1QTE9ZRUVfSUQ+ODE8L0VNUExPWUVFX0lEPg0KICAgIDxFTVBMT1lFRV9OVU0+MjwvRU1QTE9ZRUVfTlVNPg0KICAgIDxGSVJTVF9OQU1FLz4NCiAgICA8RlVMTF9OQU1FPkVkZGkuUyw8L0ZVTExfTkFNRT4NCiAgICA8TEFTVF9OQU1FPkVkZGkuUzwvTEFTVF9OQU1FPg0KICAgIDxNSURETEVfTkFNRS8+DQogIDwvRU1QTE9ZRUVfREFUQT4NCjwvRU1QTE9ZRUU+DQo=</ns5:content>
<ns5:docType>3C3RN</ns5:docType>
</ns5:backendImport5>
</soapenv:Body>
</soapenv:Envelope>
. The xml content provided need to be encoded as base 64 encoding. The following is the equivalent of above xml content.
<ns5:content>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9J25vJz8+DQo8IURPQ1RZUEUgRU1QTE9ZRUU+DQo8IS0tIE9yYWNsZSBlWHRlbnNpYmxlIE1hcmt1cCBMYW5ndWFnZSBHYXRld2F5IFNlcnZlciAgLS0+DQo8RU1QTE9ZRUU+DQogIDxFTVBMT1lFRV9EQVRBPg0KICAgIDxFTUFJTF9BRERSRVNTLz4NCiAgICA8RU1QTE9ZRUVfSUQ+ODE8L0VNUExPWUVFX0lEPg0KICAgIDxFTVBMT1lFRV9OVU0+MjwvRU1QTE9ZRUVfTlVNPg0KICAgIDxGSVJTVF9OQU1FLz4NCiAgICA8RlVMTF9OQU1FPkVkZGkuUyw8L0ZVTExfTkFNRT4NCiAgICA8TEFTVF9OQU1FPkVkZGkuUzwvTEFTVF9OQU1FPg0KICAgIDxNSURETEVfTkFNRS8+DQogIDwvRU1QTE9ZRUVfREFUQT4NCjwvRU1QTE9ZRUU+DQo=</ns5:content>
See that the content is encoded using the base64 format.
Please help us to know how we can configure XML gateway to achieve this.
Regards,
Ajith -
Base64 encode attachments but not xml payload
Hi Everyone,
Using the soap adapter I know that I can use an adapter module and base64 encode everything. Is it possible to base64 encode the attachments but leave the soap/xml payload as text/xml?
Regards,
Joe> Using the soap adapter I know that I can use an adapter module and base64 encode everything. Is it possible to base64 encode the attachments but leave the soap/xml payload as text/xml?
Do you want to have attachments of type base64, or do you want to have transfer-encoding base64? The latter is not possible with adapter modules.
Regards
Stefan -
Problem with My Base64 Encoding CLOB Routine.
I have written a program which reads an xml file into the database
and makes it Base64encoded.
This needs to work on 10g and above
If the read length specified in the code below is greater than the length of the xml_file, then I get the expected result(output).
However if the read length is less than the length of the file, then I get a lot of '==' in the file and as a result, incorrect encoding which means that the file will not be readable through the application.
I'm pretty sure I'm reading the blob lengths correctly, and the problem is somehow related to the base64 encoding.Any help appreciated
[create or replace profile_dir as &profile_dir;
create global temporary table load_xml
(profile_text clob)
on commit delete rows;
create or replace
procedure encode_xml_clobs(p_file_in in varchar2,
p_clob_out out nocopy clob )
as
pragma autonomous_transaction;
dest_clob CLOB;
src_clob BFILE := BFILENAME('PROFILE_DIR', p_file_in);
dst_offset number := 1 ;
src_offset number := 1 ;
lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
warning number;
-- processing declarations for encoding base64 --
v_xml_string varchar2(32767);
v_string varchar2(32767);
v_start_pos number := 0;
v_read_length number := 1000;
v_final_start_pos number;
v_clob_length number;
type clob_array_type is table of clob index by binary_integer;
clob_array clob_array_type;
v_index number :=0;
-- Declarations for converting base64encoded string to a clob
v_encoded_length number;
v_temp_clob clob;
BEGIN
-- THE FOLLOWING BLOCK OF CODE WILL ATTEMPT TO INSERT / WRITE THE CONTENTS
-- OF AN XML FILE TO A CLOB COLUMN. IN THIS CASE, WE WILL USE THE NEW
-- DBMS_LOB.LoadCLOBFromFile() API WHICH *DOES* SUPPORT MULTI-BYTE
-- CHARACTER SET DATA.
-- load_xml should be a Global temporary table with on commit delete rows
INSERT INTO load_xml(profile_text)
VALUES( empty_clob())
RETURNING profile_text INTO dest_clob;
-- OPENING THE SOURCE BFILE IS MANDATORY
DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
DBMS_LOB.LoadCLOBFromFile(
DEST_LOB => dest_clob
, SRC_BFILE => src_clob
, AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
, DEST_OFFSET => dst_offset
, SRC_OFFSET => src_offset
, BFILE_CSID => DBMS_LOB.DEFAULT_CSID
, LANG_CONTEXT => lang_ctx
, WARNING => warning
DBMS_LOB.CLOSE(src_clob);
-- DBMS_OUTPUT.PUT_LINE('Loaded XML File using DBMS_LOB.LoadCLOBFromFile: (ID=1');
-- file now successfully loaded
select dbms_lob.GETLENGTH(profile_text)
into v_clob_length
from load_xml;
-- File now loaded in temporary table
-- we now need to take the clob , convert it to varchar2
v_read_length :=64;
v_xml_string := '';
while v_start_pos <= v_clob_length
loop
v_index := v_index + 1;
v_string := '';
--dbms_output.put_line('Start_pos=>'||(v_start_pos+1)||' Read Length=>'||v_read_length);
--encode base64
select utl_raw.cast_to_varchar2(
utl_encode.base64_encode(
utl_raw.cast_to_raw(dbms_lob.substr(profile_text,least(v_read_length,v_clob_length-v_start_pos),v_start_pos+1))
into v_string
from load_xml;
--dbms_output.put_line(v_string);
v_start_pos := v_start_pos+v_read_length;
clob_array(v_index) := v_string;
end loop;
p_clob_out := clob_array(1);
for i in 2 .. v_index
loop
dbms_lob.append(p_clob_out,clob_array(i));
end loop;
commit;
END;Base64 encoding encodes every 3 bytes of input data into 4 bytes of output data. It uses equal signs to indicate nodata and only at the end of the encoded sequence. Try chaning your v_read_length parameter to a multiple of 3 e.g. 960 or 1008 instead of the current 1000. I'm using multiples of 48 because the utl_encode.base64_encode function adds a linebreak for every 48 bytes of input data (64 bytes of output). If you use a value that's not divisible by 48 you will still get a legitimate encoding as long as it's divisible by 3, but you will get some lines longer than others when you append them together.
-
Hi,
We have to provide a conversion of blobs to base64 in order to exchange data with
a 3th party. I wrote the following function which is used to format an xml-message.
Problem is the supplier reads this data with a .net decode of base64 complains it's invalid and it
sees some lines with more than 76 characters which seems to be not correct.
Any ideas what is wrong are greatly appreciated.
9.2.0.4 HPUX11.11
Tnx,
Jeroen
Function getbase64String( lv_blob blob )
Return clob is
Result clob;
resultString VARCHAR2(4096);
resultString1 clob;
l_amt number default 2048;
l_raw raw(4096);
l_offset number default 1;
l_clob clob;
BEGIN
dbms_output.put_line('length blob: ' || dbms_lob.getlength( lv_blob ) );
begin
DBMS_LOB.CREATETEMPORARY(resultString1,FALSE,DBMS_LOB.CALL);
DBMS_LOB.CREATETEMPORARY(result,FALSE,DBMS_LOB.CALL);
loop
dbms_lob.read( lv_blob, l_amt, l_offset, l_raw );
l_offset := l_offset + l_amt;
-- dbms_output.put_line(' voor resultstring');
resultString := utl_raw.cast_to_varchar2( utl_encode.base64_encode( l_raw ) );
-- dbms_output.put_line(' na resultsstring');
resultString1:=to_clob(resultString);
dbms_lob.append(result,resultString1);
end loop;
exception
when no_data_found then
null;
end;
-- dbms_output.put_line('length:'||dbms_lob.getlength(result));
RETURN ( result );
END getbase64String;Yep, thats what I told you.
I have modified your code slightly.
This definitely produces your output.
Note that you were not using an oracle_directory for p_dir.
You should have said create or replace directory p_dir as 'your_location';
Instead you had p_dir varchar2(200) := 'your location';
The problem with the use of utl_file.put is you have to output a byte at a time. You were trying to output an entire clob, which is why it fell over.
Note: I also removed your exception handler as this just masks where the error is.
DECLARE
p_file varchar2(100):= 'test_img.png';
p_clob CLOB;
l_bfile BFILE;
l_step PLS_INTEGER := 19200;
dest_file varchar2(100):='test_image.html';
dest_handle UTL_FILE.file_type;
v_start number := 1;
BEGIN
dbms_output.put_line('Encoding starts');
l_bfile := BFILENAME('BFILE_DIR', p_file);
dbms_output.put_line('File is going to open');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
dest_handle := UTL_FILE.fopen('BFILE_DIR', dest_file, 'w', 32767);
FOR i IN 0 .. TRUNC((DBMS_LOB.getlength(l_bfile) - 1 )/l_step) LOOP
dbms_output.put_line('Inside encodeing :'||i);
p_clob := p_clob||UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(DBMS_LOB.substr(l_bfile, l_step, i * l_step + 1)));
END LOOP;
dbms_output.put_line('Base64 encoded');
p_clob:= '<img src="data:image/png;base64,'||p_clob||'" width="32" height="32">';
dbms_output.put_line('Assignment completed');
for i in 1 .. dbms_lob.getlength(p_clob)
loop
UTL_FILE.put(dest_handle, dbms_lob.substr(p_clob,1,v_start));
v_start := v_start+1;
end loop;
DBMS_LOB.fileclose(l_bfile);
UTL_FILE.fclose(dest_handle);
end;
/ -
Base64 encoding in SOAP adapter
Hi,
Is it possible to transform outgoing messages to Base64 encoding format in XI using module processors and security encryption? I'm using receiver SOAP adapter (without SOAP header) and using PayloadZipBean module processor to zip the outgoing message. Also I need to add digital signature and base64 encryption to the zipped message. Please let me know how this can be achieved.
Thanks,
Dipankarhi dipankar
check the below blog
How to use Digital Certificates for Signing & Encrypting Messages in XI
How to use Digital Certificates for Signing & Encrypting Messages in XI
hope this resolves your issue
additionally check this
How to use Client Authentication with SOAP Adapter
How to use Client Authentication with SOAP Adapter
also
How XML Encryption can be done using web services security in SAP NetWeaver XI
How XML Encryption can be done using web services security in SAP NetWeaver XI
reward points if helpfull
regards
kummari
Edited by: kummari on Jul 19, 2008 7:24 AM -
Flex XML Parsing fails on UTF-8 encoded XML.
Flex doesn't see reliable enough for handling XML.
This basic XML file causes an error in flex. Depending on the contents of the XML, it may or may not be invalid...and its not the characters. If I put in one type of UTF8 characters, the XML is OK, if I put in another type, its also OK. If I however put in both types...then the XML fails.
So in summary, good + good = bad.
Multiple browsers, multiple versions of Flash (latest, as well as a couple prior releases), multiple OS's.
XML headers indicate the content type correctly: Content-Type: text/xml;charset=utf-8
Any suggestions?
--BenI worked around the bad XML handling in Flex by Base64 encoding my data, then Base64 decoding it in Flex. I used com.dynamicflash.util.Base64 to do the decoding.
Its a shame though...wasting extra CPU and making the flash slower just because it can't handle XML reliably.
--Ben -
hi, someone who can help me how to convert a blob oracle in base64.encode,
and viceverse.
please some idea
tanks
alexi saw a bit code about this convertions,
//one side
ResultSet r = ...........
BLOB b = (BLOB)r.getBlob('ICON');//BLOB is oracle type not Blob
byte[] base = b.getBytes();
Strgin res = Base64.encode(base);
//other side
String dec = datos;// data in base64
byte[] base = Base64.decode(dec.getBytes());
BLOB b = null;
b.setBytes(base);
is this code correct????
i tried to test but a have an error with
public static void BLOBToFile(BLOB datos,String path)
try
FileOutputStream fos=new FileOutputStream(path);
byte[] tempBin=new byte[8];
long cant=1;
while (cant <= datos.length())
tempBin=datos.getBytes(cant,Integer.MAX_VALUE);
cant = Integer.MAX_VALUE+1;
fos.write(tempBin);
fos.close();
catch(Exception e)
e.printStackTrace();
and the error is outOfMemory
how can i test my code??
alex -
File saveAsOpen and Base64 encoding...
In order to send the activeDocument to a web service, i need to save is as a file image, and send in an xml format.
Thus, i also need to encode it in Base64.
At this point everything is OK.
But between the saveAs of the file, its reopening, and its encoding, its corrupted.
I receive an error on the Mongrel server.
The Base64 encoder seems to work well, the rest of the code seem to be also ok, so I think my problem is either I do not save it correctly, either i do not reopen it correctly...
Please save me :(
Here is the code :
/* STEP 1 : save current document as image file (temporary) */
var docRef = activeDocument;
var filepath=app.path.toString()+"/"+docRef.name+".jpg";//create the image file in the installation folder of Photoshop
var file = new File(filepath);
//var options = new ExportOptionsSaveForWeb();
//options.format = SaveDocumentType.PNG;
var options = new JPEGSaveOptions();
options.quality=8;
docRef.saveAs (file, options, true, Extension.LOWERCASE);
//docRef.exportDocument (file, ExportType.SAVEFORWEB , options);
file.close();
/* I code here dialogBox and httpCOnenction object creation
that do not need to be written here
(but if you think it's important, i can give you the full script)
var f= new File(filepath);
f.open();
var buffer = f.read(f.length);
f.close();
I build an HttpConnection object called "send"
*/ send.request='"+f.name+""+f.length+""+base64encode(buffer)+"';
Here is the Server error :
Exception working with image: Not a JPEG file: starts with 0xc7 0xff `/var/folders/Nz/NzlixjchF+WAvFkZK9vVRU+++TM/-Tmp-/test599-0.jpg'Let's give you everything in fact, it will be more simple (by the way the code is suppose to become OpenSource)<br /><br />I work on Mac, Photoshop CS3 (10.0.1)<br />I use JavaScript<br />HTTP request received by a Mongrel server (Ruby on Rails)<br /><br />// Copyright 2008. Studio Melipone. All rights reserved. <br />// Licence GNU LGPL<br />// Send the active document to the UpShot web service (http://upshotit.com)<br />// The document is sent as a .png file, as a draft on the user's account.<br />// Therefore you must have a document opened and Adobe Bridge installed to perform this script.<br /><br />/*<br /> <javascriptresource><br /> <name>UpShot</name><br /> <type>automate</type><br /> <about><br /> Script for Upshot <br /> Copyright 2008 Studio Melipone <br /> http://upshotit.com <br /> </about><br /> <enableinfo>true</enableinfo><br /> </javascriptresource> <br />*/<br /><br />#target photoshop<br />#include "Base64.jsx"<br /><br />app.bringToFront();<br /><br />if( documents.length==0)// is a document opened ?<br /> alert("There are no Photoshop documents opened !")<br />else {<br /> /*********************************************/<br /> /* STEP 1 : save current document as image file (temporary) */<br /> /******************************************/<br /> var docRef = activeDocument;<br /> var filepath=app.path.toString()+"/"+docRef.name+".jpg";//create the image file in the installation folder of Photoshop<br /> var file = new File(filepath);<br /> //var options = new ExportOptionsSaveForWeb();<br /> //options.format = SaveDocumentType.PNG;<br /> var options = new JPEGSaveOptions();<br /> options.quality=8;<br /> docRef.saveAs (file, options, true, Extension.LOWERCASE);<br /> //docRef.exportDocument (file, ExportType.SAVEFORWEB , options);<br /> file.close();<br /> <br /> /********************************************************/<br /> <br /> // Only Bridge can use HttpConnection, so we test if it is installed<br /> var bridgeTarget = BridgeTalk.getSpecifier(getAppSpecifier("bridge")); <br /> <br /> if( !bridgeTarget ) { <br /> alert("Adobe Bridge not installed, needed to continue."); <br /> } <br /> else { <br /> preferences.rulerUnits = Units.PIXELS;<br /> displayDialogs = DialogModes.NO;<br /> <br /> /**********************************/<br /> /* STEP 2 : retrieve user's login & password */<br /> /*******************************/<br /> <br /> res = "dialog { text: 'UpShot authentication', \<br /> info: Panel { orientation: 'column', alignChildren:'right', \<br /> text: 'Please Identify Yourself', \<br /> login: Group { orientation: 'row', \<br /> s: StaticText { text:'Login :' }, \<br /> e: EditText { characters: 30 } \<br /> }, \<br /> passwd: Group { orientation: 'row', \<br /> s: StaticText { text:'Password :' }, \<br /> e: EditText { characters: 30, properties:{noecho: true} }, \<br /> } \<br /> }, \<br /> buttons: Group { orientation: 'row', \<br /> okBtn: Button { text:'OK', properties:{name:'ok'} }, \<br /> cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \<br /> } \<br /> }"; <br /> <br /> dlg = new Window (res); <br /> dlg.center(); <br /> dlg.show(); <br /><br /> var login = dlg.info.login.e.text;//retrieve the values given in the form<br /> var pass = dlg.info.passwd.e.text;<br /><br /> /******************************/<br /> /* STEP 3 : send image through Bridge */<br /> /***************************/<br /> var f= new File(filepath);<br /> f.open();<br /> var buffer = f.read(f.length);<br /> f.close();<br /> <br /> alert("file size "+file.length);<br /> alert("f size "+f.length);<br /> alert("BUF "+buffer);<br /> alert(base64encode("B64 "+base64encode(buffer)));<br /> <br /> // create a new BridgeTalk message object <br /> var bt = new BridgeTalk; <br /> // target the Adobe Bridge application <br /> bt.target = bridgeTarget; <br /> //p173 of Javascript Tools Guide for CS3 for http message<br /> bt.body = "\<br /> if(!ExternalObject.webaccesslib ) {\<br /> ExternalObject.webaccesslib = new ExternalObject('lib:webaccesslib');\<br /> }\<br /> var http = new HttpConnection('http://127.0.0.1:3000/en/users/get_id.xml') ; \<br /> var idfile = new File('"+app.path.toString()+"/id.xml') ;\<br /> http.response = idfile ; \<br /> http.username = '"+login+"';\<br /> http.password = '"+pass+"';\<br /> http.mime='text/xml';\<br /> http.responseencoding='utf8';\<br /> http.execute();\<br /> http.response.close();\<br /> http.close();\<br /> idfile.open();\<br /> var send = new HttpConnection('http://127.0.0.1:3000/en/users/'+idfile.read()+'/upshots') ; \<br /> send.method = 'POST';\<br /> send.username = '"+login+"';\<br /> send.password = '"+pass+"';\<br /> send.mime='text/xml';\<br /> send.requestheaders=['Host','http://localhost:3000'];\<br /> send.requestheaders=['Accept','*/*'];\<br /> send.requestheaders=['Content-Type','text/xml'];\<br /> send.request='<upshot><title>titleforyourimage</title><file_name>"+f.nam e+"</file_name><size>"+f.length+"</size><javafile>"+base64encode(buffer)+"</javafile></ups hot>';\<br /> send.execute();\<br /> idfile.toSource();\<br /> ";<br /> <br /> bt.onResult = function(result) { <br /> object = bt.result = eval(result.body);<br /> //file.remove();<br /> //object.remove();<br /> //bridge.quit ();<br /> return eval(result.body); <br /> } ;<br /> <br /> bt.onError = function( message ) { <br /> var errCode = parseInt (message.headers ["Error-Code"]); <br /> throw new Error (errCode, message.body); <br /> } ;<br /> <br /> //send the message ( also launch the targetted application)<br /> bt.send(10);<br /> <br /> /**********************************************/<br /> /* STEP 4: Once all done, delete the image previously created */<br /> /*******************************************/<br /> }<br />}<br /><br />//////////////////////////////////////////////////////////////////<br />/////////////////////////////////////////////////////////////////<br />/*functions from http://www.ps-scripts.com/bb/viewtopic.php?t=1282 */<br />//////////////////////////////////////////////////////////////<br />/////////////////////////////////////////////////////////////<br /><br />function getAppSpecifier(appName) {<br /><br /> if (isCS2()) {<br /> if (appName == 'photoshop') {<br /> return 'photoshop-9.0';<br /> }<br /> if (appName == 'bridge') {<br /> return 'bridge-1.0';<br /> }<br /> // add other apps here<br /> }<br /><br /> if (isCS3()) {<br /> if (appName == 'photoshop') {<br /> return 'photoshop-10.0';<br /> }<br /> if (appName == 'bridge') {<br /> return 'bridge-2.0';<br /> }<br /> // add other apps here<br /> }<br /><br /> return undefined;<br />};<br /><br />function isCS2() {<br /> var appName = BridgeTalk.appName;<br /> var version = BridgeTalk.appVersion;<br /><br /> if (appName == 'photoshop') {<br /> return version.match(/^9\./) != null;<br /> }<br /> if (appName == 'bridge') {<br /> return version.match(/^1\./) != null;<br /> }<br /><br /> return false;<br />};<br />function isCS3() {<br /> var appName = BridgeTalk.appName;<br /> var version = BridgeTalk.appVersion;<br /><br /> if (appName == 'photoshop') {<br /> return version.match(/^10\./) != null;<br /> }<br /> if (appName == 'bridge') {<br /> return version.match(/^2\./) != null;<br /> }<br /><br /> return false;<br />};
-
Hi there
I am writing an adobe air app in html/javascript and I am trying to base64 encode an image so I can add it to and XML RPC request. I have tried many methods and nothings seems to work.
I see that actionscript has a Base64Encoder class that look like it would work, is there any way to utilize this in javascript?
Thanks,
JordanReading it in as an ASCII string loses information - you're much better off reading it in byte-for-byte. Then you can send it as the serializeable of your choice (even a BigInteger would work).
-
How to convert a base64 encoded string to binary?
Hi, gurus,
I want to convert a base64 encoded string (a image which is read from a xml file)
into a normal binary string and then upload to archive link.
could you pls give me some hints on that?
br.
junthank you for your quick reply!
my real requirement is to extract an image(it 's said it's encoded using base64?) from a xml file and upload it sap archive linke,
following is the xml content, does that mean i need to convert all the chars in the
<mime_content> pair to your fm, that will be convert to binary string?
<MIME_CONTENT xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" href="" xfa:contentType="image/jpg"
>/9j/4AAQSkZJRgABAAEAYABgAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCE
AAgFBgcGBQgHBgcJCAgJDBQNDAsLDBgREg4UHRkeHhwZHBsgJC4nICIrIhscKDYoKy8xMzQzHyY4
PDgyPC4yMzEBCAkJDAoMFw0NFzEhHCExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTEx
MTExMTExMTExMTExMTExMf/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEBAQEB
AQEBAQAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0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kAk9gKAPLvCvhfRdL8OZ4tHfijULxd0s1wiPHFGnUA
YccADOTz1oA9V0K28Nv8Fb6fw/o11Fo99azzNZbumPBViCxPPy5HPYUAeNXsiXR4tLPje+bSl8
OvJDACIg0wZgttIoyCccE9xigDu/gLqcreKYtLtfEF3qmnx6BFKYJZSyW0xZA0ajtt6UAe50ARXl
vHeWk1tMCYp0aNwDg4Iwf50AeJfEn4LaXYGUbwjpoXN6LmMeULhnAjJO44PFAHe+GPhX4X8Na1
DqnQXRvYVZY3nuWkCbhg4B9ifzoA4PxRpHjKyIHie80TTtXW11NoNlzYGH51SLaVIftk/pQByD
AvFkeiXGk6doOvFLoRR7LqSARIFk3huDnOS3/fRoA9XOvhGbxH4OQ6XpQv9Yt5I1hZQPMRM/OA
T24oAj1bxb4rvtEvNPT4daqjXFs8Ic3URALKVz+tAGn4HtNW8I/CKyt59KlutUs7dj9hjZSzMzkh
c9OjDP40AeSv4H8Z2aGe68Nzardalok1vLhogLWaSVivB7qoXp69aAO0D3h3XrLxaNQ1Xw2jW9
vocOn5Z0PnSoVy+F9cE8/nQB7BQAUAFABQAUAFABQAUAFABQAUAFAH//2Q==</MIME_CONTENT
> -
Converting Base64 encoded String to String object
Hi,
Description:
I have a Base64 encoded string and I am using this API for it,
[ http://ws.apache.org/axis/java/apiDocs/org/apache/axis/encoding/Base64.html]
I am simply trying to convert it to a String object.
Problem:
When I try and write the String, ( which is xml ) as a XMLType to a oracle 9i database I am getting a "Cannot map Unicode to Oracle character." The root problem is because of the conversion of the base64 encoded string to a String object. I noticed that some weird square characters show up at the start of the string after i convert it. It seems like I am not properly converting to a String object. If i change the value of the variable on the fly and delete these little characters at the start, I don't get the uni code error. Just looking for a second thought on this.
Code: Converting Base64 Encoded String to String object
public String decodeToString( String base64String )
byte[] decodedByteArray = Base64.decode( base64String );
String decodedString = new String( decodedByteArray, "UTF-8");
}Any suggestions?To answer bigdaddy's question and clairfy a bit more:
Constraints:
1. Using a integrated 3rd party software that expects a Base64 encoded String and sends back a encoded base64 String.
2. Using JSF
3. Oracle 10g database and storing in a XMLType column.
Steps in process.
1. I submit my base64 encoded String to this 3rd party software.
2. The tool takes the encoded string and renders a output that works correctly. The XML can be modified dynamically using this tool.
3. I have a button that is binded to my jsf backing bean. When that button is clicked, the 3rd party tool sets a backing bean string value with the Base64 String representing the updated XML.
4. On the backend in my jsf backing bean, i attempt to decode it to string value to store in the oracle database as a XML type. Upon converting the byte[] array to a String, i get this conversion issue.
Possibly what is happen is that the tool is sending me a different encoding that is not UTF-8. I thought maybe there was a better way of doing the decoding that i wasn't looking at. I will proceed down that path and look at the possibility that the tool is sending back a different encoding then what it should. I was just looking for input on doing the byte[] decoding.
Thanks for the input though.
Edited by: haju on Apr 9, 2009 8:41 AM
Maybe you are looking for
-
I've been struggling to set up my package structure properly. Here's the situation: C:\project\impl2 :contains the files in "package impl2" C:\project\impl :contains classes that import impl2.* (let's call these the "child classes") (OS is Win2000) W
-
How do I move past the terms and agreement page of the update? I have clicked agree for every catagory about 8,000 times and it won't move me forward or give me any kind of error message.
-
Hi all, I have a mapping that has a dimension as the target table. This mapping works fine. Now I need to do a lookup on an attribute(in a different dimension table) and use this in my mapping as a source. I get this error when I try to validate the
-
K9A2 Platinum - Install to RAID - Memory issue
Hello all, I have a MSI K9A2 Platinum AM2+/AM2 AMD 790FX ATX AMD Motherboard with a AMD Phenom 9950 BLACK EDITION Agena 2.6GHz Socket AM2+ 140W Quad-Core Processor Model HD995ZFAGHBOX. I have (2) OCZ Platinum 4GB (2 x 2GB) 240-Pin DDR2 SDRAM DDR2 106
-
Have to restore every time I plug in to comp
Every time I either plug my nano into the computer to charge or add new songs, I get an error telling me to restore my ipod to factory settings and clean wipes it. I then reload my 16 gigs of music and do it again when I need to charge. Needless to s