Search in sources :

Example 91 with LoggingInInterceptor

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

the class StaxToDOMRoundTripTest method testSignaturePKI.

@Test
public void testSignaturePKI() throws Exception {
    // Create + configure service
    Service service = createService();
    Map<String, Object> inProperties = new HashMap<>();
    inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
    inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new KeystorePasswordCallback());
    inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "cxfca.properties");
    WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
    service.getInInterceptors().add(inInterceptor);
    // Create + configure client
    Echo echo = createClientProxy();
    Client client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    WSSSecurityProperties properties = new WSSSecurityProperties();
    List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
    actions.add(XMLSecurityConstants.SIGNATURE);
    properties.setActions(actions);
    properties.setSignatureUser("alice");
    Properties cryptoProperties = CryptoFactory.getProperties("alice.properties", this.getClass().getClassLoader());
    properties.setSignatureCryptoProperties(cryptoProperties);
    properties.setCallbackHandler(new KeystorePasswordCallback());
    properties.setUseSingleCert(true);
    properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE);
    WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
    client.getOutInterceptors().add(ohandler);
    assertEquals("test", echo.echo("test"));
}
Also used : WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) WSSConstants(org.apache.wss4j.stax.ext.WSSConstants) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) Properties(java.util.Properties) WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 92 with LoggingInInterceptor

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

the class JaxWsDynamicClientTest method testArgfiles.

@Test
public void testArgfiles() throws Exception {
    System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
    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 93 with LoggingInInterceptor

use of org.apache.cxf.ext.logging.LoggingInInterceptor 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 94 with LoggingInInterceptor

use of org.apache.cxf.ext.logging.LoggingInInterceptor 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 LoggingInInterceptor

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

the class ClientServerRPCLitTest method testBasicConnection.

@Test
public void testBasicConnection() throws Exception {
    SOAPServiceRPCLit service = new SOAPServiceRPCLit();
    assertNotNull(service);
    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    try {
        GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
        ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
        updateAddressPort(greeter, PORT);
        for (int idx = 0; idx < 1; idx++) {
            String greeting = greeter.greetMe("Milestone-" + idx);
            assertNotNull("no response received from service", greeting);
            String exResponse = response1 + idx;
            assertEquals(exResponse, greeting);
            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response2, reply);
            try {
                greeter.greetMe("return null");
                fail("should catch WebServiceException");
            } catch (WebServiceException e) {
            // do nothing
            } catch (Exception e) {
                fail("should catch WebServiceException");
                throw e;
            }
            try {
                greeter.greetMe(null);
                fail("should catch WebServiceException");
            } catch (WebServiceException e) {
            // do nothing
            } catch (Exception e) {
                fail("should catch WebServiceException");
                throw e;
            }
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPServiceRPCLit(org.apache.hello_world_rpclit.SOAPServiceRPCLit) GreeterRPCLit(org.apache.hello_world_rpclit.GreeterRPCLit) WebServiceException(javax.xml.ws.WebServiceException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Endpoint(javax.xml.ws.Endpoint) UnmarshalException(javax.xml.bind.UnmarshalException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Aggregations

LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)220 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)207 Test (org.junit.Test)177 Service (org.apache.cxf.service.Service)138 Client (org.apache.cxf.endpoint.Client)135 HashMap (java.util.HashMap)100 WSSSecurityProperties (org.apache.wss4j.stax.ext.WSSSecurityProperties)89 ArrayList (java.util.ArrayList)67 Properties (java.util.Properties)65 WSSConstants (org.apache.wss4j.stax.ext.WSSConstants)61 QName (javax.xml.namespace.QName)32 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)23 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)19 AbstractSecurityTest (org.apache.cxf.ws.security.wss4j.AbstractSecurityTest)18 Echo (org.apache.cxf.ws.security.wss4j.Echo)18 URL (java.net.URL)14 Bus (org.apache.cxf.Bus)14 Server (org.apache.cxf.endpoint.Server)14 Greeter (org.apache.cxf.greeter_control.Greeter)14 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)13