base64Binary is not encoded
---------------------------
Key: AXIS2-755
URL: http://issues.apache.org/jira/browse/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:complexType>
<xsd:sequence>
<xsd:element name="id"
type="xsd:string" />
<xsd:element name="file"
type="xsd:base64Binary">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
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(com.foo.schema.UploadRequest req) throws IOException
{
InputStream in =
req.getFile().getDataSource().getInputStream(); //this is the encoded string,
not bytes
...
}
In the generated UploadRequest.java, 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);
object.setFile(org.apache.axis2.databinding.utils.ConverterUtil.convertTobase64Binary(content));
...
}
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:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]