Search code examples
jax-wscontent-typemimemtomxop

Rewriting "Content-Type" header and MIME boundaries with JAX-WS and MTOM/XOP


I have a specification I need to comply with, which makes some rather unusual demands (for historical reasons) when providing and using a Web Service using MTOM/XOP:

To summarize, the Content-Type HTTP Header has to be coded like this: The start-info and action have to be coded as separate parameters of Content-Type: start-info="application/soap+xml";action="urn:ihe:iti:2007:RetrieveDocumentSet"

  • while in contrast to that, the MTOM/XOP specification demand this:

Content-Type: multipart/related;start="...";type="application/xop+xml";boundary="...";start-info="application/soap+xml;action=\"urn:ihe:iti:2007:RetrieveDocumentSet\""

  • so the "action" is included and escaped within the "start-info" parameter. We are using JAX-WS to provide and consume the web service, and I cannot see a working solution to changing the headers and MIME boundaries to meet the specification's demands.

The same applies to the MIME boundaries sent with the web service message.

Java7 and Java8's included JAX-WS implementation seem to handle this differently, i.e.: Java7 does the encoding as expected by the specification I need to comply with, while Java8 does it according to the MTOM/XOP specification. I cannot go back to Java8 because other libraries I am using need Java8

Is there a way of modifying JAX-WS's behaviour, or of intercepting and changing the headers / MIME boundaries before reaching the other system?


Solution

  • Meanwhile, we found an answer: It is possible to use a custom TubeFactory in the application. This can then return a standard HttpTransportPipe with a modified Codec implementation, which modifies the Content-Type header in the getStaticContentType(Packet) method.