Java Code Examples for org.apache.cxf.endpoint.Client

The following are top voted examples for showing how to use org.apache.cxf.endpoint.Client. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Equella   File: SoapClientFactory.java   View source code 8 votes vote down vote up
public <T> T createSoapClient(Class<T> serviceClass, URL endpoint, String namespace)
{
	ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
	Bus bus = new ExtensionManagerBus(null, null, Bus.class.getClassLoader());
	factory.setBus(bus);
	factory.setServiceClass(serviceClass);
	factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
	factory.setAddress(endpoint.toString());
	factory.getServiceFactory().getServiceConfigurations().add(0, new XFireCompatabilityConfiguration());
	factory.setDataBinding(new AegisDatabinding());
	@SuppressWarnings("unchecked")
	T soapClient = (T) factory.create();
	Client client = ClientProxy.getClient(soapClient);
	client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
	HTTPClientPolicy policy = new HTTPClientPolicy();
	policy.setReceiveTimeout(600000);
	policy.setAllowChunking(false);
	HTTPConduit conduit = (HTTPConduit) client.getConduit();
	conduit.setClient(policy);
	return soapClient;
}
 
Example 2
Project: iws   File: AdministrationWSClient.java   View source code 7 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/administrationWS?wsdl
 *
 * @param wsdlLocation IWS Administration WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public AdministrationWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, AdministrationWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a load balancer and/or proxies, this address may
    // not be available or resolvable via DNS. Instead, we force using the
    // same WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 3
Project: Camel   File: GreeterClientTest.java   View source code 7 votes vote down vote up
protected String sendMessageWithUsernameToken(String username, String password, String message) throws Exception {
    final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, SERVICE_QNAME);
    final Greeter greeter = svc.getPort(PORT_QNAME, Greeter.class);

    Client client = ClientProxy.getClient(greeter);        
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("action", "UsernameToken");
    props.put("user", username);
    // Set the the password type to be plain text, 
    // so we can keep using the password to authenticate with spring security
    props.put("passwordType", "PasswordText");       
    WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor(props);

    client.getOutInterceptors().add(wss4jOut);
    ((BindingProvider)greeter).getRequestContext().put("password", password);
    return greeter.greetMe(message);
}
 
Example 4
Project: Camel   File: CXFWsdlOnlyPayloadModeNoSpringTest.java   View source code 7 votes vote down vote up
@Test
public void testRoutes() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));

    Person client = ss.getSoap();
    
    Client c = ClientProxy.getClient(client);
    
    ((BindingProvider)client).getRequestContext()
        .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
             "http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    
    Holder<String> personId = new Holder<String>();
    personId.value = "hello";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    client.getPerson(personId, ssn, name);
    assertEquals("Bonjour", name.value);

}
 
Example 5
Project: mpay24-java   File: SoapCommunication.java   View source code 6 votes vote down vote up
private void disableCertificateChecks(Client cxfClient) {
	HTTPConduit httpConduit = (HTTPConduit) cxfClient.getConduit();
	TLSClientParameters tlsCP = new TLSClientParameters();
	tlsCP.setTrustManagers(getNoCertificationCheckTrustManager());
	tlsCP.setDisableCNCheck(true);
	httpConduit.setTlsClientParameters(tlsCP);
}
 
Example 6
Project: Equella   File: SoapHelper.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> T createSoap(Class<T> serviceClass, URL endpoint, String namespace, Object previousSession)
{
	ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
	factory.setServiceClass(serviceClass);
	factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
	factory.setAddress(endpoint.toString());
	List<AbstractServiceConfiguration> configs = factory.getServiceFactory().getServiceConfigurations();
	configs.add(0, new XFireReturnTypeConfig());
	factory.setDataBinding(new AegisDatabinding());
	T service = (T) factory.create();
	Client client = ClientProxy.getClient(service);
	client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
	HTTPClientPolicy policy = new HTTPClientPolicy();
	policy.setReceiveTimeout(600000);
	policy.setAllowChunking(false);
	HTTPConduit conduit = (HTTPConduit) client.getConduit();
	conduit.setClient(policy);
	if( previousSession != null )
	{
		copyCookiesInt(conduit, previousSession);
	}
	return service;
}
 
Example 7
Project: uavstack   File: WSService.java   View source code 6 votes vote down vote up
@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";
}
 
Example 8
Project: OSCAR-ConCert   File: CxfClientUtilsOld.java   View source code 6 votes vote down vote up
public static void configureClientConnection(Object wsPort)
{
	Client cxfClient = ClientProxy.getClient(wsPort);
	HTTPConduit httpConduit = (HTTPConduit)cxfClient.getConduit();

	configureSsl(httpConduit);
	configureTimeout(httpConduit);
	
	if(OscarProperties.getInstance().getProperty("INTEGRATOR_COMPRESSION_ENABLED","false").equals("true")) {
		configureGZIP(cxfClient);
	}

	if(OscarProperties.getInstance().getProperty("INTEGRATOR_LOGGING_ENABLED","false").equals("true")) {
		configureLogging(cxfClient,true);
	}

}
 
Example 9
Project: eSDK_IVS_Java   File: ClientProvider.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static Object configureHttp(Object obj, Class clz)
{
    Client client = ClientProxy.getClient(obj);
    addInterceptor(client);
    
    interceptorLoggingCtrl(client);
    
    HTTPConduit http = (HTTPConduit)client.getConduit();
    if (null == http)
    {
        return null;
    }
    configHttpClientPolicy(http);
    
    clientMap.put(clz.getName(), obj);
    return obj;
}
 
Example 10
Project: eSDK_IVS_Java   File: ClientProvider.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static Object configureHttp(Object obj, Class clz)
{
    Client client = ClientProxy.getClient(obj);
    addInterceptor(client);
    
    interceptorLoggingCtrl(client);
    
    HTTPConduit http = (HTTPConduit)client.getConduit();
    if (null == http)
    {
        return null;
    }
    configHttpClientPolicy(http);
    
    clientMap.put(clz.getName(), obj);
    return obj;
}
 
Example 11
Project: eSDK_IVS_Java   File: ClientProvider.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static Object configureHttp(Object obj, Class clz)
{
    Client client = ClientProxy.getClient(obj);
    addInterceptor(client);
    
    interceptorLoggingCtrl(client);
    
    HTTPConduit http = (HTTPConduit)client.getConduit();
    if (null == http)
    {
        return null;
    }
    configHttpClientPolicy(http);
    
    clientMap.put(clz.getName(), obj);
    return obj;
}
 
Example 12
Project: eSDK_IVS_Java   File: ClientProvider.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static Object configureHttp(Object obj, Class clz)
{
    Client client = ClientProxy.getClient(obj);
    addInterceptor(client);
    
    interceptorLoggingCtrl(client);
    
    HTTPConduit http = (HTTPConduit)client.getConduit();
    if (null == http)
    {
        return null;
    }
    configHttpClientPolicy(http);
    
    clientMap.put(clz.getName(), obj);
    return obj;
}
 
Example 13
Project: iws   File: StorageWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/storageWS?wsdl
 *
 * @param wsdlLocation IWS Storage WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public StorageWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, StorageWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a load balancer and/or proxies, this address may
    // not be available or resolvable via DNS. Instead, we force using the
    // same WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 14
Project: iws   File: AccessWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/accessWS?wsdl
 *
 * @param wsdlLocation IWS Access WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public AccessWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, AccessWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a load balancer and/or proxies, this address may
    // not be available or resolvable via DNS. Instead, we force using the
    // same WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 15
Project: iws   File: ExchangeWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/exchangeWS?wsdl
 *
 * @param wsdlLocation IWS Exchange WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public ExchangeWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, ExchangeWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a load balancer and/or proxies, this address may
    // not be available or resolvable via DNS. Instead, we force using the
    // same WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 16
Project: iws   File: CommitteeWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/committeeWS?wsdl
 *
 * @param wsdlLocation IWS Committees WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public CommitteeWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, CommitteeWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a load balancer and/or proxies, this address may
    // not be available or resolvable via DNS. Instead, we force using the
    // same WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 17
Project: iws   File: StudentWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/studentWS?wsdl
 *
 * @param wsdlLocation IWS Students WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public StudentWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, StudentWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a load balancer and/or proxies, this address may
    // not be available or resolvable via DNS. Instead, we force using the
    // same WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 18
Project: iws   File: AccessWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/accessWS?wsdl
 *
 * @param wsdlLocation IWS Access WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public AccessWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, AccessWS.class);

    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a loadbalancer and/or proxies, this address may not
    // be available or resolvable via DNS. Instead, we force using the same
    // WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 19
Project: iws   File: ExchangeWSClient.java   View source code 6 votes vote down vote up
/**
 * IWS Access WebService Client Constructor. Takes the URL for the WSDL as
 * parameter, to generate a new WebService Client instance.<br />
 *   For example: https://iws.iaeste.net:9443/iws-ws/exchangeWS?wsdl
 *
 * @param wsdlLocation IWS Exchange WSDL URL
 * @throws MalformedURLException if not a valid URL
 */
public ExchangeWSClient(final String wsdlLocation) throws MalformedURLException {
    super(new URL(wsdlLocation), ACCESS_SERVICE_NAME);
    client = getPort(ACCESS_SERVICE_PORT, ExchangeWS.class);

    // make sure to initialize tlsParams prior to this call somewhere
    //http.setTlsClientParameters(getTlsParams());
    // The CXF will by default attempt to read the URL from the WSDL at the
    // Server, which is normally given with the server's name. However, as
    // we're running via a loadbalancer and/or proxies, this address may not
    // be available or resolvable via DNS. Instead, we force using the same
    // WSDL for requests as we use for accessing the server.
    // Binding: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-Howtooverridetheserviceaddress?
    ((BindingProvider) client).getRequestContext().put(ENDPOINT_ADDRESS, wsdlLocation);

    // The CXF has a number of default Policy settings, which can all be
    // controlled via the internal Policy Scheme. To override or update the
    // default values, the Policy must be exposed. Which is done by setting
    // a new Policy Scheme which can be access externally.
    // Policy: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-HowtoconfiguretheHTTPConduitfortheSOAPClient?
    final Client proxy = ClientProxy.getClient(client);
    final HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

    // Finally, set the Policy into the HTTP Conduit.
    conduit.setClient(policy);
}
 
Example 20
Project: onvif   File: OnvifDevice.java   View source code 6 votes vote down vote up
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;
	}
 
Example 21
Project: Camel   File: PayLoadDataFormatFeature.java   View source code 6 votes vote down vote up
@Override
public void initialize(Client client, Bus bus) {
    client.getEndpoint().put("org.apache.cxf.binding.soap.addNamespaceContext", "true");
    removeFaultInInterceptorFromClient(client);
    
    // Need to remove some interceptors that are incompatible
    // We don't support JAX-WS Holders for PAYLOAD (not needed anyway)
    // and thus we need to remove those interceptors to prevent Holder
    // object from being created and stuck into the contents list
    // instead of Source objects
    removeInterceptor(client.getEndpoint().getInInterceptors(), 
                      HolderInInterceptor.class);
    removeInterceptor(client.getEndpoint().getOutInterceptors(), 
                      HolderOutInterceptor.class);
    // The SoapHeaderInterceptor maps various headers onto method parameters.
    // At this point, we expect all the headers to remain as headers, not
    // part of the body, so we remove that one.
    removeInterceptor(client.getEndpoint().getBinding().getInInterceptors(), 
                      SoapHeaderInterceptor.class);
    client.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
    resetPartTypes(client.getEndpoint().getBinding());

    LOG.info("Initialized CXF Client: {} in Payload mode with allow streaming: {}", client, allowStreaming);
}
 
Example 22
Project: Camel   File: CxfProducerTest.java   View source code 6 votes vote down vote up
@Test
public void testInvokingSimpleServerWithParams() throws Exception {
    Exchange exchange = sendSimpleMessage();

    org.apache.camel.Message out = exchange.getOut();
    String result = out.getBody(String.class);
    LOG.info("Received output text: " + result);
    Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
    assertNotNull(responseContext);
    assertEquals("We should get the response context here", "UTF-8", responseContext.get(org.apache.cxf.message.Message.ENCODING));
    assertEquals("reply body on Camel", "echo " + TEST_MESSAGE, result);
    
    // check the other camel header copying
    String fileName = out.getHeader(Exchange.FILE_NAME, String.class);
    assertEquals("Should get the file name from out message header", "testFile", fileName);
    
    // check if the header object is turned into String
    Object requestObject = out.getHeader("requestObject");
    assertTrue("We should get the right requestObject.", requestObject instanceof DefaultCxfBinding);
}
 
Example 23
Project: Camel   File: CxfProducerTest.java   View source code 6 votes vote down vote up
@Test
public void testInvokingJaxWsServerWithParams() throws Exception {
    Exchange exchange = sendJaxWsMessage();

    org.apache.camel.Message out = exchange.getOut();
    String result = out.getBody(String.class);
    LOG.info("Received output text: " + result);
    Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
    assertNotNull(responseContext);
    assertEquals("Get the wrong wsdl opertion name", "{http://apache.org/hello_world_soap_http}greetMe", responseContext.get("javax.xml.ws.wsdl.operation").toString());
    assertEquals("reply body on Camel", "Hello " + TEST_MESSAGE, result);
    
    // check the other camel header copying
    String fileName = out.getHeader(Exchange.FILE_NAME, String.class);
    assertEquals("Should get the file name from out message header", "testFile", fileName);
}
 
Example 24
Project: Camel   File: CxfMessageHeadersRelayTest.java   View source code 6 votes vote down vote up
protected void doTestOutOutOfBandHeaderCamelTemplate(String producerUri) throws Exception {
    // START SNIPPET: sending
    Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
    final List<Object> params = new ArrayList<Object>();
    Me me = new Me();
    me.setFirstName("john");
    me.setLastName("Doh");

    params.add(me);
    senderExchange.getIn().setBody(params);
    senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "outOutOfBandHeader");

    Exchange exchange = template.send(producerUri, senderExchange);

    org.apache.camel.Message out = exchange.getOut();
    MessageContentsList result = (MessageContentsList)out.getBody();
    assertTrue("Expected the out of band header to propagate but it didn't", 
               result.get(0) != null && ((Me)result.get(0)).getFirstName().equals("pass"));
    Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
    assertNotNull(responseContext);
    validateReturnedOutOfBandHeader(responseContext);
}
 
Example 25
Project: Camel   File: CxfProducerRouterTest.java   View source code 6 votes vote down vote up
@Test
public void testInvokingSimpleServerWithParams() throws Exception {
 // START SNIPPET: sending
    Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
    final List<String> params = new ArrayList<String>();
    // Prepare the request message for the camel-cxf procedure
    params.add(TEST_MESSAGE);
    senderExchange.getIn().setBody(params);
    senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION);

    Exchange exchange = template.send("direct:EndpointA", senderExchange);

    org.apache.camel.Message out = exchange.getOut();
    // The response message's body is an MessageContentsList which first element is the return value of the operation,
    // If there are some holder parameters, the holder parameter will be filled in the reset of List.
    // The result will be extract from the MessageContentsList with the String class type
    MessageContentsList result = (MessageContentsList)out.getBody();
    LOG.info("Received output text: " + result.get(0));
    Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
    assertNotNull(responseContext);
    assertEquals("We should get the response context here", "UTF-8", responseContext.get(org.apache.cxf.message.Message.ENCODING));
    assertEquals("Reply body on Camel is wrong", "echo " + TEST_MESSAGE, result.get(0));
 // END SNIPPET: sending
}
 
Example 26
Project: EatDubbo   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }
 
Example 27
Project: dubbo2   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }
 
Example 28
Project: mpay24-java   File: SoapCommunication.java   View source code 5 votes vote down vote up
private ETP getSoapClientProxy() {
	QName qname = new QName("https://www.mpay24.com/soap/etp/1.5/ETP.wsdl", "ETP");
	ETP_Service etpService = getEtpService(qname);
	ETP etp = etpService.getETP();
	setBindingParameter(etp);
	Client cxfClient = getSoapClient(etp);

	if (mode == Environment.INTEGRATION)
		disableCertificateChecks(cxfClient);
	
	return etp;
}
 
Example 29
Project: mpay24-java   File: SoapCommunication.java   View source code 5 votes vote down vote up
private Client getSoapClient(ETP etp) {
		Client cxfClient = ClientProxy.getClient(etp);
		LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
		loggingOutInterceptor.setPrettyLogging(true);
//      Uncomment to log the SOAP message (including the basic authentication headers) - not for production!
//		cxfClient.getOutInterceptors().add(loggingOutInterceptor);
		return cxfClient;
	}
 
Example 30
Project: Equella   File: EquellaRepoServiceImpl.java   View source code 5 votes vote down vote up
protected SoapHarvesterService getNewClient(String url, String sharedId, String sharedValue, String username)
{
	try
	{
		final URL endpointUrl = new URL(new URL(url), HARVESTER_ENDPOINT);

		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
		Bus bus = new ExtensionManagerBus(null, null, Bus.class.getClassLoader());
		factory.setBus(bus);
		factory.setServiceClass(SoapHarvesterService.class);
		factory.setServiceName(
			new QName("http://soap.harvester.core.tle.com", SoapHarvesterService.class.getSimpleName()));
		factory.setAddress(endpointUrl.toString());
		factory.setDataBinding(new AegisDatabinding());
		List<AbstractServiceConfiguration> configs = factory.getServiceFactory().getServiceConfigurations();
		configs.add(0, new XFireReturnTypeConfig());
		SoapHarvesterService soapClient = (SoapHarvesterService) factory.create();
		Client client = ClientProxy.getClient(soapClient);
		client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
		HTTPClientPolicy policy = new HTTPClientPolicy();
		policy.setReceiveTimeout(600000);
		policy.setAllowChunking(false);
		HTTPConduit conduit = (HTTPConduit) client.getConduit();
		// Works?
		// conduit.getTlsClientParameters().setSSLSocketFactory(BlindSSLSocketFactory.getDefaultSSL());
		conduit.setClient(policy);

		soapClient.loginWithToken(TokenGenerator.createSecureToken(username, sharedId, sharedValue, null));
		return soapClient;
	}
	catch( Exception x )
	{
		LOGGER.error("Error connecting to remote EQUELLA server", x);
		throw new RuntimeException(
			CurrentLocale.get("com.tle.core.remoterepo.equella.error.communication", x.getMessage()));
	}
}
 
Example 31
Project: cxf-jaxws   File: ClientConfig.java   View source code 5 votes vote down vote up
@Bean
public HTTPConduit ticketAgentConduit()
    throws NoSuchAlgorithmException, KeyStoreException,
    CertificateException, IOException {
  Client client = ClientProxy.getClient(ticketAgentProxy());

  HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
  httpConduit.setTlsClientParameters(tlsClientParameters());

  return httpConduit;
}
 
Example 32
Project: dubbox-hystrix   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }
 
Example 33
Project: uavstack   File: CECXFClient.java   View source code 5 votes vote down vote up
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);
    }
 
Example 34
Project: dubbocloud   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }
 
Example 35
Project: helium   File: WsClientUtils.java   View source code 5 votes vote down vote up
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;
}
 
Example 36
Project: dubbos   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }
 
Example 37
Project: OSCAR-ConCert   File: CxfClientUtilsOld.java   View source code 5 votes vote down vote up
public static <T extends CallbackHandler> void configureWSSecurity(Object wsPort, String user, T passwordCallbackInstance)
{
	Client cxfClient = ClientProxy.getClient(wsPort);
	Endpoint cxfEndpoint = cxfClient.getEndpoint();

	Map<String, Object> outProps = new HashMap<String, Object>();
	outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);

	outProps.put(WSHandlerConstants.USER, user);
	outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
	outProps.put(WSHandlerConstants.PW_CALLBACK_REF, passwordCallbackInstance);

	WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
	cxfEndpoint.getOutInterceptors().add(wssOut);
}
 
Example 38
Project: OSCAR-ConCert   File: MyOscarServerWebServicesManager.java   View source code 5 votes vote down vote up
public static void configureClientConnection(Object wsPort)
{
	Client cxfClient = ClientProxy.getClient(wsPort);
	HTTPConduit httpConduit = (HTTPConduit) cxfClient.getConduit();

	configureSsl(httpConduit);
	CxfClientUtils.configureTimeout(httpConduit);

	configureGzip(cxfClient);
}
 
Example 39
Project: dubbo-comments   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }
 
Example 40
Project: dubbox   File: WebServiceProtocol.java   View source code 5 votes vote down vote up
@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;
  }