Description
When Synapse forwards a SwA response, the SOAP part is duplicated in the forwarded response. This can be verified with Sample 51. The attached capture (produced with the last successful Synapse build from the trunk) shows that the response sent by Synapse to the client contains two SOAP parts. Note that a capture of the traffic between Synapse and the server shows that the response received by Synapse is correct. Sample 51 also allows to check that the issue only occurs with SwA responses, but not with SwA requests.
The probable root cause is that the message builder for SwA sets up the message context with an Attachments object that contains all MIME parts including the root part, while the message formatter for SwA expects that the Attachments object in the message context only contains the attachment parts. For SwA requests, this issue is handled by the following code in MessageHelper#clonePartially:
Attachments attachments = ori.getAttachmentMap();
if (attachments != null && attachments.getAllContentIDs().length > 0) {
String[] cIDs = attachments.getAllContentIDs();
String soapPart = attachments.getSOAPPartContentID();
for (String cID : cIDs) {
if (!cID.equals(soapPart))
}
}
Apparently that code is not executed for SwA responses, probably because a response doesn't need to be cloned.
In conjunction with the change in AXIS2-5302, the issue now causes the following failure because the original SOAP part has been consumed:
java.lang.IllegalStateException: The content of the MIME part has already been consumed
at org.apache.axiom.attachments.PartImpl.getContent(PartImpl.java:154)
at org.apache.axiom.attachments.PartImpl.writeTo(PartImpl.java:238)
at org.apache.axiom.attachments.PartDataHandler.writeTo(PartDataHandler.java:65)
at org.apache.axiom.mime.impl.axiom.MultipartWriterImpl.writePart(MultipartWriterImpl.java:133)
at org.apache.axiom.om.impl.OMMultipartWriter.writePart(OMMultipartWriter.java:159)
at org.apache.axiom.om.impl.OMMultipartWriter.writePart(OMMultipartWriter.java:175)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeSwAMessage(SOAPMessageFormatter.java:237)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:68)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.sendAsyncResponse(HttpCoreNIOSender.java:537)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.invoke(HttpCoreNIOSender.java:310)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:159)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:265)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:84)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
at org.apache.synapse.mediators.filters.OutMediator.mediate(OutMediator.java:55)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:188)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:370)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:160)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:276)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:173)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Attachments
Attachments
Issue Links
- relates to
-
AXIS2-5308 Attachments semantics are different for incoming and outgoing messages
- Open