1. Synapse
  2. SYNAPSE-867

SwA responses are processed incorrectly


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: FUTURE
    • Component/s: Core
    • Labels:


      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))

      { newMC.addAttachment(cID, attachments.getDataHandler(cID)); }


      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(
      at org.apache.axiom.attachments.PartImpl.writeTo(
      at org.apache.axiom.attachments.PartDataHandler.writeTo(
      at org.apache.axiom.mime.impl.axiom.MultipartWriterImpl.writePart(
      at org.apache.axis2.transport.http.SOAPMessageFormatter.writeSwAMessage(
      at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(
      at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.sendAsyncResponse(
      at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.invoke(
      at org.apache.axis2.engine.AxisEngine.send(
      at org.apache.synapse.core.axis2.Axis2Sender.sendBack(
      at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(
      at org.apache.synapse.mediators.builtin.SendMediator.mediate(
      at org.apache.synapse.mediators.AbstractListMediator.mediate(
      at org.apache.synapse.mediators.filters.OutMediator.mediate(
      at org.apache.synapse.mediators.AbstractListMediator.mediate(
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(
      at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(
      at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(
      at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(
      at org.apache.axis2.engine.AxisEngine.receive(
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
      at java.util.concurrent.ThreadPoolExecutor$

      1. capture.txt
        19 kB
        Andreas Veithen

        Issue Links


          Andreas Veithen created issue -
          Andreas Veithen made changes -
          Field Original Value New Value
          Attachment capture.txt [ 12525014 ]
          Andreas Veithen made changes -
          Link This issue relates to AXIS2-5308 [ AXIS2-5308 ]
          Andreas Veithen added a comment -

          One possible (clean) solution for this type of issue is outlined in AXIS2-5308.

          Andreas Veithen added a comment - One possible (clean) solution for this type of issue is outlined in AXIS2-5308 .
          Andreas Veithen added a comment -

          Fixed for 2.2 (BTW, why is there no 2.2 or 3.0 in the version list???)

          Andreas Veithen added a comment - Fixed for 2.2 (BTW, why is there no 2.2 or 3.0 in the version list???)
          Andreas Veithen made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s FUTURE [ 12313086 ]
          Resolution Fixed [ 1 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          2d 2h 8m 1 Andreas Veithen 01/May/12 13:10


            • Assignee:
              Andreas Veithen
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: