Search in sources :

Example 6 with SoapBindingConfiguration

use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.

the class SoapActionTest method testSoap12Endpoint.

@Test
public void testSoap12Endpoint() 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"));
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 7 with SoapBindingConfiguration

use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.

the class SoapActionTest method testWrappedSoap12ActionSpoofing.

@Test
public void testWrappedSoap12ActionSpoofing() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(WrappedGreeter.class);
    pf.setAddress(add14);
    SoapBindingConfiguration config = new SoapBindingConfiguration();
    config.setVersion(Soap12.getInstance());
    pf.setBindingConfig(config);
    pf.setBus(bus);
    WrappedGreeter greeter = (WrappedGreeter) pf.create();
    assertEquals("sayHi", greeter.sayHiRequestWrapped("test"));
    assertEquals("sayHi2", greeter.sayHiRequest2Wrapped("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.sayHiRequestWrapped("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.sayHiRequest2Wrapped("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.sayHiRequestWrapped("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) Test(org.junit.Test)

Example 8 with SoapBindingConfiguration

use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.

the class SoapActionTest method createServers.

@BeforeClass
public static void createServers() throws Exception {
    bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new SoapActionGreeterImpl());
    sf.setAddress(add11);
    sf.setBus(bus);
    sf.create();
    sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new SoapActionGreeterImpl());
    sf.setAddress(add12);
    sf.setBus(bus);
    SoapBindingConfiguration config = new SoapBindingConfiguration();
    config.setVersion(Soap12.getInstance());
    sf.setBindingConfig(config);
    sf.create();
    sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new WrappedSoapActionGreeterImpl());
    sf.setAddress(add13);
    sf.setBus(bus);
    sf.create();
    sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new WrappedSoapActionGreeterImpl());
    sf.setAddress(add14);
    sf.setBus(bus);
    config.setVersion(Soap12.getInstance());
    sf.setBindingConfig(config);
    sf.create();
    sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new RPCLitSoapActionGreeterImpl());
    sf.setAddress(add15);
    sf.setBus(bus);
    sf.create();
    sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new RPCEncodedSoapActionGreeterImpl());
    sf.setAddress(add16);
    sf.setBus(bus);
    sf.create();
    sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new WrappedEncodedSoapActionGreeterImpl());
    sf.setAddress(add17);
    sf.setBus(bus);
    sf.create();
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) BeforeClass(org.junit.BeforeClass)

Example 9 with SoapBindingConfiguration

use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project camel by apache.

the class CxfConsumerSoap12Test method testCxfEndpointBeanDefinitionParser.

@Test
public void testCxfEndpointBeanDefinitionParser() {
    CxfEndpoint routerEndpoint = context.getEndpoint("routerEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpoint address", routerEndpoint.getAddress(), "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
    assertEquals("Got the wrong endpont service class", "org.apache.hello_world_soap_http.Greeter", routerEndpoint.getServiceClass().getName());
    BindingConfiguration binding = routerEndpoint.getBindingConfig();
    assertTrue("Got no soap binding", binding instanceof SoapBindingConfiguration);
    assertEquals("Got the wrong soap version", "http://schemas.xmlsoap.org/wsdl/soap12/", ((SoapBindingConfiguration) binding).getVersion().getBindingId());
    assertTrue("Mtom not enabled", ((SoapBindingConfiguration) binding).isMtomEnabled());
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) Test(org.junit.Test)

Example 10 with SoapBindingConfiguration

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);
    ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/frontend/spring/clients.xml" });
    Object bean = ctx.getBean("client1.proxyFactory");
    assertNotNull(bean);
    ClientProxyFactoryBean cpfbean = (ClientProxyFactoryBean) bean;
    BindingConfiguration bc = cpfbean.getBindingConfig();
    assertTrue(bc instanceof SoapBindingConfiguration);
    SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
    assertTrue(sbc.getVersion() instanceof Soap12);
    HelloService greeter = (HelloService) ctx.getBean("client1");
    assertNotNull(greeter);
    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);
    ClientProxyFactoryBean clientProxyFactoryBean = (ClientProxyFactoryBean) ctx.getBean("client2.proxyFactory");
    assertNotNull(clientProxyFactoryBean);
    assertEquals("get the wrong transportId", clientProxyFactoryBean.getTransportId(), "http://cxf.apache.org/transports/local");
    assertEquals("get the wrong bindingId", clientProxyFactoryBean.getBindingId(), "http://cxf.apache.org/bindings/xformat");
    greeter = (HelloService) ctx.getBean("client2");
    assertNotNull(greeter);
    greeter = (HelloService) ctx.getBean("client3");
    assertNotNull(greeter);
    client = ClientProxy.getClient(greeter);
    EndpointInfo epi = client.getEndpoint().getEndpointInfo();
    AuthorizationPolicy ap = epi.getExtensor(AuthorizationPolicy.class);
    assertNotNull("The AuthorizationPolicy instance should not be null", ap);
    assertEquals("Get the wrong username", ap.getUserName(), "testUser");
    assertEquals("Get the wrong password", ap.getPassword(), "password");
}
Also used : Soap12(org.apache.cxf.binding.soap.Soap12) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) Message(org.apache.cxf.message.Message) HelloService(org.apache.cxf.service.factory.HelloService) NullConduitSelector(org.apache.cxf.endpoint.NullConduitSelector) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Aggregations

SoapBindingConfiguration (org.apache.cxf.binding.soap.SoapBindingConfiguration)13 Test (org.junit.Test)11 BindingConfiguration (org.apache.cxf.binding.BindingConfiguration)6 Soap12 (org.apache.cxf.binding.soap.Soap12)5 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)5 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)4 Message (org.apache.cxf.message.Message)3 WrappedGreeter (org.apache.hello_world_soap_action.WrappedGreeter)3 CxfEndpoint (org.apache.camel.component.cxf.CxfEndpoint)2 SAAJInInterceptor (org.apache.cxf.binding.soap.saaj.SAAJInInterceptor)2 SAAJOutInterceptor (org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor)2 SourceDataBinding (org.apache.cxf.databinding.source.SourceDataBinding)2 Client (org.apache.cxf.endpoint.Client)2 NullConduitSelector (org.apache.cxf.endpoint.NullConduitSelector)2 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)2 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)2 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)2 Interceptor (org.apache.cxf.interceptor.Interceptor)2 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)2 HelloServiceImpl (org.apache.cxf.service.factory.HelloServiceImpl)2