Results 1 to 1 of 1
- 09-11-2008, 10:22 AM #1
Member
- Join Date
- Sep 2008
- Posts
- 1
- Rep Power
- 0
Include Base64 encoded data into XML
Hello,
I have to base64 encode a large quantity of data and include it in the XML response of the webservice.The WSDL define the XML element in the following way:
<xs:complexType name="MessagePart">
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attribute name="contentType" type="xs:string" default="text/plain" use="optional"/>
<xs:attribute name="length" type="xs:int" default="0" use="optional"/>
<xs:attribute name="offset" type="xs:int" default="0" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
I have implemented it but I have some doubts. I'm not sure it's the better way for doing it.
import org.apache.commons.codec.binary.Base64;
...
OMElement part = factory.createOMElement("part", emptyNs);
part.addAttribute("length", this.attachment.getLength(), null);
byte[] value = Base64.encodeBase64(this.attachment.getValue());
part.setText( new String(value) );
What about performance if I have an attachment of 1MB? I'm specially worried about the "new String()" operation.
Any suggestion will be appreciated. Thanks,
Alessandro
Similar Threads
-
How to include lib in JAR file
By adam.muller in forum EclipseReplies: 4Last Post: 08-06-2008, 05:15 PM -
jsp:include in a sql:transaction
By sam2020 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 07-31-2008, 08:11 PM -
<jsp:include> Vs <%@include> Vs <jsp:forward> Vs RequestDispatcher .forward/includeVs
By freddieMaize in forum Java ServletReplies: 5Last Post: 07-29-2008, 02:13 PM -
Reaing a UTF-8 encoded file
By mew in forum New To JavaReplies: 0Last Post: 01-16-2008, 05:09 PM -
jsp:include and include file
By Heather in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-14-2007, 04:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks