title: Soap with attachments SAAJ
body: <p>I have a problem related to parsing a SOAP message.<br>
  This is the message:</p>
  
  <pre><code>------=_Part_3_5438437.1107262647279
  
  Content-Type: text/xml
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap-env:Body&gt;
      &lt;content&gt;
       [...]
       &lt;/content&gt;
    &lt;/soap-env:Body&gt;
  &lt;/soap-env:Envelope&gt;
  
  ------=_Part_3_5438437.1107262647279
  Content-Type: text/plain; charset=ISO-8859-1
  
  text
  ------=_Part_3_5438437.1107262647279--
  </code></pre>
  
  <p>This is an extract of my Java servlet, which should receive and parse the message:</p>
  
  <pre><code>messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
  message = messageFactory.createMessage(mimeHeaders, req.getInputStream());
  </code></pre>
  
  <p>To test the servlet, I'm using JMeter. I put the SOAP message in the raw post body of an HTTP Request.
  In the header I put this:
      Content-type  multipart/related;boundary=----=_Part_3_5438437.1107262647279</p>
  
  <p>Problem number 1: it seems that the parsing in SAAJ is bugged, because debugging I see that boundary is seen as ----null, as if = can be used as a token and nothing more. So I removed it, both from the body and from the header. This is a huge problem, because I can't change the input I receive, but let's pretend I can for a while.
  Ok, this moves me forward to problem number 2: now the boundary is parsed correctly, but I obtain this exception: <strong>com.sun.xml.messaging.saaj.SOAPExceptionImpl: Bad Content-Type for SOAP Part : text/plain</strong></p>
  
  <p>Ok, I believe I know how to solve it, I have to add the type in Content-type header: 
      Content-type  multipart/related;type=text/xml;boundary=----_Part_3_5438437.1107262647279</p>
  
  <p>Yes, but of course I have another nasty exception: <strong>com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
      at com.sun.xml.messaging.saaj.soap.MessageImpl.parseContentType(MessageImpl.java:337)</strong></p>
  
  <p>I'm using saaj-impl-1.3.18 and saaj-api-1.3.3.<br>
  java version "1.6.0_29"<br>
  Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)<br>
  Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)</p>