Java consuming REST services -


i'm trying consume rest service using java client , obtain java.net.connectexception: connection timed out exception.

if i'm using web client (chrome, firefox) i'm able retrieve right answer.

i added in windows firewall exception java not solve problem. connection secured.

sslcontext sslcontext = sslcontext.getinstance("tls");         x509trustmanager[] xtmarray = new x509trustmanager[] { new owntrustmanager() };         sslcontext.init(null, xtmarray, new java.security.securerandom());         if (sslcontext != null) {             httpsurlconnection.setdefaultsslsocketfactory(sslcontext                     .getsocketfactory());         }         httpsurlconnection                 .setdefaulthostnameverifier(new isahostnameverifier());    public class owntrustmanager implements x509trustmanager{ public void checkclienttrusted(x509certificate[] chain, string authtype) { }  public void checkservertrusted(x509certificate[] chain, string authtype) { }  public x509certificate[] getacceptedissuers() {     return null; } }   public class isahostnameverifier implements hostnameverifier{ public boolean verify(string hostname, sslsession session) {     return true; } } 

business logic is:

url url = null;       try {           url = new url("https://16.9.1.82/xxxx/v23/rest");          httpsurlconnection con = (httpsurlconnection)url.openconnection();          con.setrequestmethod("get");          con.setrequestproperty("accept", "application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");          con.setrequestproperty("accept-encoding", "gzip,deflate,sdch");          con.setrequestproperty("cookie", "----");          con.setrequestproperty("host", "16.9.1.82");          con.setrequestproperty("authorization", "basic u1bqq19sttfasujnlknpttptyxhhzg1pbg==");          con.connect(); 


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -