Skip to content

AXIS2 ADB base64binary problem

I look today into problem “Unexpected element”. Developer use a code generation utility wsdl2java for AXIS2. Everything working fine except attachments. Service call fail with exception “Unexpected element attachment”.  I found that element attachment is successfully start to processing, but fail to finished. The problem in the code:

	if (reader.isStartElement() && new javax.xml.namespace.QName("", "attachment").equals(reader.getName()))
		if (isReaderMTOMAware(reader) && java.lang.Boolean.TRUE.equals(reader.getProperty(
			//MTOM aware reader - get the datahandler directly and put it in the object
			object.setAttachment((javax.activation.DataHandler) reader.getProperty(;
			if ((reader.getEventType() == && reader.getName()
				.equals( new javax.xml.namespace.QName(,
				final java.lang.String id =, "UTF-8");
				object.setAttachment(((org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder) (( reader).getBuilder()).getDataHandler(id));;;

			else if (reader.hasText())
                               String content = reader.getText();
	} // End of if for expected property start element

We don’t use MTOM, so problem was in section

else if (reader.hasText()){

Looking into reader data I found that content of element “attachment” contains multiple text nodes, but expected only one node. It seams that parser reads base64binary not in one piece, but multiple chunks.
So instead I use next code:

  else if (reader.hasText()) {
            String content = "";

Now all working as expected.

Posted in development.

Tagged with , , .

2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Gennadiy Bukhmatov says

    I use 1.4.1 also. Please, check if you apply fix in right place of code. You could use debugger to check is fix working.

Continuing the Discussion

  1. Encodertool – Encode string to base64,binary… | Startup Websites linked to this post on November 18, 2010

    […] AXIS2 ADB base64binary problem – Java Developer notes […]

You must be logged in to post a comment.