Index: modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java =================================================================== --- modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java (revision 8769) +++ modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java (working copy) @@ -23,6 +23,8 @@ import java.io.IOException; import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; @@ -40,6 +42,7 @@ import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; +import org.jboss.logging.Logger; import org.jboss.ws.Constants; import org.jboss.ws.WSException; import org.jboss.ws.core.CommonMessageContext; @@ -72,6 +75,7 @@ private SOAPPartImpl soapPart; private MultipartRelatedEncoder multipartRelatedEncoder; private static final boolean writeXMLDeclaration = Boolean.getBoolean(WRITE_XML_DECLARATION); + private static Logger log = Logger.getLogger(SOAPMessageImpl.class); // Cache the associated operation meta data private OperationMetaData opMetaData; @@ -128,10 +132,29 @@ public AttachmentPart getAttachmentByContentId(String cid) throws SOAPException { + String cidDecoded = cid; + try + { + cidDecoded = URLDecoder.decode(cid, "UTF-8"); + } + catch (UnsupportedEncodingException ex) + { + log.error("Cannot decode name for cid: " + ex); + } + for (AttachmentPart part : attachments) { String contentId = part.getContentId(); - if (contentId.equals(cid)) + String contentIdDecoded = contentId; + try + { + contentIdDecoded = URLDecoder.decode(contentId, "UTF-8"); + } + catch (UnsupportedEncodingException ex) + { + log.error("Cannot decode name for contentId: " + ex); + } + if (contentIdDecoded.equals(cidDecoded)) return part; } return null; @@ -139,15 +162,19 @@ public AttachmentPart removeAttachmentByContentId(String cid) { - for (AttachmentPart part : attachments) + try { - String contentId = part.getContentId(); - if (contentId.equals(cid)) - { + AttachmentPart part = getAttachmentByContentId(cid); + if (part != null) { attachments.remove(part); return part; } } + catch (SOAPException ex) + { + // this used to not throw SOAPException + log.error("Ignore SOAPException: " + ex); + } return null; }