Search in sources :

Example 1 with SoapBindingConfiguration

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()));
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 2 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);
    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 3 with SoapBindingConfiguration

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);
}
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 4 with SoapBindingConfiguration

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);
}
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 5 with SoapBindingConfiguration

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);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.common.i18n.Message) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) Method(java.lang.reflect.Method) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

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