use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SpringBeansTest method testServers.
@Test
public void testServers() throws Exception {
ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/frontend/spring/servers.xml" });
ServerFactoryBean bean = (ServerFactoryBean) ctx.getBean("simple");
assertNotNull(bean);
if (!(bean.getServiceBean() instanceof HelloServiceImpl)) {
fail("can't get the right serviceBean");
}
bean = (ServerFactoryBean) ctx.getBean("inlineImplementor");
if (!(bean.getServiceBean() instanceof HelloServiceImpl)) {
fail("can't get the right serviceBean");
}
bean = (ServerFactoryBean) ctx.getBean("inlineSoapBinding");
assertNotNull(bean);
BindingConfiguration bc = bean.getBindingConfig();
assertTrue(bc instanceof SoapBindingConfiguration);
SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
assertTrue(sbc.getVersion() instanceof Soap12);
bean = (ServerFactoryBean) ctx.getBean("simpleWithBindingId");
assertEquals("get the wrong BindingId", bean.getBindingId(), "http://cxf.apache.org/bindings/xformat");
bean = (ServerFactoryBean) ctx.getBean("simpleWithWSDL");
assertNotNull(bean);
assertEquals(bean.getWsdlLocation(), "org/apache/cxf/frontend/spring/simple.wsdl");
bean = (ServerFactoryBean) ctx.getBean("proxyBean");
assertNotNull(bean);
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SoapBindingSelectionTest method testMultipleSoapBindings.
@Test
public void testMultipleSoapBindings() throws Exception {
ServerFactoryBean svrBean1 = new ServerFactoryBean();
svrBean1.setAddress("http://localhost/Hello");
svrBean1.setServiceClass(HelloService.class);
svrBean1.setServiceBean(new HelloServiceImpl());
svrBean1.setBus(getBus());
svrBean1.getInInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.USER_LOGICAL) {
public void handleMessage(Message message) throws Fault {
service1Invoked = true;
}
});
svrBean1.create();
ServerFactoryBean svrBean2 = new ServerFactoryBean();
svrBean2.setAddress("http://localhost/Hello");
svrBean2.setServiceClass(HelloService.class);
svrBean2.setServiceBean(new HelloServiceImpl());
svrBean2.setBus(getBus());
svrBean2.getInInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.USER_LOGICAL) {
public void handleMessage(Message message) throws Fault {
service2Invoked = true;
}
});
SoapBindingConfiguration config = new SoapBindingConfiguration();
config.setVersion(Soap12.getInstance());
svrBean2.setBindingConfig(config);
ServerImpl server2 = (ServerImpl) svrBean2.create();
Destination d = server2.getDestination();
MessageObserver mo = d.getMessageObserver();
assertTrue(mo instanceof MultipleEndpointObserver);
MultipleEndpointObserver meo = (MultipleEndpointObserver) mo;
assertEquals(2, meo.getEndpoints().size());
Node nd = invoke("http://localhost/Hello", LocalTransportFactory.TRANSPORT_ID, "soap11.xml");
assertEquals("http://schemas.xmlsoap.org/soap/envelope/", getNs(nd));
assertTrue(service1Invoked);
assertFalse(service2Invoked);
service1Invoked = false;
nd = invoke("http://localhost/Hello", LocalTransportFactory.TRANSPORT_ID, "soap12.xml");
assertEquals("http://www.w3.org/2003/05/soap-envelope", getNs(nd));
assertFalse(service1Invoked);
assertTrue(service2Invoked);
server2.stop();
server2.start();
nd = invoke("http://localhost/Hello", LocalTransportFactory.TRANSPORT_ID, "soap12.xml");
assertEquals("http://www.w3.org/2003/05/soap-envelope", getNs(nd));
assertFalse(service1Invoked);
assertTrue(service2Invoked);
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SoapActionTest method testBareSoap12ActionSpoofing.
@Test
public void testBareSoap12ActionSpoofing() throws Exception {
JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
pf.setServiceClass(Greeter.class);
pf.setAddress(add12);
SoapBindingConfiguration config = new SoapBindingConfiguration();
config.setVersion(Soap12.getInstance());
pf.setBindingConfig(config);
pf.setBus(bus);
Greeter greeter = (Greeter) pf.create();
assertEquals("sayHi", greeter.sayHi("test"));
assertEquals("sayHi2", greeter.sayHi2("test"));
// Now test spoofing attack
((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2");
try {
greeter.sayHi("test");
fail("Failure expected on spoofing attack");
} catch (Exception ex) {
// expected
}
// Test the other operation
((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_1");
try {
greeter.sayHi2("test");
fail("Failure expected on spoofing attack");
} catch (Exception ex) {
// expected
}
// Test a SOAP Action that does not exist in the binding
((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_UNKNOWN");
try {
greeter.sayHi("test");
fail("Failure expected on spoofing attack");
} catch (Exception ex) {
// expected
}
}
Aggregations