1/**
2 * Digi-Key
3 * http://www.digikey.com
4 *
5 * Copyright 2010 Logicopolis Technology Inc. All rights reserved.
6 * http://www.logicopolis.com
7 */
8
9package org.ksoap2.transport;
10
11import java.io.IOException;
12
13/**
14 * KeepAliveHttpsTransport deals with the problems with the Android ssl libraries having trouble with certificates and
15 * certificate authorities somehow messing up connecting/needing reconnects. Added as generic class for SE since it
16 * might be useful in SE environments as well and can be used as an example to create your own transport
17 * implementations.
18 *
19 * @author Manfred Moser <manfred@simpligility.com>
20 *
21 * @see "http://groups.google.com/group/android-developers/browse_thread/thread/3dcf62e7886a213/21f912bb90a011d6"
22 * @see "http://code.google.com/p/android/issues/detail?id=7074"
23 * @see "http://crazybob.org/2010_02_01_crazyboblee_archive.html"
24 */
25public class KeepAliveHttpsTransportSE extends HttpsTransportSE
26{
27    private final String host;
28    private final int port;
29    private final String file;
30    private final int timeout;
31    private ServiceConnection serviceConnection;
32
33    public KeepAliveHttpsTransportSE(String host, int port, String file, int timeout) {
34        super(host, port, file, timeout);
35        this.host = host;
36        this.port = port;
37        this.file = file;
38        this.timeout = timeout;
39    }
40
41    /**
42     * Get a service connection. Returns an implementation of {@link org.ksoap2.transport.ServiceConnectionSE} that
43     * ignores "Connection: close" request property setting and has "Connection: keep-alive" always set and is uses
44     * a https connection.
45     * @see org.ksoap2.transport.HttpTransportSE#getServiceConnection()
46     */
47    //@Override
48    public ServiceConnection getServiceConnection() throws IOException
49    {
50        if (serviceConnection == null) {
51            serviceConnection = new HttpsServiceConnectionSEIgnoringConnectionClose(host, port,
52                    file, timeout);
53            serviceConnection.setRequestProperty("Connection", "keep-alive");
54        }
55        return serviceConnection;
56    }
57
58}
59