axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kent Tong (JIRA)" <>
Subject [jira] Created: (AXIS2-755) base64Binary is not encoded
Date Sat, 20 May 2006 11:41:29 GMT
base64Binary is not encoded

         Key: AXIS2-755
     Project: Apache Axis 2.0 (Axis2)
        Type: Bug

  Components: databinding  
    Versions: 1.0    
    Reporter: Kent Tong

In my WSDL (as attached), I have a message element of type base64Binary like:

			<xsd:element name="uploadRequest">
						<xsd:element name="id" type="xsd:string" />
						<xsd:element name="file" type="xsd:base64Binary">

When the client sends a file to the service, what the service gets is the base64 encoded representation
of the bytes, not the bytes themselves:

	public void upload( req) throws IOException {
		InputStream in = req.getFile().getDataSource().getInputStream(); //this is the encoded string,
not bytes

In the generated, the factory's parse() method is like:

		if (reader.isStartElement() && new javax.xml.namespace.QName("", "file").equals(reader.getName()))
			java.lang.String content = getElementTextProperly(reader);

The convertTobase64Binary() should decode the string, but it doesn't:

    public static javax.activation.DataHandler convertTobase64Binary(String s) throws Exception{
        // reusing the byteArrayDataSource from the Axiom classes
        ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(s.getBytes());
        return new DataHandler(byteArrayDataSource);

All it does is to convert the string to bytes using the system's default encoding which is
unlikely to be base64 (it may be ISO-8859-1, UTF-8, Big5, ...).

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message