Search in sources :

Example 6 with Soap12

use of org.apache.cxf.binding.soap.Soap12 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");
    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);
}
Also used : Soap12(org.apache.cxf.binding.soap.Soap12) SpringServerFactoryBean(org.apache.cxf.jaxws.spring.NamespaceHandler.SpringServerFactoryBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Example 7 with Soap12

use of org.apache.cxf.binding.soap.Soap12 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);
}
Also used : Soap12(org.apache.cxf.binding.soap.Soap12) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) Hello(org.apache.cxf.jaxws.service.Hello) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) DataBinding(org.apache.cxf.databinding.DataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Example 8 with Soap12

use of org.apache.cxf.binding.soap.Soap12 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();
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) Soap12(org.apache.cxf.binding.soap.Soap12) Message(org.apache.cxf.message.Message) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) NullConduitSelector(org.apache.cxf.endpoint.NullConduitSelector) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.hello_world_soap_http.Greeter) 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)

Example 9 with Soap12

use of org.apache.cxf.binding.soap.Soap12 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);
}
Also used : Soap12(org.apache.cxf.binding.soap.Soap12) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) HelloServiceImpl(org.apache.cxf.service.factory.HelloServiceImpl) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Example 10 with Soap12

use of org.apache.cxf.binding.soap.Soap12 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) Interceptor(org.apache.cxf.interceptor.Interceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Aggregations

Soap12 (org.apache.cxf.binding.soap.Soap12)11 BindingConfiguration (org.apache.cxf.binding.BindingConfiguration)5 Soap11 (org.apache.cxf.binding.soap.Soap11)5 SoapBindingConfiguration (org.apache.cxf.binding.soap.SoapBindingConfiguration)5 Test (org.junit.Test)5 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)5 List (java.util.List)3 TreeMap (java.util.TreeMap)2 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)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 Interceptor (org.apache.cxf.interceptor.Interceptor)2 Message (org.apache.cxf.message.Message)2 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1