eclipse-ee4j / metro-jax-ws

metro-jax-ws
https://eclipse-ee4j.github.io/metro-jax-ws/
BSD 3-Clause "New" or "Revised" License
71 stars 40 forks source link

In SOAPMessage mime header Content-Transfer-Encoding mime header is stipped off #461

Open Tomas-Kraus opened 2 years ago

Tomas-Kraus commented 2 years ago

Hi All,

All of my SOAP request attachments has "Content-Transfer-Encoding" mime header. In our web service, we have SOAP Message Handler. When I dump the SOAPMessage contents, "Content-Transfer-Encoding" is missing. Below is the code snippet to dump the SOAPMessage.

public boolean handleMessage(SOAPMessageContext context) { SOAPMessage soapMessage = context.getMessage(); soapMessage.writeTo(System.out); We even tried printing all the MIME headers in the attachment, but "Content- Transfer-Encoding" is not present. I thought it was issue on the SAJJ side and opened [https://saaj.dev.java.net/issues/show_bug.cgi?id=52](https://saaj.dev.java.net/issues/show_bug.cgi?id=52) defect. After running snippet provided by Kumar, I found SAJJ is able to parse this header.Hence as suggested by Kumar, I am opening issue. Can you please help us here? PFA: Request dump to webservice: STIRequest.dump soapMessage dump: soapMessage.writeTo.dump Platform details: JAX-WS version: JAX-WS RI 2.2 Container: apache-tomcat-5.5.28 OS: Linux msg-lnx7 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux #### Environment Operating System: All Platform: All #### Affected Versions [2.2] Source: [https://github.com/javaee/metro-jax-ws/issues/855](https://github.com/javaee/metro-jax-ws/issues/855) Author: glassfishrobot
dub357 commented 2 months ago

No movement on this major bug in over 2 years? This issue affects all request headers, not just the "Content-Transfer-Encoding" one. When a Message is converted to a SAAJ SOAPMessage, all the original MIME header information is missing.

I'm pretty sure this is happening because the SAAJMessage constructor never calls the private "parse" method: https://github.com/eclipse-ee4j/metro-jax-ws/blob/22629d34bdcb6f414bcc9abe8ee025368a795dde/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/message/saaj/SAAJMessage.java#L79

This means that the next time the SAAJMessage.readAsSoapMessage method is called, it creates a new SOAPMessage object instead of returning the one that was passed to its constructor (because the internal 'parsedMessage' boolean isn't true): https://github.com/eclipse-ee4j/metro-jax-ws/blob/22629d34bdcb6f414bcc9abe8ee025368a795dde/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/message/saaj/SAAJMessage.java#L252

Its that new SOAPMessage object is passed the header information: https://github.com/eclipse-ee4j/metro-jax-ws/blob/22629d34bdcb6f414bcc9abe8ee025368a795dde/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/message/AbstractMessageImpl.java#L204

And that new SOAPMessage object is never used again :( This means that any registered javax.xml.ws.handler.soap.SOAPHandler in the chain never see the correct MimeHeaders