title: Content-Type Missing "start=" Tag in Java SOAP Client, Attachment not Found by Server
body: <p>I am creating a Java client for a SOAP service that takes an attachment.  I'm using java.xml.soap classes, which I have uses before, but not with attachments.  The server claims that my attachment is not included.  </p>
  
  <p>I used SoapUI, which works, and wireshark to compare my SOAP message to a working SOAP message.  One big difference is that my header does not include "start=". </p>
  
  <p>The working Content-Type looks like this:</p>
  
  <p>Content-Type: multipart/related; type="text/xml"; start=""; boundary="----=_Part_23_6341950.1286312374228"</p>
  
  <p>The Content-Type I get from my Java code is like this:</p>
  
  <p>Content-Type: multipart/related; type="text/xml"; boundary="----=_Part_23_6341950.1286312374228"</p>
  
  <p>No start= even when the content ID is set on the root element.  The working and failing SOAP messages are otherwise nearly identical.  How can I get the start tag generated, or what are other reasons the server might not see the attachment?</p>
  
  <p>Thanks</p>
  
  <pre><code>        SOAPMessage soapMessage = 
                         MessageFactory.newInstance().createMessage();            
          SOAPPart soapPart = soapMessage.getSOAPPart();
          SOAPEnvelope soapEnvelope = soapPart.getEnvelope();         
          SOAPBody body = soapEnvelope.getBody(); 
          SOAPHeader header = soapMessage.getSOAPHeader();
  
          soapPart.setContentId("&lt;rootpart@here.com&gt;");
  
          MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
          mimeHeaders.addHeader("SOAPAction", "addDocument");
          mimeHeaders.addHeader("Accept-Encoding", "gzip,deflate");
  
          Name bodyName = soapEnvelope.createName("Document", "doc", 
              "http://ns/Document");
          SOAPBodyElement document = body.addBodyElement(bodyName);
  
          Name filenameName = soapEnvelope.createName("Filename", "doc", 
              "http://ns/Document");
  
          SOAPElement filename = document.addChildElement(filenameName);
          filename.setValue("filename.txt");
  
          AttachmentPart attachment = soapMessage.createAttachmentPart(); 
          attachment.setContent("Some text", "application/octet-stream");
          attachment.setMimeHeader("Content-Transfer-Encoding", "binary");
  
          soapMessage.addAttachmentPart(attachment); 
  
          SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
          SOAPConnection soapConnection = scf.createConnection();
          URL url = new URL("http://host/Service");
  
          SOAPMessage reply = soapConnection.call(soapMessage, url);
  </code></pre>