/** Creates a new factory, which creates transports for the given client. * @param pClient The client, which is operating the factory. */ public XmlRpcSunHttpTransportFactory(XmlRpcClient pClient) { super(pClient); HTTP_TRANSPORT = new XmlRpcSunHttpTransport(pClient); }
protected void close() throws XmlRpcClientException { final URLConnection c = getURLConnection(); if (c instanceof HttpURLConnection) { ((HttpURLConnection) c).disconnect(); } }
protected URLConnection newURLConnection(URL pURL) throws IOException { final URLConnection conn = super.newURLConnection(pURL); final SSLSocketFactory sslSockFactory = getSSLSocketFactory(); if ((sslSockFactory != null) && (conn instanceof HttpsURLConnection)) ((HttpsURLConnection)conn).setSSLSocketFactory(sslSockFactory); return conn; } }
protected URLConnection newURLConnection(URL pURL) throws IOException { final URLConnection conn = super.newURLConnection(pURL); final SSLSocketFactory sslSockFactory = getSSLSocketFactory(); if ((sslSockFactory != null) && (conn instanceof HttpsURLConnection)) ((HttpsURLConnection)conn).setSSLSocketFactory(sslSockFactory); return conn; } }
public XmlRpcTransport getTransport() { return new XmlRpcSunHttpTransport(getClient()); } }
protected void close() throws XmlRpcClientException { final URLConnection c = getURLConnection(); if (c instanceof HttpURLConnection) { ((HttpURLConnection) c).disconnect(); } }
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); try { final URLConnection c = conn = newURLConnection(config.getServerURL()); c.setUseCaches(false); c.setDoInput(true); c.setDoOutput(true); } catch (IOException e) { throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e); } return super.sendRequest(pRequest); }
XmlRpcClient client = new XmlRpcClient() client.setTransportFactory(new XmlRpcTransportFactory(){ @Override public XmlRpcTransport getTransport() { return new XmlRpcSunHttpTransport(client){ protected java.net.URLConnection getURLConnection(){ URLConnection urlConnection = super.getURLConnection(); urlConnection.setConnectTimeout(60000); urlConnection.setReadTimeout(60000); return urlConnection; } }; }});
protected void setRequestHeader(String pHeader, String pValue) { getURLConnection().setRequestProperty(pHeader, pValue); }
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); try { final URLConnection c = conn = newURLConnection(config.getServerURL()); c.setUseCaches(false); c.setDoInput(true); c.setDoOutput(true); } catch (IOException e) { throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e); } return super.sendRequest(pRequest); }
public XmlRpcTransport getTransport() { return new XmlRpcSunHttpTransport(getClient()); } }
protected void setRequestHeader(String pHeader, String pValue) { getURLConnection().setRequestProperty(pHeader, pValue); }
return new XmlRpcSunHttpTransport(client) {
protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { return HttpUtil.isUsingGzipEncoding(getURLConnection().getHeaderField("Content-Encoding")); }
protected void writeRequest(ReqWriter pWriter) throws IOException, XmlRpcException, SAXException { pWriter.write(getURLConnection().getOutputStream()); } }
protected void writeRequest(ReqWriter pWriter) throws IOException, XmlRpcException, SAXException { pWriter.write(getURLConnection().getOutputStream()); } }
protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { return HttpUtil.isUsingGzipEncoding(getURLConnection().getHeaderField("Content-Encoding")); }
protected InputStream getInputStream() throws XmlRpcException { try { URLConnection connection = getURLConnection(); if ( connection instanceof HttpURLConnection ) { HttpURLConnection httpConnection = (HttpURLConnection) connection; int responseCode = httpConnection.getResponseCode(); if (responseCode < 200 || responseCode > 299) { throw new XmlRpcHttpTransportException(responseCode, httpConnection.getResponseMessage()); } } return connection.getInputStream(); } catch (IOException e) { throw new XmlRpcException("Failed to create input stream: " + e.getMessage(), e); } }
protected InputStream getInputStream() throws XmlRpcException { try { URLConnection connection = getURLConnection(); if ( connection instanceof HttpURLConnection ) { HttpURLConnection httpConnection = (HttpURLConnection) connection; int responseCode = httpConnection.getResponseCode(); if (responseCode < 200 || responseCode > 299) { throw new XmlRpcHttpTransportException(responseCode, httpConnection.getResponseMessage()); } } return connection.getInputStream(); } catch (IOException e) { throw new XmlRpcException("Failed to create input stream: " + e.getMessage(), e); } }