Java Code Examples for org.apache.cxf.frontend.ClientProxy

The following are top voted examples for showing how to use org.apache.cxf.frontend.ClientProxy. 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   Source Code and License 9 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: Equella   File: SoapHelper.java   Source Code and License 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 6
Project: uavstack   File: WSService.java   Source Code and License 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 7
Project: OSCAR-ConCert   File: CxfClientUtilsOld.java   Source Code and License 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 8
Project: eSDK_IVS_Java   File: ClientProvider.java   Source Code and License 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 9
Project: eSDK_IVS_Java   File: ClientProvider.java   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: jbossws-cxf   File: HelloDigestTestCase.java   Source Code and License 6 votes vote down vote up
@Test
@RunAsClient
public void testDigest() throws Exception
{
   final Bus bus = BusFactory.newInstance().createBus();
   BusFactory.setThreadDefaultBus(bus);
   try {
      QName serviceName = new QName("http://jboss.org/http/security", "HelloService");
      URL wsdlURL = getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
      Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
      Hello proxy = (Hello)service.getPort(Hello.class);
      ((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toString());
      ((BindingProvider)proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jbossws");
      ((BindingProvider)proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "jbossws");
      HTTPConduit cond = (HTTPConduit)ClientProxy.getClient(proxy).getConduit();
      cond.setAuthSupplier(new DigestAuthSupplier());
      int result = proxy.helloRequest("number");
      assertEquals(100, result);
   } finally {
      bus.shutdown(true);
   }
}
 
Example 22
Project: jbossws-cxf   File: HelloDigestTestCase.java   Source Code and License 6 votes vote down vote up
@Test
@RunAsClient
public void testDigestAuthFail() throws Exception
{
   final Bus bus = BusFactory.newInstance().createBus();
   BusFactory.setThreadDefaultBus(bus);
   try {
      QName serviceName = new QName("http://jboss.org/http/security", "HelloService");
      URL wsdlURL = getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
      Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
      Hello proxy = (Hello)service.getPort(Hello.class);
      ((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toString());
      ((BindingProvider)proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jbossws");
      ((BindingProvider)proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "wrongPwd");
      HTTPConduit cond = (HTTPConduit)ClientProxy.getClient(proxy).getConduit();
      cond.setAuthSupplier(new DigestAuthSupplier());
      try {
         proxy.helloRequest("number");
         fail("Authorization exception expected!");
      } catch (Exception e) {
         assertTrue(e.getCause().getMessage().contains("Authorization"));
      }
   } finally {
      bus.shutdown(true);
   }
}
 
Example 23
Project: jbossws-cxf   File: Helper.java   Source Code and License 6 votes vote down vote up
public boolean testGZIPServerSideOnlyInterceptorOnClient() throws Exception
{
   Bus bus = BusFactory.newInstance().createBus();
   try
   {
      BusFactory.setThreadDefaultBus(bus);
      
      HelloWorld port = getPort();
      Client client = ClientProxy.getClient(port);
      HTTPConduit conduit = (HTTPConduit)client.getConduit();
      HTTPClientPolicy policy = conduit.getClient();
      //enable Accept gzip, otherwise the server will not try to reply using gzip
      policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
      //add interceptor for decoding gzip message
      
      ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
      configurer.setConfigProperties(port, "jaxws-client-config.xml", "Interceptor Client Config");
      
      return ("foo".equals(port.echo("foo")));
   }
   finally
   {
      bus.shutdown(true);
   }
}
 
Example 24
Project: jbossws-cxf   File: Helper.java   Source Code and License 6 votes vote down vote up
public boolean testFailureGZIPServerSideOnlyInterceptorOnClient() throws Exception
{
   HelloWorld port = getPort();
   Client client = ClientProxy.getClient(port);
   HTTPConduit conduit = (HTTPConduit)client.getConduit();
   HTTPClientPolicy policy = conduit.getClient();
   //enable Accept gzip, otherwise the server will not try to reply using gzip
   policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
   try
   {
      port.echo("foo");
      return false;
   }
   catch (Exception e)
   {
      //expected exception, as the client is not able to decode gzip message
      return true;
   }
}
 
Example 25
Project: jbossws-cxf   File: Helper.java   Source Code and License 6 votes vote down vote up
public boolean testGZIPServerSideOnlyInterceptorOnClient() throws Exception
{
   Bus bus = BusFactory.newInstance().createBus();
   try
   {
      BusFactory.setThreadDefaultBus(bus);
      
      HelloWorld port = getPort();
      Client client = ClientProxy.getClient(port);
      HTTPConduit conduit = (HTTPConduit)client.getConduit();
      HTTPClientPolicy policy = conduit.getClient();
      //enable Accept gzip, otherwise the server will not try to reply using gzip
      policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
      //add interceptor for decoding gzip message
      client.getInInterceptors().add(new GZIPEnforcingInInterceptor());
      return ("foo".equals(port.echo("foo")));
   }
   finally
   {
      bus.shutdown(true);
   }
}
 
Example 26
Project: jbossws-cxf   File: Helper.java   Source Code and License 6 votes vote down vote up
public boolean testFailureGZIPServerSideOnlyInterceptorOnClient() throws Exception
{
   HelloWorld port = getPort();
   Client client = ClientProxy.getClient(port);
   HTTPConduit conduit = (HTTPConduit)client.getConduit();
   HTTPClientPolicy policy = conduit.getClient();
   //enable Accept gzip, otherwise the server will not try to reply using gzip
   policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
   try
   {
      port.echo("foo");
      return false;
   }
   catch (Exception e)
   {
      //expected exception, as the client is not able to decode gzip message
      return true;
   }
}
 
Example 27
Project: jbossws-cxf   File: Helper.java   Source Code and License 6 votes vote down vote up
public boolean testConfigurationChange() throws Exception
{
   Service service = Service.create(new URL(address + "?wsdl"), serviceName);
   Endpoint port = (Endpoint)service.getPort(Endpoint.class);
   org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(port).getEndpoint();
   assert(ep.get("propA") == null);
   assert(ep.get("propB") == null);
   ep.put("propZ", "valueZ");
   
   ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
   configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Custom Client Config");

   if (!ep.get("propA").equals("fileValueA") || !ep.get("propB").equals("fileValueB") || !ep.get("propZ").equals("valueZ")) {
      return false;
   }
   
   port.echo("Kermit");
   
   configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Another Client Config");
   
   return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
}
 
Example 28
Project: jbossws-cxf   File: Helper.java   Source Code and License 6 votes vote down vote up
public boolean testCustomClientConfigurationUsingFeature() throws Exception
{
   final URL wsdlURL = new URL(address + "?wsdl");
   final String testConfigName = "MyTestConfig";
   try
   {
      //-- add test client configuration
      TestUtils.addTestCaseClientConfiguration(testConfigName);
      // --
      
      Service service = Service.create(wsdlURL, serviceName);
      Endpoint port = (Endpoint)service.getPort(Endpoint.class, new ClientConfigFeature(null, testConfigName, true));
      org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(port).getEndpoint();
      ep.put("propZ", "valueZ");
      
      return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
   }
   finally
   {
      // -- remove test client configuration --
      TestUtils.removeTestCaseClientConfiguration(testConfigName);
      // --
   }
}
 
Example 29
Project: jbossws-cxf   File: HelperUsignThreadLocal.java   Source Code and License 6 votes vote down vote up
private static ThreadLocal<HelloWs> createPortThreadLocal(final URL wsdlURL, final WebServiceFeature feature, final BusCounter busCounter)
{
   return new ThreadLocal<HelloWs>()
   {
      @Override
      protected HelloWs initialValue()
      {
         QName qname = new QName("http://hello/test", "HelloService");
         Service service = feature != null ? Service.create(wsdlURL, qname, feature) : Service.create(wsdlURL, qname);
         HelloWs helloPort = service.getPort(HelloWs.class);
         org.apache.cxf.endpoint.Client cxfClient = ClientProxy.getClient(helloPort);
         busCounter.count(cxfClient.getBus());
         return helloPort;
      }
   };
}
 
Example 30
Project: jbossws-cxf   File: ProviderImpl.java   Source Code and License 6 votes vote down vote up
protected void setupClient(Object obj, Class<?> seiClass, WebServiceFeature... features) {
   Binding binding = ((BindingProvider)obj).getBinding();
   Client client = obj instanceof DispatchImpl<?> ? ((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj);
   ClientConfig config = readConfig(seiClass);
   if (config != null) {
      CXFClientConfigurer helper = new CXFClientConfigurer();
      helper.setupConfigHandlers(binding, config);
      helper.setConfigProperties(client, config.getProperties());
   }
   client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add this *after* the config has been set (if any)!
   if (features != null) {
      for (WebServiceFeature f : features) {
         if (f instanceof AbstractClientFeature) {
            ((AbstractClientFeature)f).initialize(obj);
         }
      }
   }
}
 
Example 31
Project: jbossws-cxf   File: CXFClientConfigurer.java   Source Code and License 6 votes vote down vote up
protected void setConfigProperties(Object client, ClientConfig config) {
   Client cxfClient;
   if (client instanceof DispatchImpl<?>) {
      cxfClient = ((DispatchImpl<?>)client).getClient();
   } else {
      cxfClient = ClientProxy.getClient(client);
   }
   cleanupPreviousProps(cxfClient);
   Map<String, String> props = config.getProperties();
   if (props != null && !props.isEmpty()) {
      savePropList(cxfClient, props);
   }
   setConfigProperties(cxfClient, props);
   
   //config jaspi
   JASPIAuthenticationProvider japsiProvider = (JASPIAuthenticationProvider) ServiceLoader.loadService(
         JASPIAuthenticationProvider.class.getName(), null, ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
   if (japsiProvider != null)
   {
      japsiProvider.enableClientAuthentication(cxfClient, props);
   }
   else
   {
      Loggers.SECURITY_LOGGER.cannotFindJaspiClasses();
   }
}
 
Example 32
Project: techytax-zk   File: SecureConnectionHelper.java   Source Code and License 6 votes vote down vote up
public static void setupTLS(Object port, Properties keyProperties, Properties trustProperties) throws FileNotFoundException, IOException,
		GeneralSecurityException {

	HTTPConduit httpConduit = (HTTPConduit) ClientProxy.getClient(port).getConduit();

	TLSClientParameters tlsCP = new TLSClientParameters();
	String keyPassword = keyProperties.getProperty("org.apache.ws.security.crypto.merlin.keystore.password");
	KeyStore keyStore = KeyStore.getInstance(keyProperties.getProperty("org.apache.ws.security.crypto.merlin.keystore.type"));
	String keyStoreLoc = keyProperties.getProperty("org.apache.ws.security.crypto.merlin.file");
	keyStore.load(new FileInputStream(keyStoreLoc), keyPassword.toCharArray());
	KeyManager[] myKeyManagers = getKeyManagers(keyStore, keyPassword);
	tlsCP.setKeyManagers(myKeyManagers);

	KeyStore trustStore = KeyStore.getInstance(trustProperties.getProperty("org.apache.ws.security.crypto.merlin.keystore.type"));
	keyPassword = trustProperties.getProperty("org.apache.ws.security.crypto.merlin.keystore.password");
	String trustStoreLoc = trustProperties.getProperty("org.apache.ws.security.crypto.merlin.file");
	trustStore.load(new FileInputStream(trustStoreLoc), keyPassword.toCharArray());
	TrustManager[] myTrustStoreKeyManagers = getTrustManagers(trustStore);
	tlsCP.setTrustManagers(myTrustStoreKeyManagers);

	httpConduit.setTlsClientParameters(tlsCP);

}
 
Example 33
Project: wsman   File: CXFWSManClient.java   Source Code and License 6 votes vote down vote up
public EnumerationOperations getEnumerator(String resourceUri) {
    // Relocate the Filter element to the WS-Man namespace.
    // Our WSDLs generate it one package but the servers expect it to be in the other
    Map<String, String> outTransformMap = Maps.newHashMap();
    outTransformMap.put("{" + WSManConstants.XML_NS_WS_2004_09_ENUMERATION + "}Filter",
            "{" + WSManConstants.XML_NS_DMTF_WSMAN_V1 + "}Filter");

    // Create the proxy
    EnumerationOperations enumerator = createProxyFor(EnumerationOperations.class, outTransformMap, Maps.newHashMap());
    Client cxfClient = ClientProxy.getClient(enumerator);

    // Add the WS-Man ResourceURI to the SOAP header
    WSManHeaderInterceptor interceptor = new WSManHeaderInterceptor(resourceUri);
    cxfClient.getOutInterceptors().add(interceptor);

    return enumerator;
}
 
Example 34
Project: wsman   File: CXFWSManClient.java   Source Code and License 6 votes vote down vote up
public TransferOperations getTransferer(String resourceUri, String elementType, Map<String, String> selectors) {
    // Modify the incoming response to use a generic element instead of the one provided
    // The JAX-WS implementation excepts the element types to match those in specified
    // by the annotated interface, but these are subject to change for every call we make
    Map<String, String> inTransformMap = Maps.newHashMap();
    inTransformMap.put(String.format("{%s}%s", resourceUri, elementType),
            "{" + WSManConstants.XML_NS_WS_2004_09_TRANSFER + "}TransferElement");

    // Create the proxy
    TransferOperations transferer = createProxyFor(TransferOperations.class, Maps.newHashMap(), inTransformMap);
    Client cxfClient = ClientProxy.getClient(transferer);

    // Add the WS-Man ResourceURI and SelectorSet to the SOAP header
    WSManHeaderInterceptor interceptor = new WSManHeaderInterceptor(resourceUri, selectors);
    cxfClient.getOutInterceptors().add(interceptor);

    return transferer;
}
 
Example 35
Project: esdk_cloud_fm_r3_native_java   File: ClientProvider.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static Object configureHttp(Object service, Class clz, ClientProviderBean bean)
{
    Client client = ClientProxy.getClient(service);
    addInterceptor(client, bean);
    
    HTTPConduit http = (HTTPConduit)client.getConduit();
    if (null == http)
    {
        return null;
    }
    configHttpClientPolicy(http, bean);
    
    FMCacheHolder.saveService(clz, bean, service);
    return service;
}
 
Example 36
Project: juddi   File: SAPRegistryJAXWSTransport.java   Source Code and License 6 votes vote down vote up
public UDDIInquiryPortType getUDDIInquiryService(String endpointURL) throws TransportException {

		if (inquiryService==null) {
			try {
				if (endpointURL==null)  {
					UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName);
					endpointURL = manager.getClientConfig().getUDDINode(nodeName).getInquiryUrl();
				}
				UDDIService service = new UDDIService();
				inquiryService = service.getUDDIInquiryPort();
				Map<String, Object> requestContext = ((BindingProvider) inquiryService).getRequestContext();
				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
				setCredentials(requestContext);
				
				XMLDeclarationWritingInterceptor xmldwi = new XMLDeclarationWritingInterceptor();				
				Client cxfClient = ClientProxy.getClient(inquiryService);
				cxfClient.getInInterceptors().add(xmldwi);
			} catch (Exception e) {
				throw new TransportException(e.getMessage(), e);
			}
		}
		return inquiryService;
	}
 
Example 37
Project: juddi   File: SAPRegistryJAXWSTransport.java   Source Code and License 6 votes vote down vote up
public UDDISecurityPortType getUDDISecurityService(String endpointURL) throws TransportException {

		if (securityService==null) {
			try {
				if (endpointURL==null)  {
					UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName);
					endpointURL = manager.getClientConfig().getUDDINode(nodeName).getSecurityUrl();
				}
				UDDIService service = new UDDIService();
				securityService = service.getUDDISecurityPort();
				Map<String, Object> requestContext = ((BindingProvider) securityService).getRequestContext();
				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
				setCredentials(requestContext);

				XMLDeclarationWritingInterceptor xmldwi = new XMLDeclarationWritingInterceptor();				
				Client cxfClient = ClientProxy.getClient(securityService);
				cxfClient.getInInterceptors().add(xmldwi);

			} catch (Exception e) {
				throw new TransportException(e.getMessage(), e);
			}
		}
		return securityService;
	}
 
Example 38
Project: juddi   File: SAPRegistryJAXWSTransport.java   Source Code and License 6 votes vote down vote up
public UDDIPublicationPortType getUDDIPublishService(String endpointURL) throws TransportException {

		if (publishService==null) {
			try {
				if (endpointURL==null)  {
					UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName);
					endpointURL = manager.getClientConfig().getUDDINode(nodeName).getPublishUrl();
				}
				UDDIService service = new UDDIService();
				publishService = service.getUDDIPublicationPort();
				Map<String, Object> requestContext = ((BindingProvider) publishService).getRequestContext();
				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
				setCredentials(requestContext);

				XMLDeclarationWritingInterceptor xmldwi = new XMLDeclarationWritingInterceptor();				
				Client cxfClient = ClientProxy.getClient(publishService);
				cxfClient.getInInterceptors().add(xmldwi);

			} catch (Exception e) {
				throw new TransportException(e.getMessage(), e);
			}
		}
		return publishService;
	}
 
Example 39
Project: juddi   File: SAPRegistryJAXWSTransport.java   Source Code and License 6 votes vote down vote up
public UDDISubscriptionPortType getUDDISubscriptionService(String endpointURL) throws TransportException {

		if (subscriptionService==null) {
			try {
				if (endpointURL==null)  {
					UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName);
					endpointURL = manager.getClientConfig().getUDDINode(nodeName).getSubscriptionUrl();
				}
				UDDIService service = new UDDIService();
				subscriptionService = service.getUDDISubscriptionPort();
				Map<String, Object> requestContext = ((BindingProvider) subscriptionService).getRequestContext();
				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
				setCredentials(requestContext);

				XMLDeclarationWritingInterceptor xmldwi = new XMLDeclarationWritingInterceptor();				
				Client cxfClient = ClientProxy.getClient(subscriptionService);
				cxfClient.getInInterceptors().add(xmldwi);

			} catch (Exception e) {
				throw new TransportException(e.getMessage(), e);
			}
		}
		return subscriptionService;
	}
 
Example 40
Project: juddi   File: SAPRegistryJAXWSTransport.java   Source Code and License 6 votes vote down vote up
public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(String endpointURL) throws TransportException {
	if (subscriptionListenerService == null) {
		try {
			if (endpointURL==null)  {
				UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName);
				endpointURL = manager.getClientConfig().getUDDINode(nodeName).getSubscriptionListenerUrl();
			}
			UDDIService service = new UDDIService();
			subscriptionListenerService = service.getUDDISubscriptionListenerPort();
			Map<String, Object> requestContext = ((BindingProvider) subscriptionListenerService).getRequestContext();
			requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
			setCredentials(requestContext);

			XMLDeclarationWritingInterceptor xmldwi = new XMLDeclarationWritingInterceptor();				
			Client cxfClient = ClientProxy.getClient(subscriptionListenerService);
			cxfClient.getInInterceptors().add(xmldwi);

		} catch (Exception e) {
			throw new TransportException(e.getMessage(), e);
		}
	}
	return subscriptionListenerService;
}