Search in sources :

Example 1 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project camel by apache.

the class CXFWsdlOnlyPayloadModeNoSpringTest method testRoutes.

@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);
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Example 2 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project camel by apache.

the class CxfConsumerPayloadFaultCauseEnabledTest method testInvokingFromCxfClient.

@Test
public void testInvokingFromCxfClient() throws Exception {
    this.getCamelContextService();
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
    Person client = ss.getSoap();
    Client c = ClientProxy.getClient(client);
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
    Holder<String> personId = new Holder<String>();
    personId.value = "";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    try {
        client.getPerson(personId, ssn, name);
        fail("SOAPFault expected!");
    } catch (Exception e) {
        assertTrue(e instanceof SOAPFaultException);
        SOAPFault fault = ((SOAPFaultException) e).getFault();
        assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
    }
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFault(javax.xml.soap.SOAPFault) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 3 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project camel by apache.

the class CxfConsumerPayloadFaultTest method testInvokingFromCxfClient.

@Test
public void testInvokingFromCxfClient() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
    Person client = ss.getSoap();
    Client c = ClientProxy.getClient(client);
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
    Holder<String> personId = new Holder<String>();
    personId.value = "";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    Throwable t = null;
    try {
        client.getPerson(personId, ssn, name);
        fail("expect UnknownPersonFault");
    } catch (UnknownPersonFault e) {
        t = e;
        assertEquals("Get the wrong fault detail", "", e.getFaultInfo().getPersonId());
    }
    assertNotNull(t);
    assertTrue(t instanceof UnknownPersonFault);
}
Also used : UnknownPersonFault(org.apache.camel.wsdl_first.UnknownPersonFault) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Example 4 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project camel by apache.

the class CxfRsProducerClientFactoryBeanTest method testProducerInOutInterceptors.

@Test
public void testProducerInOutInterceptors() throws Exception {
    CxfRsEndpoint e = context.getEndpoint("cxfrs://bean://rsClientHttpInterceptors", CxfRsEndpoint.class);
    CxfRsProducer p = new CxfRsProducer(e);
    CxfRsProducer.ClientFactoryBeanCache cache = p.getClientFactoryBeanCache();
    JAXRSClientFactoryBean bean = cache.get("http://localhost:8080/CxfRsProducerClientFactoryBeanInterceptors/");
    List<Interceptor<?>> ins = bean.getInInterceptors();
    assertEquals(1, ins.size());
    assertTrue(ins.get(0) instanceof LoggingInInterceptor);
    List<Interceptor<?>> outs = bean.getOutInterceptors();
    assertEquals(1, outs.size());
    assertTrue(outs.get(0) instanceof LoggingOutInterceptor);
}
Also used : JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Test(org.junit.Test)

Example 5 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project qi4j-sdk by Qi4j.

the class HelloClient method main.

public static void main(String[] args) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(HelloWorld.class);
    factory.setAddress("http://localhost:9001/helloWorld");
    HelloWorld client = (HelloWorld) factory.create();
    String reply = client.sayHi("World");
    System.out.println("Server said: " + reply);
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor)

Aggregations

LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)18 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)17 Client (org.apache.cxf.endpoint.Client)6 Test (org.junit.Test)6 URL (java.net.URL)4 BindingProvider (javax.xml.ws.BindingProvider)4 Holder (javax.xml.ws.Holder)4 Person (org.apache.camel.wsdl_first.Person)4 PersonService (org.apache.camel.wsdl_first.PersonService)4 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)4 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)3 ModelService (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService)3 HashMap (java.util.HashMap)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 UnknownPersonFault (org.apache.camel.wsdl_first.UnknownPersonFault)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 ClientPasswordHandler (com.evolveum.midpoint.cli.ninja.util.ClientPasswordHandler)1 SHSIMPINC (com.ibm.maximo.wsdl.shsimpinc.SHSIMPINC)1 IOException (java.io.IOException)1