title: Is it possible to use custom truststore with SOAPConnection?
body: <p>(This is with Java 7.)</p>
  
  <p>We are considering using <code>javax.xml.soap.SOAPConnection</code> and its associated stuff to do some relatively quick and dirty sending and receiving of SOAP messages.</p>
  
  <p>However, the server this will be connecting uses certificates whose trust anchors are <strong>not</strong> in the default Java 7 truststore.  We do not want to modify the default truststore but instead want to use a custom truststore.</p>
  
  <p>If we were working at a lower level we could do stuff like getting an <code>SSLContext</code>, reinitializing it with the custom truststore, getting an <code>SSLSocketFactory</code> from it and so on.</p>
  
  <p>But from what I can see in the <code>SOAPConnection</code> API and the APIs of associated classes there is no obvious way to change the <code>SSLContext</code> instance that <code>SOAPConnection</code> implementations use.  I could change the default context but that changes things JVM-wide which is not what we want to have happen.</p>
  
  <p>Are we just out of luck if we want to use <code>SOAPConnection</code> then?  Any other libraries that will let you create SOAP requests relatively simply but let you specify the <code>SSLContext</code> or <code>SSLSocketFactory</code> to use?</p>