use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project camel by apache.
the class CxfEndpointBeanTest method testCxfEndpointBeanDefinitionParser.
@Test
public void testCxfEndpointBeanDefinitionParser() {
CxfEndpoint routerEndpoint = ctx.getBean("routerEndpoint", CxfEndpoint.class);
assertEquals("Got the wrong endpoint address", "http://localhost:" + port1 + "/CxfEndpointBeanTest/router", routerEndpoint.getAddress());
assertEquals("Got the wrong endpont service class", "org.apache.camel.component.cxf.HelloService", routerEndpoint.getServiceClass().getName());
assertEquals("loggingFeatureEnabled should be false", false, routerEndpoint.isLoggingFeatureEnabled());
assertEquals("loggingSizeLimit should not be set", 0, routerEndpoint.getLoggingSizeLimit());
assertEquals("Got the wrong handlers size", 1, routerEndpoint.getHandlers().size());
assertEquals("Got the wrong schemalocations size", 1, routerEndpoint.getSchemaLocations().size());
assertEquals("Got the wrong schemalocation", "classpath:wsdl/Message.xsd", routerEndpoint.getSchemaLocations().get(0));
assertEquals("Got the wrong continuationTimeout", 60000, routerEndpoint.getContinuationTimeout());
CxfEndpoint myEndpoint = ctx.getBean("myEndpoint", CxfEndpoint.class);
assertEquals("Got the wrong endpointName", endpointName, myEndpoint.getPortName());
assertEquals("Got the wrong serviceName", serviceName, myEndpoint.getServiceName());
assertEquals("loggingFeatureEnabled should be true", true, myEndpoint.isLoggingFeatureEnabled());
assertEquals("loggingSizeLimit should be set", 200, myEndpoint.getLoggingSizeLimit());
assertTrue("We should get a soap binding", myEndpoint.getBindingConfig() instanceof SoapBindingConfiguration);
SoapBindingConfiguration configuration = (SoapBindingConfiguration) myEndpoint.getBindingConfig();
assertEquals("We should get a right soap version", "1.2", String.valueOf(configuration.getVersion().getVersion()));
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SpringBeansTest method testClients.
@Test
public void testClients() throws Exception {
AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false);
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/jaxws/spring/clients.xml" });
ClientHolderBean greeters = (ClientHolderBean) ctx.getBean("greeters");
assertEquals(4, greeters.greeterCount());
Object bean = ctx.getBean("client1.proxyFactory");
assertNotNull(bean);
Greeter greeter = (Greeter) ctx.getBean("client1");
Greeter greeter2 = (Greeter) ctx.getBean("client1");
assertNotNull(greeter);
assertNotNull(greeter2);
assertSame(greeter, greeter2);
Client client = ClientProxy.getClient(greeter);
assertNotNull("expected ConduitSelector", client.getConduitSelector());
assertTrue("unexpected ConduitSelector", client.getConduitSelector() instanceof NullConduitSelector);
List<Interceptor<? extends Message>> inInterceptors = client.getInInterceptors();
boolean saaj = false;
boolean logging = false;
for (Interceptor<? extends Message> i : inInterceptors) {
if (i instanceof SAAJInInterceptor) {
saaj = true;
} else if (i instanceof LoggingInInterceptor) {
logging = true;
}
}
assertTrue(saaj);
assertTrue(logging);
saaj = false;
logging = false;
for (Interceptor<?> i : client.getOutInterceptors()) {
if (i instanceof SAAJOutInterceptor) {
saaj = true;
} else if (i instanceof LoggingOutInterceptor) {
logging = true;
}
}
assertTrue(saaj);
assertTrue(logging);
assertTrue(client.getEndpoint().getService().getDataBinding() instanceof SourceDataBinding);
JaxWsProxyFactoryBean factory = (JaxWsProxyFactoryBean) ctx.getBean("wsdlLocation.proxyFactory");
assertNotNull(factory);
String wsdlLocation = factory.getWsdlLocation();
assertEquals("We should get the right wsdl location", wsdlLocation, "wsdl/hello_world.wsdl");
factory = (JaxWsProxyFactoryBean) ctx.getBean("inlineSoapBinding.proxyFactory");
assertNotNull(factory);
BindingConfiguration bc = factory.getBindingConfig();
assertTrue(bc instanceof SoapBindingConfiguration);
SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
assertTrue(sbc.getVersion() instanceof Soap12);
assertTrue("the soap configure should set isMtomEnabled to be true", sbc.isMtomEnabled());
Greeter g1 = greeters.getGreet1();
Greeter g2 = greeters.getGreet2();
assertNotSame(g1, g2);
ctx.close();
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SpringBeansTest method testServers.
@Test
public void testServers() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/jaxws/spring/servers.xml" });
JaxWsServerFactoryBean bean;
BindingConfiguration bc;
SoapBindingConfiguration sbc;
bean = (JaxWsServerFactoryBean) ctx.getBean("inlineSoapBindingRPC");
assertNotNull(bean);
bc = bean.getBindingConfig();
assertTrue(bc instanceof SoapBindingConfiguration);
sbc = (SoapBindingConfiguration) bc;
assertEquals("rpc", sbc.getStyle());
bean = (JaxWsServerFactoryBean) ctx.getBean("simple");
assertNotNull(bean);
bean = (JaxWsServerFactoryBean) ctx.getBean("inlineWsdlLocation");
assertNotNull(bean);
assertEquals(bean.getWsdlLocation(), "wsdl/hello_world_doc_lit.wsdl");
bean = (JaxWsServerFactoryBean) ctx.getBean("inlineSoapBinding");
assertNotNull(bean);
bc = bean.getBindingConfig();
assertTrue(bc instanceof SoapBindingConfiguration);
sbc = (SoapBindingConfiguration) bc;
assertTrue("Not soap version 1.2: " + sbc.getVersion(), sbc.getVersion() instanceof Soap12);
bean = (JaxWsServerFactoryBean) ctx.getBean("inlineDataBinding");
assertNotNull(bean);
boolean found = false;
String[] names = ctx.getBeanNamesForType(SpringServerFactoryBean.class);
for (String n : names) {
if (n.startsWith(SpringServerFactoryBean.class.getName())) {
found = true;
}
}
assertTrue("Could not find server factory with autogenerated id", found);
testNamespaceMapping(ctx);
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SpringBeansTest method testEndpoints.
@Test
public void testEndpoints() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/jaxws/spring/endpoints.xml" });
EndpointImpl ep = getEndpointImplBean("simple", ctx);
assertNotNull(ep.getImplementor());
assertNotNull(ep.getServer());
ep = getEndpointImplBean("simpleWithAddress", ctx);
if (!(ep.getImplementor() instanceof org.apache.hello_world_soap_http.GreeterImpl)) {
fail("can't get the right implementor object");
}
assertEquals("http://localhost:8080/simpleWithAddress", ep.getServer().getEndpoint().getEndpointInfo().getAddress());
ep = getEndpointImplBean("inlineImplementor", ctx);
if (!(ep.getImplementor() instanceof org.apache.hello_world_soap_http.GreeterImpl)) {
fail("can't get the right implementor object");
}
org.apache.hello_world_soap_http.GreeterImpl impl = (org.apache.hello_world_soap_http.GreeterImpl) ep.getImplementor();
assertEquals("The property was not injected rightly", impl.getPrefix(), "hello");
assertNotNull(ep.getServer());
ep = getEndpointImplBean("inlineInvoker", ctx);
assertTrue(ep.getInvoker() instanceof NullInvoker);
assertTrue(ep.getService().getInvoker() instanceof NullInvoker);
ep = getEndpointImplBean("simpleWithBindingUri", ctx);
assertEquals("get the wrong bindingId", ep.getBindingUri(), "http://cxf.apache.org/bindings/xformat");
assertEquals("get a wrong transportId", "http://cxf.apache.org/transports/local", ep.getTransportId());
ep = getEndpointImplBean("simpleWithBinding", ctx);
BindingConfiguration bc = ep.getBindingConfig();
assertTrue(bc instanceof SoapBindingConfiguration);
SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
assertTrue(sbc.getVersion() instanceof Soap12);
assertTrue("the soap configure should set isMtomEnabled to be true", sbc.isMtomEnabled());
ep = getEndpointImplBean("implementorClass", ctx);
assertEquals(Hello.class, ep.getImplementorClass());
assertTrue(ep.getImplementor().getClass() == Object.class);
ep = getEndpointImplBean("epWithProps", ctx);
assertEquals("bar", ep.getProperties().get("foo"));
ep = getEndpointImplBean("classImpl", ctx);
assertTrue(ep.getImplementor() instanceof Hello);
QName name = ep.getServer().getEndpoint().getService().getName();
assertEquals("http://service.jaxws.cxf.apache.org/service", name.getNamespaceURI());
assertEquals("HelloServiceCustomized", name.getLocalPart());
name = ep.getServer().getEndpoint().getEndpointInfo().getName();
assertEquals("http://service.jaxws.cxf.apache.org/endpoint", name.getNamespaceURI());
assertEquals("HelloEndpointCustomized", name.getLocalPart());
Object bean = ctx.getBean("wsdlLocation");
assertNotNull(bean);
ep = getEndpointImplBean("publishedEndpointUrl", ctx);
String expectedEndpointUrl = "http://cxf.apache.org/Greeter";
assertEquals(expectedEndpointUrl, ep.getPublishedEndpointUrl());
ep = getEndpointImplBean("epWithDataBinding", ctx);
DataBinding dataBinding = ep.getDataBinding();
assertTrue(dataBinding instanceof JAXBDataBinding);
assertEquals("The namespace map should have an entry", ((JAXBDataBinding) dataBinding).getNamespaceMap().size(), 1);
// test for existence of Endpoint without an id element
boolean found = false;
String[] names = ctx.getBeanNamesForType(EndpointImpl.class);
for (String n : names) {
if (n.startsWith(EndpointImpl.class.getPackage().getName())) {
found = true;
}
}
assertTrue("Could not find server factory with autogenerated id", found);
ep = getEndpointImplBean("unpublishedEndpoint", ctx);
assertFalse("Unpublished endpoint is published", ep.isPublished());
testInterceptors(ctx);
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method createBindingInfo.
protected BindingInfo createBindingInfo() {
BindingFactoryManager mgr = bus.getExtension(BindingFactoryManager.class);
String binding = bindingId;
if (binding == null && bindingConfig != null) {
binding = bindingConfig.getBindingId();
}
if (binding == null) {
// default to soap binding
binding = "http://schemas.xmlsoap.org/soap/";
}
try {
if (binding.contains("/soap")) {
if (bindingConfig == null) {
bindingConfig = createSoapBindingConfig();
}
if (bindingConfig instanceof SoapBindingConfiguration && !((SoapBindingConfiguration) bindingConfig).isSetStyle()) {
((SoapBindingConfiguration) bindingConfig).setStyle(serviceFactory.getStyle());
}
}
bindingFactory = mgr.getBindingFactory(binding);
BindingInfo inf = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
for (BindingOperationInfo boi : inf.getOperations()) {
serviceFactory.updateBindingOperation(boi);
Method m = serviceFactory.getMethodDispatcher().getMethod(boi);
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, inf, boi, m);
}
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, inf);
return inf;
} catch (BusException ex) {
throw new ServiceConstructionException(new Message("COULD.NOT.RESOLVE.BINDING", LOG, bindingId), ex);
}
}
Aggregations