title: SSL - HTTPException: HTTP response '413: Request Entity Too Large' when communicating
body: <p>I have a webservice client in Wildfly which is trying to upload a small file around 400 - 500kb, it was working fine but when I added the Client Cert Authentication logic it is complaining of</p>
  
  <pre><code>HTTPException: HTTP response '413: Request Entity Too Large' when communicating with 
  </code></pre>
  
  <p><strong>What am I missing here or why did it stop working, how to fix it.</strong>
  The server implements the service using xdoclet tags. The client auth is done at apache level and not the application code.</p>
  
  <p>Following is the code:</p>
  
  <pre><code>        String WS_URL = PropertiesLoader.getInstance().getMyServiceWsdlUrl();
          URL url = new URL(WS_URL);
          QName qname = new QName(PropertiesLoader.getInstance().getMyServiceNamespaceURI(), "MyService");
  
          //Service service = Service.create(url, qname);
  
          Service service = Service.create(qname);
  
          MyEndpoint myEndpointPort = service.getPort(MyEndpoint.class);
          //HACK: The underlying "JMess" changes our passed Endpoint URL with the hostname of the box (that we won't be able to find
          //      since everything is straight IP's...  So we update it again here... There has to be a better way...
          //((BindingProvider)myEndpointPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,WS_URL.replace("?wsdl",""));
          Map&lt;String, Object&gt; req_ctx = ((BindingProvider) myEndpointPort).getRequestContext();
          req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, WS_URL.replace("?wsdl",""));
          BindingProvider bp = (BindingProvider) myEndpointPort;
          SOAPBinding binding = (SOAPBinding) bp.getBinding();
  
          // Adding Client Authentication
          System.setProperty("javax.net.ssl.trustStore", PropertiesLoader.getInstance().getServerTruststore());
          System.setProperty("javax.net.ssl.trustStorePassword", PropertiesLoader.getInstance().getServerTruststorePassword());
          System.setProperty("javax.net.ssl.keyStore", PropertiesLoader.getInstance().getServerKeystore());
          System.setProperty("javax.net.ssl.keyStorePassword", PropertiesLoader.getInstance().getServerKeystorePassword());
          System.setProperty("javax.net.debug", "SSL");
  
          Client client=ClientProxy.getClient(myEndpointPort);
          HTTPConduit conduit = (HTTPConduit)client.getConduit();
          TLSClientParameters tlsParams = new TLSClientParameters();
  
          // Disabling host name check
          tlsParams.setDisableCNCheck(true);
  
          // Setup Truststore 
          KeyStore keyStore = KeyStore.getInstance("JKS");
          File truststore = new File(PropertiesLoader.getInstance().getServerTruststore());
          keyStore.load(new FileInputStream(truststore), PropertiesLoader.getInstance().getServerTruststorePassword().toCharArray()); 
  
          // Setting trust manager(s)
          TrustManagerFactory trustFactory = 
              TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); 
          trustFactory.init(keyStore); 
          TrustManager[] tm = trustFactory.getTrustManagers(); 
          tlsParams.setTrustManagers(tm);
  
          // Setup Keystore 
          truststore = new File(PropertiesLoader.getInstance().getServerKeystore());
          keyStore.load(new FileInputStream(truststore), PropertiesLoader.getInstance().getServerKeystorePassword().toCharArray());
  
          // Setting up key manager(s)
          KeyManagerFactory keyFactory = 
              KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());                         
          keyFactory.init(keyStore, PropertiesLoader.getInstance().getServerKeystorePassword().toCharArray()); 
          KeyManager[] km = keyFactory.getKeyManagers();                      
          tlsParams.setKeyManagers(km); 
  
          // Setting parameters
          conduit.setTlsClientParameters(tlsParams); 
  </code></pre>