How do I force CXF to use a DataHandler for base64binary types without modifying the WSDL?
Asked Answered
P

0

6

I'm working on changing our implementation of a SOAP service from using Axis2 to using JAX-WS (technically, the CXF implementation provided by JBossWS on AS 7) and I've run into an issue that's preventing me from switching the final remaining method to the JAX-WS style.

The (slightly anonymized since the spec seems to not be public) method returns a Type which contains a base64binary element.

<xs:complexType name="BitmapResult">
    <xs:sequence>
        <xs:element minOccurs="0" name="chunkBitmap" nillable="true" type="xs:base64Binary"/>
    </xs:sequence>
</xs:complexType>

In Axis2 this generates a class that uses a DataHandler to handle the binary parameter and appears to use MTOM by default for returning the result.

Using the CXF wsdl2java tool this generates a type class that uses a byte[] and will return the parameter as base64 encoded text within the SOAP reply itself.

From everything that I have read, the correct way to do this with CXF is to make sure the wsdl that you are generating from contains: xmime:expectedContentTypes="application/octet-stream" but since we are being provided with the WSDL by an outside source, I would prefer not to modify it locally.

Is there another way to request that CXF generate the class using a DataHandler other than modifying the WSDL? I am already using a jaxb binding file to tweak some other parameters of the generation, but I wasn't able to find anything that would enable me to override this particular setting.

Pairs answered 22/10, 2012 at 21:51 Comment(3)
I don't know about your exact use case, but I don't think this will be able, but if you need to rely on DataHandler you could convert the byte[] to a DataHandler?Butcher
Oh, sorry if I wasn't clear. I could change our code to just place the byte[] into the return type directly right now, but if we want to use MTOM we need to be using the DataHandler construct (as well as setting some annotations) and that doesn't seem to be possible without the wsdl change.Pairs
@NicholasGeorge In know this is old, but were you able to solve this? I've run into exactly the same problemGentes

© 2022 - 2024 — McMap. All rights reserved.