1 2 package org.ksoap2.transport; 3 4 import java.io.IOException; 5 import java.net.MalformedURLException; 6 import java.net.URL; 7 8 /** 9 * HttpsTransportSE is a simple transport for https protocal based connections. It creates a #HttpsServiceConnectionSE 10 * with the provided parameters. 11 * 12 * @author Manfred Moser <manfred (at) simpligility.com> 13 */ 14 public class HttpsTransportSE extends HttpTransportSE { 15 16 static final String PROTOCOL = "https"; 17 18 private ServiceConnection serviceConnection = null; 19 private final String host; 20 private final int port; 21 private final String file; 22 private final int timeout; 23 24 public HttpsTransportSE(String host, int port, String file, int timeout) { 25 super(HttpsTransportSE.PROTOCOL + "://" + host + ":" + port + file); 26 System.out.println("Establistion connection to: " + HttpsTransportSE.PROTOCOL + "://" 27 + host + ":" + port + file); 28 this.host = host; 29 this.port = port; 30 this.file = file; 31 this.timeout = timeout; 32 } 33 34 /** 35 * Returns the HttpsServiceConnectionSE and creates it if necessary 36 * @see org.ksoap2.transport.HttpsTransportSE#getServiceConnection() 37 */ 38 public ServiceConnection getServiceConnection() throws IOException 39 { 40 if (serviceConnection == null) { 41 serviceConnection = new HttpsServiceConnectionSE(host, port, file, timeout); 42 } 43 return serviceConnection; 44 } 45 46 public String getHost() { 47 48 String retVal = null; 49 50 try { 51 retVal = new URL(url).getHost(); 52 } catch (MalformedURLException e) { 53 e.printStackTrace(); 54 } 55 56 return retVal; 57 } 58 59 public int getPort() { 60 61 int retVal = -1; 62 63 try { 64 retVal = new URL(url).getPort(); 65 } catch (MalformedURLException e) { 66 e.printStackTrace(); 67 } 68 69 return retVal; 70 } 71 72 public String getPath() { 73 74 String retVal = null; 75 76 try { 77 retVal = new URL(url).getPath(); 78 } catch (MalformedURLException e) { 79 e.printStackTrace(); 80 } 81 82 return retVal; 83 } 84 } 85