You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Manuel Mayer (JIRA)" <ji...@apache.org> on 2008/11/21 17:25:44 UTC

[jira] Commented: (CXF-1900) Invalid ContentId Encode

    [ https://issues.apache.org/jira/browse/CXF-1900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12649696#action_12649696 ] 

Manuel Mayer commented on CXF-1900:
-----------------------------------

I have a similar issue: if I invoke a simple MTOM-enabled Axis2 (v1.4.1) service from a CXF (v2.1.3) client, the Axis2 service fails with the following exception:

[ERROR] Referenced Attachment not found in the MIME Message. ContentID:5005a0c0-9e55-4b79-baf5-9320b1abb43b@http://cxf.apache.org/
Caused by: org.apache.axiom.om.OMException: Referenced Attachment not found in the MIME Message. ContentID:5005a0c0-9e55-4b79-baf5-9320b1abb43b@http://cxf.apache.org/

Looking at the message from the CXF client I realized that both, the cid-Url and the Content-Id message header, were URL-encoded (although RFC 2111 states the cid URL should be, the Content-Id message header not).

I fixed the problem by URL-decoding the Id of the Attachment in org.apache.cxf.attachment.AttachmentSerializer:

private void writeHeaders(String contentType, String attachmentId, Writer writer) throws IOException {
	writer.write("\r\n");
	writer.write("Content-Type: ");
	writer.write(contentType);
	writer.write("\r\n");

	writer.write("Content-Transfer-Encoding: binary\r\n");

	writer.write("Content-ID: <");
	writer.write(URLDecoder.decode(attachmentId, "UTF-8"));
	writer.write(">\r\n\r\n");
}

> Invalid ContentId Encode
> ------------------------
>
>                 Key: CXF-1900
>                 URL: https://issues.apache.org/jira/browse/CXF-1900
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.3
>         Environment: Linux - Ubuntu 8.04
>            Reporter: Andrea Bozzetto
>
> The namespace  "urn:ihe:iti:xds-b:2007" is encoded in this way:
> Content-ID: <ae6becb4-dee4-441f-8b21-9cdffe3b2986@urn%3Aihe%3Aiti%3Axds-b%3A2007>
> I change the class AttachmentUtil like this:
> /**
>      * @param ns
>      * @return
>      */
>     public static String createContentID(String ns) throws UnsupportedEncodingException {
>         // tend to change
>         String cid = URLEncoder.encode("http://cxf.apache.org/", "UTF-8");
>         String name = UUID.randomUUID().toString();
>         if (ns != null && (ns.length() > 0)) {
>             try {
>                 URI uri = new URI(ns);
>                 String host = uri.toURL().getHost();
>                 cid = URLEncoder.encode(host, "UTF-8");
>             } catch (URISyntaxException e) {
>                 e.printStackTrace();
>                 return null;
>             } catch (MalformedURLException e) {
>                 cid = ns;
>             }
>         }
>         return URLEncoder.encode(name, "UTF-8") + "@" + cid;
>     }
> bye

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.