Search in sources :

Example 1 with LoggingOutInterceptor

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

the class CodeFirstTest method testCXF2766.

@Test
public void testCXF2766() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(CXF2766.class);
    factory.setServiceBean(new CXF2766Impl());
    factory.setAddress("local://localhost/testcxf2766");
    Server server = factory.create();
    server.getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
    server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
    Document doc = getWSDLDocument(server);
    // org.apache.cxf.helpers.XMLUtils.printDOM(doc);
    assertValid("//wsdl:message[@name='doReturnResponse']/wsdl:part[@name='returnResponse']", doc);
    QName serviceName = new QName("http://cxf.apache.org/service.wsdl", "BareService");
    QName portName = new QName("http://cxf.apache.org/service.wsdl", "BarePort");
    ServiceImpl service = new ServiceImpl(getBus(), (URL) null, serviceName, null);
    service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost/testcxf2766");
    CXF2766 proxy = service.getPort(portName, CXF2766.class);
    proxy.doReturn(new ReturnRequestType());
}
Also used : Server(org.apache.cxf.endpoint.Server) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) QName(javax.xml.namespace.QName) ArrayServiceImpl(org.apache.cxf.jaxws.service.ArrayServiceImpl) FooServiceImpl(org.apache.cxf.jaxws.service.FooServiceImpl) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 2 with LoggingOutInterceptor

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

the class CodeFirstTest method testClient.

@Test
public void testClient() throws Exception {
    Hello serviceImpl = new Hello();
    try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
        ep.publish("local://localhost:9090/hello");
        QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
        QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
        // need to set the same bus with service , so use the ServiceImpl
        ServiceImpl service = new ServiceImpl(getBus(), (URL) null, serviceName, null);
        service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
        HelloInterface proxy = service.getPort(portName, HelloInterface.class, new LoggingFeature());
        Client client = ClientProxy.getClient(proxy);
        boolean found = false;
        for (Interceptor<? extends Message> i : client.getOutInterceptors()) {
            if (i instanceof LoggingOutInterceptor) {
                found = true;
            }
        }
        assertTrue(found);
        assertEquals("Get the wrong result", "hello", proxy.sayHi("hello"));
        String[] strInput = new String[2];
        strInput[0] = "Hello";
        strInput[1] = "Bonjour";
        String[] strings = proxy.getStringArray(strInput);
        assertEquals(strings.length, 2);
        assertEquals(strings[0], "HelloHello");
        assertEquals(strings[1], "BonjourBonjour");
        List<String> listInput = new ArrayList<>();
        listInput.add("Hello");
        listInput.add("Bonjour");
        List<String> list = proxy.getStringList(listInput);
        assertEquals(list.size(), 2);
        assertEquals(list.get(0), "HelloHello");
        assertEquals(list.get(1), "BonjourBonjour");
        // now the client side can't unmarshal the complex type without binding types annoutation
        List<String> result = proxy.getGreetings();
        assertEquals(2, result.size());
    }
}
Also used : QName(javax.xml.namespace.QName) ArrayServiceImpl(org.apache.cxf.jaxws.service.ArrayServiceImpl) FooServiceImpl(org.apache.cxf.jaxws.service.FooServiceImpl) ArrayList(java.util.ArrayList) Hello(org.apache.cxf.jaxws.service.Hello) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) HelloInterface(org.apache.cxf.jaxws.service.HelloInterface) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 3 with LoggingOutInterceptor

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

the class SEIWithJAXBAnnoTest method testXMLList.

@Test
public void testXMLList() throws Exception {
    AddNumbersImpl serviceImpl = new AddNumbersImpl();
    Endpoint.publish("local://localhost:9000/Hello", serviceImpl);
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(BusFactory.getDefaultBus());
    factory.setServiceClass(AddNumbers.class);
    factory.setAddress(address);
    AddNumbers proxy = (AddNumbers) factory.create();
    StringWriter strWriter = new StringWriter();
    LoggingOutInterceptor log = new LoggingOutInterceptor(new PrintWriter(strWriter));
    ClientProxy.getClient(proxy).getOutInterceptors().add(log);
    List<String> args = new ArrayList<>();
    args.add("str1");
    args.add("str2");
    args.add("str3");
    List<Integer> result = proxy.addNumbers(args);
    String expected = "<arg0>str1 str2 str3</arg0>";
    assertTrue("Client does not use the generated wrapper class to marshal request parameters", strWriter.toString().indexOf(expected) > -1);
    assertEquals("Get the wrong result", 100, (int) result.get(0));
}
Also used : StringWriter(java.io.StringWriter) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) AddNumbersImpl(org.apache.cxf.jaxws.service.AddNumbersImpl) AddNumbers(org.apache.cxf.jaxws.service.AddNumbers) ArrayList(java.util.ArrayList) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 4 with LoggingOutInterceptor

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

the class SubscriptionEndNotificationTask method run.

@Override
public void run() {
    try {
        // needed SOAP handlers
        ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler(target.getNotificationReferenceParams());
        JaxWsProxyFactoryBean service = new JaxWsProxyFactoryBean();
        service.getOutInterceptors().add(new LoggingOutInterceptor());
        service.setServiceClass(EndToEndpoint.class);
        service.setAddress(target.getEndToURL());
        service.getHandlers().add(handler);
        EndToEndpoint endpoint = (EndToEndpoint) service.create();
        SubscriptionEnd message = new SubscriptionEnd();
        message.setStatus(status.toString());
        if (reason != null) {
            LanguageSpecificStringType reasonElement = new LanguageSpecificStringType();
            reasonElement.setLang("en-US");
            reasonElement.setValue(reason);
            message.getReason().add(reasonElement);
        }
        endpoint.subscriptionEnd(message);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SubscriptionEnd(org.apache.cxf.ws.eventing.SubscriptionEnd) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) EndToEndpoint(org.apache.cxf.ws.eventing.client.EndToEndpoint) ReferenceParametersAddingHandler(org.apache.cxf.ws.eventing.shared.handlers.ReferenceParametersAddingHandler) LanguageSpecificStringType(org.apache.cxf.ws.eventing.LanguageSpecificStringType)

Example 5 with LoggingOutInterceptor

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

the class SimpleEventingIntegrationTest method createSubscriptionManagerClient.

/**
 * Convenience method to create a client for the testing Subscription Manager
 * which is located at local://SimpleSubscriptionManager.
 * You have to specify the reference parameters you obtained from the Event Source
 * when your subscription was created.
 *
 * @return a JAX-WS client set up for managing the subscription you had created using the Event Source
 */
public SubscriptionManagerEndpoint createSubscriptionManagerClient(ReferenceParametersType refs) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(SubscriptionManagerEndpoint.class);
    factory.setAddress(URL_SUBSCRIPTION_MANAGER);
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler(refs);
    factory.getHandlers().add(handler);
    return (SubscriptionManagerEndpoint) factory.create();
}
Also used : LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) SubscriptionManagerEndpoint(org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) ReferenceParametersAddingHandler(org.apache.cxf.ws.eventing.shared.handlers.ReferenceParametersAddingHandler)

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