Freeman Yue Fang created CXF-9258:
-------------------------------------

             Summary: WS-RM retransmission of messages with attachments 
(SwA/MTOM) sends an invalid multipart request
                 Key: CXF-9258
                 URL: https://issues.apache.org/jira/browse/CXF-9258
             Project: CXF
          Issue Type: Bug
          Components: WS-* Components
    Affects Versions: 3.6.13, 4.2.4, 4.1.9
            Reporter: Freeman Yue Fang


When a WS-RM application message with attachments (SwA or MTOM) is 
retransmitted from the in-memory retransmission queue, the retransmitted 
request is invalid. The server fails with:
{noformat}
org.apache.cxf.interceptor.Fault: Couldn't find MIME boundary: --uuid:...
    at 
org.apache.cxf.interceptor.AttachmentInInterceptor.handleMessage(AttachmentInInterceptor.java:60)
{noformat}
so the message is never delivered, although it is retransmitted until the 
retransmission limit.

h3. Cause
{{RetransmissionQueueImpl.doResend()}} reuses the original message and runs its 
interceptor chain again, starting after {{RMCaptureOutInterceptor}}. Two 
message properties left over from the first transmission break the attachment 
handling:
# {{AttachmentOutInterceptor}} sets {{ATTACHMENT_OUT_CHECKED}} on the message 
to avoid being invoked twice (added by CXF-7952 in 3.3.6/3.4.0). On the 
retransmission, the flag is still set, so the interceptor does nothing: the 
request is sent with the multipart Content-Type of the first transmission, but 
its body is the bare SOAP envelope, without the MIME parts and the attachments.
# {{AttachmentSerializer.writeProlog()}} replaces {{Message.CONTENT_TYPE}} 
(e.g. {{text/xml}}) with the multipart Content-Type, and uses 
{{Message.CONTENT_TYPE}} as the type of the root part. On the retransmission, 
it uses the multipart Content-Type of the first transmission instead, so the 
{{type}}/{{start-info}} parameters and the Content-Type of the root part 
contain the previous multipart Content-Type, including its boundary, e.g.:
{noformat}
multipart/related; type="multipart/related"; boundary="uuid:c331e22c-..."; 
start="<[email protected]>"; start-info="multipart/related; 
type=\"text/xml\"; boundary=\"uuid:6a734010-...\"; 
start=\"<[email protected]>\"; start-info=\"text/xml\""
{noformat}

h3. How to reproduce
Send a one-way message with a SwA attachment (or with MTOM enabled) through a 
WS-RM client, and lose the first transmission (e.g. with the 
{{MessageLossSimulator}} of the ws-rm systests), so that the server only 
receives the retransmission.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to