title: System property "javax.xml.soap.MessageFactory" for two different soap versions
body: <p>i need to  communicate with two webservices from my application.
  For one webservice i need to use soap1_1 version and for the other soap version is soap1_2. In this case what should be the value set for the system property "javax.xml.soap.MessageFactory"</p>
  
  <p>Client 1:</p>
  
  <pre><code>public class SoapClient1 {
  
  
  protected static Logger _logger = Logger.getLogger ("TEST");
  private static Long retryDelay = null;
  
  
  public String sendSoapMessage (String xml) throws Exception {
  
      SOAPMessage resp  = null;
      String response = null;
      String endpoint = "http:xxxx";
  
  
  
      System.setProperty("javax.xml.soap.MessageFactory","com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl");
      SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
      SOAPConnection soapConnection = connectionFactory.createConnection();
  
      long start = System.currentTimeMillis();
      long end = System.currentTimeMillis();
  
      //URL endPoint = new URL(endpoint);
  
      //setting connection time out and read timeout
  
      URL endPoint = new URL (null, endpoint, new URLStreamHandler () {
          @Override
          protected URLConnection openConnection (URL url) throws IOException {
  
              URL clone = new URL (url.toString ());
              URLConnection connection = clone.openConnection ();
              connection.setConnectTimeout (60000);
              connection.setReadTimeout (60000);
              // Custom header
  
              return connection;
          }});
  
  
      try{
  
          start = System.currentTimeMillis();
  
  
              resp = soapConnection.call(getSoapRequest(xml), endPoint);      
  
          end = System.currentTimeMillis();
  
          ByteArrayOutputStream os = new ByteArrayOutputStream();
          resp.writeTo(os);
          response = os.toString();
  
  
          if (!resp.getSOAPBody().hasFault()) {
  
              response = "SucCess:" + response;
  
              }else{
  
                  response = "FaiLure:" + response;
              }
  
          }else{
  
              response = "FaiLure:" + response;
          }
  
  
      }catch(SOAPException se){
          _logger.log(Level.ERROR," Service Provisioning Call Failed");
          _logger.log(Level.ERROR,"The call duration before SOAPException =" +(end-start)+" ms.");
  
          se.printStackTrace();
          throw se;
      }
  
      soapConnection.close();
      return response;
  }
  
  
  private SOAPMessage getSoapRequest(String xml) throws SOAPException,Exception{
  
      MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
      /* Create a SOAP message object. */
      SOAPMessage soapMessage = mf.createMessage();
      SOAPPart soapPart = soapMessage.getSOAPPart();
      SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
      SOAPBody soapBody = soapEnvelope.getBody();
      soapEnvelope.getHeader().detachNode();
      soapEnvelope.addNamespaceDeclaration("soap","http://yyyy");
      SOAPHeader header = soapEnvelope.addHeader();
  
  
  
      DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
      builderFactory.setNamespaceAware(true);
  
      InputStream stream  = new ByteArrayInputStream(xml.getBytes());
      Document doc = builderFactory.newDocumentBuilder().parse(stream);
  
      _logger.log(Level.DEBUG, "Adding SOAP Request Body");
      soapBody.addDocument(doc);
  
      soapMessage.saveChanges();
  
      return soapMessage;
  
  }
  }
  </code></pre>
  
  <p>sample request </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
         &lt;env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://bridgewatersystems.com/xpc/tsc/entity/soap"&gt;
        &lt;env:Header/&gt;
          &lt;env:Body&gt;
               &lt;TempTierChangeRequest xmlns="http://bridgewatersystems.com/xpc/tsc/entity/soap" credentials="root" principal="root"&gt;
             &lt;temp-tier-change xmlns=""&gt;
                  &lt;service-components&gt;
                       &lt;service-component name="DSL_Tier_2"/&gt;
                  &lt;/service-components&gt;
                  &lt;duration-sec&gt;300&lt;/duration-sec&gt;
                  &lt;description&gt;1024 SC&lt;/description&gt;
                  &lt;activation-date&gt;2017-02-09T10:29:16&lt;/activation-date&gt;
                  &lt;subscriber-id&gt;26752018010@wholesale1.com&lt;/subscriber-id&gt;
                  &lt;partition-key&gt;26752018010&lt;/partition-key&gt;
                  &lt;ttc-id&gt;3706043&lt;/ttc-id&gt;
                  &lt;validity-period&gt;
                       &lt;duration&gt;30&lt;/duration&gt;
                       &lt;expires-with-billing-reset&gt;1&lt;/expires-with-billing-reset&gt;
                  &lt;/validity-period&gt;
             &lt;/temp-tier-change&gt;
        &lt;/TempTierChangeRequest&gt;
        &lt;/env:Body&gt;
        &lt;/env:Envelope&gt;
  </code></pre>