Search in sources :

Example 91 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class JaxWsDynamicClientTest method testArrayList.

@Test
public void testArrayList() throws Exception {
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl"));
    String[] values = new String[] { "foobar", "something" };
    List<String> list = Arrays.asList(values);
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.invoke("init", list);
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) Test(org.junit.Test)

Example 92 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class JAXRSKerberosBookTest method testGetBookWithInterceptor.

@Test
public void testGetBookWithInterceptor() throws Exception {
    if (!runTests) {
        return;
    }
    WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/123");
    KerberosAuthOutInterceptor kbInterceptor = new KerberosAuthOutInterceptor();
    AuthorizationPolicy policy = new AuthorizationPolicy();
    policy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_NEGOTIATE);
    policy.setAuthorization("alice");
    policy.setUserName("alice");
    policy.setPassword("alice");
    kbInterceptor.setPolicy(policy);
    kbInterceptor.setCredDelegation(true);
    WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor());
    WebClient.getConfig(wc).getOutInterceptors().add(kbInterceptor);
    // Required so as to get it working with our KDC
    kbInterceptor.setServicePrincipalName("bob@service.ws.apache.org");
    kbInterceptor.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE);
    Book b = wc.get(Book.class);
    Assert.assertEquals(b.getId(), 123);
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) KerberosAuthOutInterceptor(org.apache.cxf.jaxrs.security.KerberosAuthOutInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 93 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class ClientServerSwaTest method testSwa.

@Test
public void testSwa() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setWsdlLocation("classpath:/swa-mime_jms.wsdl");
    factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
    factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
    factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceJMSPort"));
    factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    SwAService port = factory.create(SwAService.class);
    Holder<String> textHolder = new Holder<String>();
    Holder<DataHandler> data = new Holder<DataHandler>();
    ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
    DataHandler handler = new DataHandler(source);
    data.value = handler;
    textHolder.value = "Hi";
    port.echoData(textHolder, data);
    InputStream bis = null;
    bis = data.value.getDataSource().getInputStream();
    byte[] b = new byte[10];
    bis.read(b, 0, 10);
    String string = IOUtils.newStringFromBytes(b);
    assertEquals("testfoobar", string);
    assertEquals("Hi", textHolder.value);
    if (port instanceof Closeable) {
        ((Closeable) port).close();
    }
}
Also used : QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) Closeable(java.io.Closeable) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) DataHandler(javax.activation.DataHandler) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Example 94 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class CXF6655Test method testConnectionWithProxy.

@Test
public void testConnectionWithProxy() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService");
    HelloService service = new HelloService(null, serviceName);
    assertNotNull(service);
    Hello hello = service.getHelloPort();
    Client client = ClientProxy.getClient(hello);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    HTTPConduit http = (HTTPConduit) client.getConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setAllowChunking(false);
    httpClientPolicy.setReceiveTimeout(0);
    httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
    httpClientPolicy.setProxyServer("localhost");
    httpClientPolicy.setProxyServerPort(PROXY_PORT);
    http.setClient(httpClientPolicy);
    ((BindingProvider) hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello");
    assertEquals("getSayHi", hello.sayHi("SayHi"));
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) QName(javax.xml.namespace.QName) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 95 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class DispatchClientServerWithMalformedResponseTest method setUp.

@org.junit.Before
public void setUp() {
    BusFactory.setThreadDefaultBus(getStaticBus());
    BusFactory.getThreadDefaultBus().getOutInterceptors().add(new LoggingOutInterceptor());
    BusFactory.getThreadDefaultBus().getInInterceptors().add(new LoggingInInterceptor());
    BusFactory.getThreadDefaultBus().getInInterceptors().add(new MalformedResponseInterceptor());
}
Also used : LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor)

Aggregations

LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)224 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)207 Test (org.junit.Test)175 Service (org.apache.cxf.service.Service)138 Client (org.apache.cxf.endpoint.Client)135 HashMap (java.util.HashMap)101 WSSSecurityProperties (org.apache.wss4j.stax.ext.WSSSecurityProperties)89 ArrayList (java.util.ArrayList)68 Properties (java.util.Properties)65 WSSConstants (org.apache.wss4j.stax.ext.WSSConstants)61 QName (javax.xml.namespace.QName)35 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)22 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)21 AbstractSecurityTest (org.apache.cxf.ws.security.wss4j.AbstractSecurityTest)18 Echo (org.apache.cxf.ws.security.wss4j.Echo)18 Bus (org.apache.cxf.Bus)16 URL (java.net.URL)15 Server (org.apache.cxf.endpoint.Server)14 Greeter (org.apache.cxf.greeter_control.Greeter)14 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)13