當前位置: 首頁>>代碼示例>>Java>>正文


Java HTTPClientPolicy.setConnectionTimeout方法代碼示例

本文整理匯總了Java中org.apache.cxf.transports.http.configuration.HTTPClientPolicy.setConnectionTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java HTTPClientPolicy.setConnectionTimeout方法的具體用法?Java HTTPClientPolicy.setConnectionTimeout怎麽用?Java HTTPClientPolicy.setConnectionTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.cxf.transports.http.configuration.HTTPClientPolicy的用法示例。


在下文中一共展示了HTTPClientPolicy.setConnectionTimeout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
@GET
@Path("test")
public String test() {

    TestService_Service s = new TestService_Service();
    TestService ts = s.getTestServicePort();

    // 設置客戶端的配置信息,超時等.
    Client proxy = ClientProxy.getClient(ts);
    HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
    HTTPClientPolicy policy = new HTTPClientPolicy();

    // 連接服務器超時時間
    policy.setConnectionTimeout(30000);
    // 等待服務器響應超時時間
    policy.setReceiveTimeout(30000);

    conduit.setClient(policy);

    ts.echo();
    return "web service perfect";
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:23,代碼來源:WSService.java

示例2: createTrustedWebClient

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
public static WebClient createTrustedWebClient( String url )
{
    WebClient client = WebClient.create( url );

    HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit();

    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout( defaultConnectionTimeout );
    httpClientPolicy.setReceiveTimeout( defaultReceiveTimeout );
    httpClientPolicy.setMaxRetransmits( defaultMaxRetransmits );


    httpConduit.setClient( httpClientPolicy );

    SSLManager sslManager = new SSLManager( null, null, null, null );

    TLSClientParameters tlsClientParameters = new TLSClientParameters();
    tlsClientParameters.setDisableCNCheck( true );
    tlsClientParameters.setTrustManagers( sslManager.getClientFullTrustManagers() );
    httpConduit.setTlsClientParameters( tlsClientParameters );

    return client;
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:24,代碼來源:RestUtil.java

示例3: getServiceProxy

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
public static JaxWsProxyFactoryBean getServiceProxy(BindingProvider servicePort, String serviceAddr) {
		JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
		if(serviceAddr != null)
			proxyFactory.setAddress(serviceAddr);
		proxyFactory.setServiceClass(servicePort.getClass());
		proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor());  
		SoapBindingConfiguration config = new SoapBindingConfiguration();  
		config.setVersion(Soap12.getInstance());
		proxyFactory.setBindingConfig(config);
		Client deviceClient = ClientProxy.getClient(servicePort);

		HTTPConduit http = (HTTPConduit) deviceClient.getConduit();

//		AuthorizationPolicy authPolicy = new AuthorizationPolicy();
//		authPolicy.setUserName(username);
//		authPolicy.setPassword(password);
//		authPolicy.setAuthorizationType("Basic");
//		http.setAuthorization(authPolicy);
		
		HTTPClientPolicy httpClientPolicy = http.getClient();
		httpClientPolicy.setConnectionTimeout(36000);  
		httpClientPolicy.setReceiveTimeout(32000);
		httpClientPolicy.setAllowChunking(false);
		return proxyFactory;
	}
 
開發者ID:fpompermaier,項目名稱:onvif,代碼行數:26,代碼來源:OnvifDevice.java

示例4: start

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
public T start(Class<T> cls, String url, boolean trustAllCerts, String trustStore, String trustStorePassword, 
	List<?> providers, int connectTimeout, int receiveTimeout) {

	try {
		
		T resource = JAXRSClientFactory.create(url, cls, providers);
	    HTTPConduit conduit = WebClient.getConfig(resource).getHttpConduit();
	    WebClient.getConfig(resource).getInInterceptors().add(new LoggingInInterceptor());
	    WebClient.getConfig(resource).getOutInterceptors().add(new LoggingOutInterceptor());
		configureHTTPS(resource, conduit, trustAllCerts, trustStore, trustStorePassword);
		
	    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 
	    httpClientPolicy.setConnectionTimeout(connectTimeout); 
	    httpClientPolicy.setReceiveTimeout(receiveTimeout); 
	    conduit.setClient(httpClientPolicy);
		
		return resource;
		
	} catch (Exception e) {
		LOG.error(" rest client '{}': NOT STARTED", url);
		return null;
	}
	
}
 
開發者ID:csob,項目名稱:paymentgateway,代碼行數:25,代碼來源:JaxRsClientStarter.java

示例5: build

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
/**
 * Build a client proxy, for a specific proxy type.
 * 
 * @param proxyType proxy type class
 * @return client proxy stub
 */
protected <T> T build(Class<T> proxyType) {
    String address = generateAddress();
    T rootResource;
    // Synchronized on the class to correlate with the scope of clientStaticResources
    // We want to ensure that the shared bean isn't set concurrently in multiple callers
    synchronized (AmbariClientBuilder.class) {
        JAXRSClientFactoryBean bean = cleanFactory(clientStaticResources.getUnchecked(proxyType));
        bean.setAddress(address);
        if (username != null) {
            bean.setUsername(username);
            bean.setPassword(password);
        }

        if (enableLogging) {
            bean.setFeatures(Arrays.<AbstractFeature> asList(new LoggingFeature()));
        }
        rootResource = bean.create(proxyType);
    }

    boolean isTlsEnabled = address.startsWith("https://");
    ClientConfiguration config = WebClient.getConfig(rootResource);
    HTTPConduit conduit = (HTTPConduit) config.getConduit();
    if (isTlsEnabled) {
        TLSClientParameters tlsParams = new TLSClientParameters();
        if (!validateCerts) {
            tlsParams.setTrustManagers(new TrustManager[] { new AcceptAllTrustManager() });
        } else if (trustManagers != null) {
            tlsParams.setTrustManagers(trustManagers);
        }
        tlsParams.setDisableCNCheck(!validateCn);
        conduit.setTlsClientParameters(tlsParams);
    }

    HTTPClientPolicy policy = conduit.getClient();
    policy.setConnectionTimeout(connectionTimeoutUnits.toMillis(connectionTimeout));
    policy.setReceiveTimeout(receiveTimeoutUnits.toMillis(receiveTimeout));
    return rootResource;
}
 
開發者ID:Talend,項目名稱:components,代碼行數:45,代碼來源:AmbariClientBuilder.java

示例6: configureBean

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
@Override
public void configureBean(String name, Object beanInstance) {
	if (beanInstance instanceof HTTPConduit) {
		HTTPConduit http = (HTTPConduit) beanInstance;
		TLSClientParameters tls = new TLSClientParameters();
		tls.setTrustManagers(trustManagers);
		tls.setKeyManagers(keyManagers);
		tls.setDisableCNCheck(true);
		tls.setCipherSuitesFilter(getCipherSuites());
		http.setTlsClientParameters(tls);
		HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
		httpClientPolicy.setConnectionTimeout(36000);
		httpClientPolicy.setAllowChunking(false);
		httpClientPolicy.setReceiveTimeout(120000);
		http.setClient(httpClientPolicy);
	} else {
		parentConfigurer.configureBean(name, beanInstance);
	}
}
 
開發者ID:NCIP,項目名稱:cagrid2,代碼行數:20,代碼來源:SoapClientFactory.java

示例7: doRefer

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
  protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
  	ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
  	proxyFactoryBean.setAddress(url.setProtocol("http").toIdentityString());
  	proxyFactoryBean.setServiceClass(serviceType);
  	proxyFactoryBean.setBus(bus);
  	T ref = (T) proxyFactoryBean.create();
  	Client proxy = ClientProxy.getClient(ref);  
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
policy.setReceiveTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
conduit.setClient(policy);
      return ref;
  }
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:16,代碼來源:WebServiceProtocol.java

示例8: configHttpConduit

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
private void configHttpConduit(Object port) {

        // 設置客戶端的配置信息,超時等.
        Client proxy = ClientProxy.getClient(port);
        HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
        HTTPClientPolicy policy = new HTTPClientPolicy();

        // 連接服務器超時時間
        policy.setConnectionTimeout(this.connectTimeout);
        // 等待服務器響應超時時間
        policy.setReceiveTimeout(this.receiveTimeout);

        conduit.setClient(policy);
    }
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:15,代碼來源:CECXFClient.java

示例9: createWebClient

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
/**
 * Creates a JAXRS web client for the given JAXRS client
 */
protected <T> T createWebClient(Class<T> clientType) {
    List<Object> providers = WebClients.createProviders();
    String queryString = "?secret=" + secret + "&secretNamespace=" + secretNamespace + "&kubeUserName=" + kubeUserName;
    String commandsAddress = URLUtils.pathJoin(this.address, "/api/forge" + queryString);
    WebClient webClient = WebClient.create(commandsAddress, providers);
    disableSslChecks(webClient);
    HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(connectionTimeoutMillis);
    httpClientPolicy.setReceiveTimeout(connectionTimeoutMillis);
    conduit.setClient(httpClientPolicy);

    return JAXRSClientFactory.fromClient(webClient, clientType);
}
 
開發者ID:fabric8io,項目名稱:fabric8-forge,代碼行數:18,代碼來源:ForgeClient.java

示例10: getWsClientProxy

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
public static Object getWsClientProxy(
		Class<?> clientClass,
		String wsUrl,
		String wsUserName,
		String wsPassword,
		String authType,
		boolean generateTimestamp,
		boolean logCalls,
		boolean disableCnCheck,
		Integer timeout) {
	ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
	factory.setAddress(wsUrl);
	factory.setServiceClass(clientClass);
	if (logCalls) {
		factory.getInInterceptors().add(new LoggingInInterceptor());
		factory.getOutInterceptors().add(new LoggingOutInterceptor());
	}
	String authTypeBo = authType;
	if (authTypeBo == null || authTypeBo.length() == 0) {
		if (wsUserName != null && wsUserName.length() > 0)
			authTypeBo = "BASIC";
	}
	if ("BASIC".equalsIgnoreCase(authTypeBo)) {
		factory.setUsername(wsUserName);
		factory.setPassword(wsPassword);
	} else if ("USERNAMETOKEN".equalsIgnoreCase(authTypeBo)) {
		Map<String, Object> wss4jInterceptorProps = new HashMap<String, Object>();
		if (generateTimestamp) {
			wss4jInterceptorProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN);
		} else {
			wss4jInterceptorProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
		}
		wss4jInterceptorProps.put(WSHandlerConstants.USER, wsUserName);
		wss4jInterceptorProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
		ClientPasswordCallback cp = new ClientPasswordCallback(wsPassword);
		wss4jInterceptorProps.put(WSHandlerConstants.PW_CALLBACK_REF, cp);
		factory.getOutInterceptors().add(new WSS4JOutInterceptor(wss4jInterceptorProps));
	}
	Object c = factory.create();
	
	Client client = ClientProxy.getClient(c);
       HTTPConduit httpConduit = (HTTPConduit)client.getConduit();
       HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
       if (timeout != null) {
       	httpClientPolicy.setConnectionTimeout(timeout);
       	httpClientPolicy.setReceiveTimeout(timeout);
       }
       // Envi­o chunked
	httpClientPolicy.setAllowChunking(isWsClientChunked());
       httpConduit.setClient(httpClientPolicy);
       
	if (disableCnCheck) {
        TLSClientParameters tlsParams = new TLSClientParameters();
        tlsParams.setDisableCNCheck(true);
        httpConduit.setTlsClientParameters(tlsParams);
	}
	return c;
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:59,代碼來源:WsClientUtils.java

示例11: configureTimeout

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
private static void configureTimeout(HTTPConduit httpConduit)
{
	HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

	httpClientPolicy.setConnectionTimeout(connectionTimeout);
	httpClientPolicy.setAllowChunking(false);
	httpClientPolicy.setReceiveTimeout(receiveTimeout);

	httpConduit.setClient(httpClientPolicy);
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:11,代碼來源:CxfClientUtilsOld.java

示例12: configHttpClientPolicy

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
private static void configHttpClientPolicy(HTTPConduit http)
{
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(60000);
    httpClientPolicy.setAllowChunking(false);
    httpClientPolicy.setReceiveTimeout(60000);
    http.setClient(httpClientPolicy);
}
 
開發者ID:Huawei,項目名稱:eSDK_IVS_Java,代碼行數:9,代碼來源:ClientProvider.java

示例13: buildEnvironmentWebClient

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
public static WebClient buildEnvironmentWebClient( final PeerInfo peerInfo, final String path,
                                                   final Object provider )
{
    String effectiveUrl = String.format( ENVIRONMENT_URL_TEMPLATE, peerInfo.getIp(), peerInfo.getPublicSecurePort(),
            path.startsWith( "/" ) ? path : "/" + path );
    WebClient client = WebClient.create( effectiveUrl, Arrays.asList( provider ) );
    client.type( MediaType.APPLICATION_JSON );
    client.accept( MediaType.APPLICATION_JSON );
    HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit();

    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout( DEFAULT_CONNECTION_TIMEOUT );
    httpClientPolicy.setReceiveTimeout( DEFAULT_RECEIVE_TIMEOUT );
    httpClientPolicy.setMaxRetransmits( DEFAULT_MAX_RETRANSMITS );

    httpConduit.setClient( httpClientPolicy );

    KeyStoreTool keyStoreManager = new KeyStoreTool();
    KeyStoreData keyStoreData = new KeyStoreData();
    keyStoreData.setupKeyStorePx2();
    keyStoreData.setAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS );
    KeyStore keyStore = keyStoreManager.load( keyStoreData );

    LOG.debug( String.format( "Getting key with alias: %s for url: %s", SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS,
            effectiveUrl ) );

    KeyStoreData trustStoreData = new KeyStoreData();
    trustStoreData.setupTrustStorePx2();
    KeyStore trustStore = keyStoreManager.load( trustStoreData );

    SSLManager sslManager = new SSLManager( keyStore, keyStoreData, trustStore, trustStoreData );

    TLSClientParameters tlsClientParameters = new TLSClientParameters();
    tlsClientParameters.setDisableCNCheck( true );
    tlsClientParameters.setTrustManagers( sslManager.getClientTrustManagers() );
    tlsClientParameters.setKeyManagers( sslManager.getClientKeyManagers() );
    tlsClientParameters.setCertAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS );
    httpConduit.setTlsClientParameters( tlsClientParameters );
    return client;
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:41,代碼來源:WebClientBuilder.java

示例14: doRefer

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
  protected <T> T doRefer(final Class<T> serviceType, final URL url) throws JahhanException {
  	ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
  	proxyFactoryBean.setAddress(url.setProtocol("http").toIdentityString());
  	proxyFactoryBean.setServiceClass(serviceType);
  	proxyFactoryBean.setBus(bus);
  	T ref = (T) proxyFactoryBean.create();
  	Client proxy = ClientProxy.getClient(ref);  
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
policy.setReceiveTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
conduit.setClient(policy);
      return ref;
  }
 
開發者ID:nince-wyj,項目名稱:jahhan,代碼行數:16,代碼來源:WebServiceProtocol.java

示例15: configureTimeout

import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; //導入方法依賴的package包/類
private void configureTimeout(final Client clientProxy) {
    final HTTPConduit conduit = (HTTPConduit) clientProxy.getConduit();
    final HTTPClientPolicy policy = new HTTPClientPolicy();
    policy.setReceiveTimeout(this.wsConfiguration.getReceiveTimeout());
    policy.setConnectionTimeout(this.wsConfiguration.getReceiveTimeout());
    policy.setAsyncExecuteTimeout(this.wsConfiguration.getReceiveTimeout());
    conduit.setClient(policy);
}
 
開發者ID:todvora,項目名稱:eet-client,代碼行數:9,代碼來源:SecureEETCommunication.java


注:本文中的org.apache.cxf.transports.http.configuration.HTTPClientPolicy.setConnectionTimeout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。