title: Receiving a Version Mismatch SOAP Fault even if Correct namespaces are used
body: <p>I am using apache commons httpclient version 4.2 to execute a simple web service based on SOAP 1.2. I am able to fire the web service properly through SOAP UI but I am unable to do the same using Java.</p>
  
  <p>Following is the method I'm using to invoke the service.</p>
  
  <pre><code>private static byte[] callSOAPServer(String body, String SOAP_ACTION,
          String SERVER_URL) {
  
      byte[] result = null;
  
      HttpParams httpParameters = new BasicHttpParams();
      // Set the timeout in milliseconds until a connection is established.
      int timeoutConnection = 15000;
      HttpConnectionParams.setConnectionTimeout(httpParameters,
              timeoutConnection);
      // Set the default socket timeout (SO_TIMEOUT)
      // in milliseconds which is the timeout for waiting for data.
      int timeoutSocket = 35000;
      HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
  
      DefaultHttpClient httpclient = new DefaultHttpClient(httpParameters);
  
      /*
       * httpclient.getCredentialsProvider().setCredentials( new
       * AuthScope("os.icloud.com", 80, null, "Digest"), new
       * UsernamePasswordCredentials(username, password));
       */
      HttpPost httppost = new HttpPost(SERVER_URL);
      httppost.setHeader("soapaction", SOAP_ACTION);
      httppost.setHeader("Content-Type", "text/xml; charset=utf-8");
  
      System.out.println("executing request" + httppost.getRequestLine());
      // now create a soap request message as follows:
      final StringBuffer soap = new StringBuffer();
      soap.append("\n");
      soap.append("");
      // this is a sample data..you have create your own required data BEGIN
      soap.append(" \n");
      soap.append(" \n");
      soap.append("" + body);
      soap.append(" \n");
      soap.append(" \n");
  
      /* soap.append(body); */
      // END of MEssage Body
      soap.append("");
      System.out.println("SOAP Request : " + soap.toString());
      // END of full SOAP request message
      try {
          HttpEntity entity = new StringEntity(soap.toString(), HTTP.UTF_8);
          httppost.setEntity(entity);
          HttpResponse response = httpclient.execute(httppost);// calling
                                                                  // server
          HttpEntity r_entity = response.getEntity(); // get response
          System.out.println("Reponse Header:Begin..."); // response headers
          System.out.println("Reponse Header StatusLine:"
                  + response.getStatusLine());
          Header[] headers = response.getAllHeaders();
          for (Header h : headers) {
              System.out.println("Reponse Header " + h.getName() + ": "
                      + h.getValue());
          }
          System.out.println("Reponse Header END...");
          if (r_entity != null) {
              result = new byte[(int) r_entity.getContentLength()];
              if (r_entity.isStreaming()) {
                  DataInputStream is = new DataInputStream(
                          r_entity.getContent());
                  is.readFully(result);
              }
          }
      } catch (Exception E) {
          System.out.println("Exception While Connecting " + E.getMessage());
          E.printStackTrace();
      }
  
      httpclient.getConnectionManager().shutdown(); // shut down the
                                                      // connection
      return result;
  }
  </code></pre>
  
  <p>Following is my SOAP Request as well as the end point.</p>
  
  <pre><code>String soapRequest = "&lt;soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:typ=\"http://skash.service.sahaj.com/types/\"&gt;"
              + "&lt;soap:Header/&gt;"
              + "&lt;soap:Body&gt;"
              + "&lt;typ:remoteSKASHDeductionElement&gt;"
              + "&lt;typ:vleId&gt;?&lt;/typ:vleId&gt;"
              + "&lt;typ:paidAmt&gt;?&lt;/typ:paidAmt&gt;"
              + "&lt;typ:refTxnId&gt;?&lt;/typ:refTxnId&gt;"
              + "&lt;/typ:remoteSKASHDeductionElement&gt;"
              + "&lt;/soap:Body&gt;"
              + "&lt;/soap:Envelope&gt;";
      String soapEndPoint = "http://xxx.xxx.xxx.xxx:xxxx/skashws/remoteSKASHDeductionSoap12HttpPort";
      String soapAction = "http://xxx.xxx.xxx.xxx:xxxx//remoteSKASHDeduction";
      // executeSOAPRequest(soapRequest, soapEndPoint, soapAction);
      byte[] resp = callSOAPServer(soapRequest, soapAction, soapEndPoint);
      System.out.println(IOUtils.toString(resp));
  </code></pre>
  
  <p>I can see that the namespace set to Envelope tag is for SOAP 1.2 and is well set. I am not sure where I'm going wrong. I am receiving the following version mismatch error.</p>
  
  <pre><code>&lt;env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;env:Header&gt;
      &lt;env:Upgrade&gt;
          &lt;env:SupportedEnvelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" qname="soap12:Envelope"/&gt;
      &lt;/env:Upgrade&gt;
  &lt;/env:Header&gt;
  &lt;env:Body&gt;
      &lt;env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
          &lt;faultcode&gt;env:VersionMismatch&lt;/faultcode&gt;
          &lt;faultstring&gt;Version Mismatch&lt;/faultstring&gt;
          &lt;faultactor&gt;http://schemas.xmlsoap.org/soap/actor/next&lt;/faultactor&gt;
      &lt;/env:Fault&gt;
  &lt;/env:Body&gt;
  </code></pre>
  
  <p></p>