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());
}
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());
}
}
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));
}
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();
}
}
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();
}
Aggregations