Question

I'm consuming a webservice with a binary data object which is base 64 encoded. The corresponding xsd element looks like this:

<xs:element name="Document" maxOccurs="unbounded"
                xmime:expectedContentTypes="application/octet-stream">
    <xs:complexType>
        <xs:simpleContent>
            <xs:extension base="xs:base64Binary">
                <xs:attribute name="id" type="xs:anyURI" use="required">
                    <xs:annotation>
                        <xs:documentation>documentation text...</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:element>

After generating my classes using the maven-jaxws-tools-plugin with the jbossws-cxf-client (the native client leads to the same error) something seems to be missing. No matter how I try to enable MTOM, it just does not send any attachments but it keeps the binary data in the main xml. I tried to configure the SOAPBinding and I created the port with an MTOMFeature with and without threshold. Basically it always looks like this.

<ns4:Document id="Document01">dGhpcyBpcyBzYW1wbGUgZG9jdW1lbnQgbm8uIDE=</ns4:Document>

Is there an error in the xsd file, is the plugin the problem or is it just me forgetting something?

--

After generating the classes with another plugin (jaxws-maven-plugin) I got an interesting warning in the console. It tells me that the xmine:expectedContentType attribute is present in an invalid element. I'm quite sure that I saw several examples of this doing it exactly the same way so I have no idea whether this could lead to any problems or not.

This does not change anything, I found that the classes are just fine.

--

It seems to be a problem of this method call in one of our Handler implementations:

ctx.getMessage();

ctx is the SOAPMessageContext object that is put into the handleMessage method of the SOAPHandler implementation. As soon as this method is executed, there will be no attachments in the request. I'm curious how a getter can disable attachments for a whole request. Any ideas?

Was it helpful?

Solution

I finally managed to find the reason of this behaviour. There is a bug that will not get fixed which leads to it. The corresponding ticket can be found here: https://java.net/jira/browse/WSIT-1320

For a workaround you can go to this blog post, that's where I found some information on this topic: http://blog.toshredsyousay.com/post/43379955341/the-trouble-with-soaphandlers-and-mtom#fn:p43379955341-8

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top