You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by si...@bt.com on 2008/12/19 15:57:45 UTC

Httpclient-webservice

HI I am trying to connect to webservice url from behind a firewall.
Since it is the secured site they gave necessary permissions to our fire
wall so now we can see the wsdl file from the browser.
They also sent one pfx certificate and password for it.
Now I am trying to connect to that webservice from our application
developed in Java using httpclient.
After creating necessary keystore and ssl connections it is throwing
unknown host exceptions.
We connect to many urls behind firewall with no problems. 

Please suggest us how to connect to webservice url
Is there any way to connect with out sockets?

Plz can some one help me to solve it

Here is some code snippet


try{
					
					int Port=443;
					System.out.println("socket block
1");
	
//char []passwKey = "VFPimport".toCharArray();
					
					
					
					char []passwKey =
"changeit".toCharArray();
	
KeyStore ts = KeyStore.getInstance("JKS");
	
ts.load(new FileInputStream(basePath +
CLIENT_KEYSTORE_PATH+"\\supplier_keystore"), passwKey);
	
//System.out.println((String)ts.toString());
	
KeyManagerFactory tmf = KeyManagerFactory.getInstance("SunX509");
	
tmf.init(ts,passwKey);
	
SSLContext sslContext = SSLContext.getInstance("TLS");
	
sslContext.init(tmf.getKeyManagers(), null, null);
	
SSLSocketFactory factory =sslContext.getSocketFactory();
	
HttpsURLConnection.setDefaultSSLSocketFactory(factory);
	
SSLSocket socket = (SSLSocket) factory.createSocket(supplierUrl,Port);
// Create the ServerSocket
	
String[] suites = socket.getSupportedCipherSuites();
	
socket.setEnabledCipherSuites(suites);
//
start handshake
	
socket.startHandshake();
					
				
					
				status =
checkClient.executeMethod(postMethod);
				
				


Regards

Sai