Search in sources :

Example 61 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project camel by apache.

the class CxfEndpoint method createServerFactoryBean.

/**
     * Create a CXF server factory bean
     */
ServerFactoryBean createServerFactoryBean() throws Exception {
    Class<?> cls = null;
    if (getDataFormat() == DataFormat.POJO) {
        ObjectHelper.notNull(getServiceClass(), CxfConstants.SERVICE_CLASS);
    }
    if (getWsdlURL() == null && getServiceClass() == null) {
        // no WSDL and serviceClass specified, set our default serviceClass
        if (getDataFormat().equals(DataFormat.PAYLOAD)) {
            setServiceClass(org.apache.camel.component.cxf.DefaultPayloadProviderSEI.class.getName());
        }
    }
    if (getServiceClass() != null) {
        cls = getServiceClass();
    }
    // create server factory bean
    // Shouldn't use CxfEndpointUtils.getServerFactoryBean(cls) as it is for
    // CxfSoapComponent
    ServerFactoryBean answer = null;
    if (cls == null) {
        checkName(portName, " endpoint/port name");
        checkName(serviceName, " service name");
        answer = new JaxWsServerFactoryBean(new WSDLServiceFactoryBean()) {

            {
                doInit = false;
            }
        };
        cls = Provider.class;
    } else if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
        answer = new JaxWsServerFactoryBean();
    } else {
        answer = new ServerFactoryBean();
    }
    // setup server factory bean
    setupServerFactoryBean(answer, cls);
    return answer;
}
Also used : ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 62 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project camel by apache.

the class CxfEndpoint method setupServerFactoryBean.

/**
     * Populate server factory bean
     */
protected void setupServerFactoryBean(ServerFactoryBean sfb, Class<?> cls) {
    // address
    sfb.setAddress(getAddress());
    sfb.setServiceClass(cls);
    sfb.setInInterceptors(in);
    sfb.setOutInterceptors(out);
    sfb.setOutFaultInterceptors(outFault);
    sfb.setInFaultInterceptors(inFault);
    sfb.setFeatures(features);
    if (schemaLocations != null) {
        sfb.setSchemaLocations(schemaLocations);
    }
    if (bindingConfig != null) {
        sfb.setBindingConfig(bindingConfig);
    }
    if (dataBinding != null) {
        sfb.setDataBinding(dataBinding);
    }
    if (serviceFactoryBean != null) {
        setServiceFactory(sfb, serviceFactoryBean);
    }
    if (sfb instanceof JaxWsServerFactoryBean && handlers != null) {
        ((JaxWsServerFactoryBean) sfb).setHandlers(handlers);
    }
    if (getTransportId() != null) {
        sfb.setTransportId(getTransportId());
    }
    if (getBindingId() != null) {
        sfb.setBindingId(getBindingId());
    }
    // wsdl url
    if (getWsdlURL() != null) {
        sfb.setWsdlURL(getWsdlURL());
    }
    // service  name qname
    if (getServiceName() != null) {
        sfb.setServiceName(getServiceName());
    }
    // port qname
    if (getPortName() != null) {
        sfb.setEndpointName(getPortName());
    }
    // apply feature here
    if (!CxfEndpointUtils.hasAnnotation(cls, WebServiceProvider.class)) {
        if (getDataFormat() == DataFormat.PAYLOAD) {
            sfb.getFeatures().add(new PayLoadDataFormatFeature(allowStreaming));
        } else if (getDataFormat().dealias() == DataFormat.CXF_MESSAGE) {
            sfb.getFeatures().add(new CXFMessageDataFormatFeature());
            sfb.setDataBinding(new SourceDataBinding());
        } else if (getDataFormat().dealias() == DataFormat.RAW) {
            RAWDataFormatFeature feature = new RAWDataFormatFeature();
            if (this.getExchangePattern().equals(ExchangePattern.InOnly)) {
                //if DataFormat is RAW|MESSAGE, can't read message so can't
                //determine it's oneway so need get the MEP from URI explicitly
                feature.setOneway(true);
            }
            feature.addInIntercepters(getInInterceptors());
            feature.addOutInterceptors(getOutInterceptors());
            sfb.getFeatures().add(feature);
        }
    } else {
        LOG.debug("Ignore DataFormat mode {} since SEI class is annotated with WebServiceProvider", getDataFormat());
    }
    if (isLoggingFeatureEnabled()) {
        if (getLoggingSizeLimit() != 0) {
            sfb.getFeatures().add(new LoggingFeature(getLoggingSizeLimit()));
        } else {
            sfb.getFeatures().add(new LoggingFeature());
        }
    }
    if (getDataFormat() == DataFormat.PAYLOAD) {
        sfb.setDataBinding(new HybridSourceDataBinding());
    }
    // set the document-literal wrapped style
    if (getWrappedStyle() != null && getDataFormat().dealias() != DataFormat.CXF_MESSAGE) {
        setWrapped(sfb, getWrappedStyle());
    }
    // any optional properties
    if (getProperties() != null) {
        if (sfb.getProperties() != null) {
            // add to existing properties
            sfb.getProperties().putAll(getProperties());
        } else {
            sfb.setProperties(getProperties());
        }
        LOG.debug("ServerFactoryBean: {} added properties: {}", sfb, getProperties());
    }
    if (this.isSkipPayloadMessagePartCheck()) {
        if (sfb.getProperties() == null) {
            sfb.setProperties(new HashMap<String, Object>());
        }
        sfb.getProperties().put("soap.no.validate.parts", Boolean.TRUE);
    }
    if (this.isSkipFaultLogging()) {
        if (sfb.getProperties() == null) {
            sfb.setProperties(new HashMap<String, Object>());
        }
        sfb.getProperties().put(FaultListener.class.getName(), new NullFaultListener());
    }
    sfb.setBus(getBus());
    sfb.setStart(false);
    getNullSafeCxfEndpointConfigurer().configure(sfb);
}
Also used : RAWDataFormatFeature(org.apache.camel.component.cxf.feature.RAWDataFormatFeature) FaultListener(org.apache.cxf.logging.FaultListener) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) WebServiceProvider(javax.xml.ws.WebServiceProvider) LoggingFeature(org.apache.cxf.feature.LoggingFeature) PayLoadDataFormatFeature(org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature) CXFMessageDataFormatFeature(org.apache.camel.component.cxf.feature.CXFMessageDataFormatFeature) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 63 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project fabric8 by jboss-fuse.

the class LoadBalanceClientServerTest method testClientServer.

@Test
public void testClientServer() throws Exception {
    assertNotNull(bus);
    // The bus is load the feature
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new HelloImpl());
    factory.setAddress("http://localhost:9000/simple/server");
    factory.setBus(bus);
    factory.create();
    // sleep a while to let the service be published
    for (int i = 0; i < 100; i++) {
        if (!feature.getLoadBalanceStrategy().getAlternateAddressList().isEmpty()) {
            break;
        }
        Thread.sleep(100);
    }
    JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
    clientFactory.setServiceClass(Hello.class);
    // The address is not the actual address that the client will access
    clientFactory.setAddress("http://someotherplace");
    List<AbstractFeature> features = new ArrayList<AbstractFeature>();
    features.add(feature);
    // we need to setup the feature on the clientfactory
    clientFactory.setFeatures(features);
    Hello hello = clientFactory.create(Hello.class);
    String response = hello.sayHello();
    assertEquals("Get a wrong response", "Hello", response);
    response = hello.sayHello();
    assertEquals("Get a wrong response", "Hello", response);
    // Try to call the hello proxy which is created by Spring with setting feature on the bus
    response = helloProxy.sayHello();
    assertEquals("Get a wrong response", "Hello", response);
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ArrayList(java.util.ArrayList) AbstractFeature(org.apache.cxf.feature.AbstractFeature) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test)

Example 64 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.

the class EndpointCreationLoop3 method iteration.

private void iteration() {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setAddress("http://localhost:9000/test");
    sf.setServiceClass(org.apache.cxf.systest.jaxb.service.TestServiceImpl.class);
    sf.setStart(false);
    Server server = sf.create();
    server.start();
    server.stop();
}
Also used : Server(org.apache.cxf.endpoint.Server) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 65 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.

the class ServerJMS method launchCxfApi.

private static void launchCxfApi() {
    Object implementor = new HelloWorldImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(HelloWorld.class);
    svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
    svrFactory.setAddress(JMS_ENDPOINT_URI);
    svrFactory.setServiceBean(implementor);
    svrFactory.setFeatures(Collections.singletonList(new LoggingFeature()));
    svrFactory.create();
}
Also used : HelloWorldImpl(demo.service.impl.HelloWorldImpl) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)106 Server (org.apache.cxf.endpoint.Server)32 Test (org.junit.Test)29 Service (org.apache.cxf.service.Service)21 Bus (org.apache.cxf.Bus)15 HashMap (java.util.HashMap)13 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)13 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)13 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)9 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)8 QName (javax.xml.namespace.QName)7 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 BeforeClass (org.junit.BeforeClass)7 Endpoint (org.apache.cxf.endpoint.Endpoint)6 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)6 JAXWSMethodInvoker (org.apache.cxf.jaxws.JAXWSMethodInvoker)6 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)6 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)5 URL (java.net.URL)4 Definition (javax.wsdl.Definition)4