A basic introduction to the section and the features of MTOM.˚
Leveraging the Spring Initializr project, a project is created.
The project created is clean up per the ACD standard as follows:
- Delete the mvnwrapper support.
- Rename the
HELP.md
toREADME.md
- Clean up the
.gitignore
, i.e., removeHELP.md
,.mvnw
and other exclude inversions that look at thesrc/main
class paths wheretarget
andbuild
may occur in package names.
These Spring Initializr changes can be found in the commit history.
Update the POM with proper GAV coordinates and add the CXF dependency.
Of note, is server.context-path
is deprecated in favor of server.servlet.context-path
. The cxf.path
setting of /
strips services
from the default URL path created by CXF in Spring Boot.
Create a new Java interface and define the following two (2) methods for implementation:
void upload(DataHandler)
and DataHandler download()
This interface is marked with an @Webservice
annotation and the upload
method parameter MAY be marked with the
@WebParam
annotation for documentation purposes.
The implementation of the webservice from Lesson 131 is straightforward stream handling of bytes.
Write the file to the JVM temp directory, or elsewhere as needed in the design.
Added some JavaDocs.
Directly implemented with a DataHandler and FileDataSource.
Create the endpoint with a configuration class.
The endpoint using the FileWsImpl requires that MTOM be enabled. Get a SOAPBinding from the endpoint and enable the MTOM feature. Apache CXF documentation provide details.
Refactor the InputStream and OutputStream so that the implementation can properly handle the resources. Close the
streams in a finally
block on the upload implementation of the service.