Search in sources :

Example 6 with JaxWsServerFactoryBean

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

the class AbstractWebServiceTaskTest method initializeProcessEngine.

@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();
    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WebServiceMockImpl(org.activiti.engine.impl.webservice.WebServiceMockImpl) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 7 with JaxWsServerFactoryBean

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

the class CxfEndpoint method doPublish.

protected void doPublish(String address) {
    JaxWsServerFactoryBean svrFactory = new NoInitJaxWsServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setAddress(address);
    svrFactory.setServiceFactory(serviceFactory);
    svrFactory.setStart(false);
    svrFactory.setServiceBean(implementor);
    svrFactory.setDestinationFactory(destinationFactory);
    svrFactory.setServiceClass(serviceFactory.getServiceClass());
    final Properties beanConfig = serviceConfiguration.getProperties();
    // endpoint properties
    if (beanConfig != null) {
        final String schemaLocations = beanConfig.getProperty(CXF_JAXWS_PREFIX + "schema-locations");
        if (schemaLocations != null) {
            svrFactory.setSchemaLocations(Arrays.asList(schemaLocations.split(",")));
        }
        final String wsdlLocation = beanConfig.getProperty(CXF_JAXWS_PREFIX + "wsdl-location");
        if (wsdlLocation != null) {
            svrFactory.setWsdlLocation(wsdlLocation);
        }
    }
    // look for bean info if exists
    CxfUtil.configureEndpoint(svrFactory, serviceConfiguration, CXF_JAXWS_PREFIX);
    if (HTTPBinding.HTTP_BINDING.equals(implInfo.getBindingType())) {
        svrFactory.setTransportId("http://cxf.apache.org/bindings/xformat");
    }
    final Level level = SERVER_IMPL_LOGGER.getLevel();
    try {
        SERVER_IMPL_LOGGER.setLevel(Level.SEVERE);
    } catch (final UnsupportedOperationException uoe) {
    // no-op
    }
    try {
        server = svrFactory.create();
    } finally {
        try {
            SERVER_IMPL_LOGGER.setLevel(level);
        } catch (final UnsupportedOperationException uoe) {
        // no-op
        }
    }
    init();
    if (getBinding() instanceof SOAPBinding) {
        ((SOAPBinding) getBinding()).setMTOMEnabled(port.isMtomEnabled());
    }
    server.start();
}
Also used : SOAPBinding(javax.xml.ws.soap.SOAPBinding) Level(java.util.logging.Level) Properties(java.util.Properties) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 8 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 9 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 10 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project qi4j-sdk by Qi4j.

the class HelloMain method main.

public static void main(String[] args) {
    HelloWorldImpl implementor = new HelloWorldImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(HelloWorld.class);
    svrFactory.setAddress("http://localhost:9001/helloWorld");
    svrFactory.setServiceBean(implementor);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    svrFactory.create();
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)11 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)3 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)3 LoggingFeature (org.apache.cxf.feature.LoggingFeature)2 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)2 URL (java.net.URL)1 Properties (java.util.Properties)1 Level (java.util.logging.Level)1 QName (javax.xml.namespace.QName)1 WebServiceProvider (javax.xml.ws.WebServiceProvider)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1 WebServiceMockImpl (org.activiti.engine.impl.webservice.WebServiceMockImpl)1 CXFMessageDataFormatFeature (org.apache.camel.component.cxf.feature.CXFMessageDataFormatFeature)1 PayLoadDataFormatFeature (org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature)1 RAWDataFormatFeature (org.apache.camel.component.cxf.feature.RAWDataFormatFeature)1 Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 SourceDataBinding (org.apache.cxf.databinding.source.SourceDataBinding)1 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)1 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)1