diff -uNr jbossws-3.0.1-native-2.0.4.GA-src.orig/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java jbossws-3.0.1-native-2.0.4.GA-src/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java --- jbossws-3.0.1-native-2.0.4.GA-src.orig/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2008-03-31 20:47:42.000000000 -0700 +++ jbossws-3.0.1-native-2.0.4.GA-src/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2009-03-24 15:41:18.000000000 -0700 @@ -25,6 +25,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; @@ -42,6 +44,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; @@ -73,6 +76,7 @@ private boolean isSWARefMessage; private SOAPPartImpl soapPart; private MultipartRelatedEncoder multipartRelatedEncoder; + private static Logger log = Logger.getLogger(SOAPMessageImpl.class); // Cache the associated operation meta data private OperationMetaData opMetaData; @@ -129,10 +133,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; @@ -140,15 +163,20 @@ 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; }