Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTOM/XOP - byte array field not populated when using hexBinary #224

Open
steinrr opened this issue Sep 10, 2022 · 0 comments
Open

MTOM/XOP - byte array field not populated when using hexBinary #224

steinrr opened this issue Sep 10, 2022 · 0 comments

Comments

@steinrr
Copy link

steinrr commented Sep 10, 2022

We are creating the server side for a SOAP based service that uses MTOM/XOP to receive binary files (zip files).

The xsd for the service has the following element definition for the binary file:

<xs:element name="thebinaryfile" type="xs:hexBinary" xmime:contentType="application/octet-stream"/>
We have been using the same approach as demo'ed here (but without all the repository classes etc):

https://github.com/spring-projects/spring-ws-samples/tree/main/mtom/server

The issue is that when the type "hexBinary" is used, the get'er on the generated request object always returns null. If we change the type to "base64Binary", we get the proper value populated in the byte array.

We send identical requests from SoapUI and see that they reaches the server as expected. But something happens on the receiving side when the libraries are trying to populate the request objects when using "hexBinary" - since the byte field is not populated properly. The fields in the main part of the SOAP request are populated just fine.

If we change the definition in XSD to base64Binary, it can receive the bytes just fine - but would this be safe when the client uses hexBinary? I've used SoapUI with "encodeAttachments" - which are supposed to handle this - and seems to work fine.

This is how the field is generated when using hexBinary:

    @XmlElement(name = "zip-file", required = true, type = String.class)
    @XmlJavaTypeAdapter(HexBinaryAdapter.class)
    @XmlSchemaType(name = "hexBinary")
    protected byte[] zipFile; 

This is how the field is generated when using base64Binary:

    @XmlElement(name = "trr-file", required = true)
    protected byte[] trrFile;

Using the following configuration:

                            <plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>jaxb2-maven-plugin</artifactId>
				<version>2.5.0</version>
				<executions>
					<execution>
						<id>xjc</id>
						<goals>
							<goal>xjc</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<sourceType>WSDL</sourceType>
					<sources>${project.basedir}/src/main/resources/file-interface.wsdl</sources>
					<packageName>my.package.schema</packageName>
					<target>2.1</target>
				</configuration>
			</plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant