Folks
getDataHandler method of org.apache.axiom.attachments.Attachments returns NULL when it can't find the content part it is looking based on the content id. Shouldn't it return something else? I mean, if you return null its very obvious that you get null pointer exception from this call is originiated, in my case, org.apache.axiom.attachments.Attachments.getSOAPPartContentType. I am not really sure why would you want to return null. Instead, You can handle the null case and throw an exception stating, required content based on content id not found in message etc. I have copied my response MIME encoded message and please let me know if its missing any MIME parts. My response schema has NO element of type base64Binary, howerver, the response is MIME encoded. Checks whether the MIME part is already parsed by checking the attachments HashMap. If it is not parsed yet then call the getNextPart() till the required part is found. Parameters: blobContentID (without the surrounding angle brackets and "cid:" prefix) Returns: The DataHandler of the mime part referred by the Content-Id or *null* if the mime part referred by the content-id does not exist Checks whether the MIME part is already parsed by checking the attachments HashMap. If it is not parsed yet then call the getNextPart() till the required part is found. Parameters: blobContentID (without the surrounding angle brackets and "cid:" prefix) Returns: *The DataHandler of the mime part referred by the Content-Id or *null* if the mime part referred by the content-id does not exist* 342 public DataHandler getDataHandler(String blobContentID) { 343 DataHandler dataHandler; 344 if (attachmentsMap.containsKey(blobContentID)) { 345 dataHandler = (DataHandler) attachmentsMap.get(blobContentID); 346 return dataHandler; 347 } else if (!noStreams) { 348 //This loop will be terminated by the Exceptions thrown if the Mime 349 // part searching was not found 350 while ((dataHandler = this.getNextPartDataHandler()) != null) { 351 if (attachmentsMap.containsKey(blobContentID)) { 352 dataHandler = (DataHandler) attachmentsMap.get(blobContentID); 353 return dataHandler; 354 } 355 } 356 } 357 return null; 358 } MIME encoded response from the server side. HTTP/1.1 200 OK Connection: close Date: Thu, 12 May 2011 14:42:15 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private, max-age=0 Content-Type: multipart/related; type="application/xop+xml"; boundary=--MIMEBoundary634407937359568655; start="< 0.634407937359568...@example.org>"; start-info="text/xml; charset=utf-8" Content-Length: 890 ----MIMEBoundary634407937359568655 content-id: <0.634407937359568...@example.org> content-type: application/xop+xml; charset=utf-8; type="text/xml; charset=utf-8" content-transfer-encoding: binary <soap:Envelope xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><soap:Body><TravelDocumentNotificationRSVersion="1.000" xmlns=" http://www.amtrak.com/schema/2010/01/01"><Success/></TravelDocumentNotificationRS></soap:Body></soap:Envelope> ----MIMEBoundary634407937359568655--