Search in sources :

Example 1 with JaxWsServerFactoryBean

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

the class SoapSTSInstanceLifecycleManagerImpl method exposeSTSInstanceAsWebService.

@Override
public Server exposeSTSInstanceAsWebService(Map<String, Object> webServiceProperties, SecurityTokenServiceProvider securityTokenServiceProvider, SoapSTSInstanceConfig stsInstanceConfig) throws STSPublishException {
    try {
        JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
        /*
        The serverFactoryBean#setBus invocation is crucial. The cxf.Bus class is ultimately the entity with which newly published web-services are
        registered. The STSBroker#loadBus method previously called BusFactory.setDefaultBus with the bus instance corresponding
        to the STSBroker, the CXFNonSpringServlet subclass which is specified in web.xml as the entry point for all incoming
        web-service invocations, and thus the entity with which all published web-service instances must be registered.
        Without the line below, web-services instances can happily be published, but unless they are associated with the
        STSBroker's cxf bus, the routing functionality in the CXFNonSpringServlet will not know of this published web-service,
        resulting in a 404 on any invocation.

        Note that the parameter to BusFactory.getDefaultBus is set to false, as BusFactory.setDefaultBus was called in
        STSBroker#loadBus, the CXFNonSpringServlet subclass, specified in web.xml, which is the entry point for all
        web-service invocations. Note that the STSBroker#loadBus method is called as part of the servlet intialization
        (it is a load-on-startup servlet), and prior to the initiation of the publish-service polling which will ultimately
        result in the invocation of this method. So the BusFactory.getDefaultBus method should always return the Bus
        instance set in the STSBroker class - thus the createIfNecessary parameter is always set to false.
         */
        final boolean createIfNecessary = false;
        serverFactoryBean.setBus(BusFactory.getDefaultBus(createIfNecessary));
        serverFactoryBean.setWsdlLocation(stsInstanceConfig.getDeploymentConfig().getWsdlLocation());
        serverFactoryBean.setAddress(normalizeDeploymentSubPath(stsInstanceConfig.getDeploymentSubPath()));
        serverFactoryBean.setServiceBean(securityTokenServiceProvider);
        serverFactoryBean.setServiceName(stsInstanceConfig.getDeploymentConfig().getService());
        serverFactoryBean.setEndpointName(stsInstanceConfig.getDeploymentConfig().getPort());
        //TODO: get clear on implications of this line.
        serverFactoryBean.setBindingId(SOAPBinding.SOAP12HTTP_BINDING);
        serverFactoryBean.setProperties(webServiceProperties);
        return serverFactoryBean.create();
    } catch (RuntimeException e) {
        /*
            The CXF runtime was written at the time when checked-exceptions were passe' - thus RuntimeException subclasses
            are thrown. Catch Exception because the compiler won't tell me which exceptions are thrown.
             */
        throw new STSPublishException(ResourceException.INTERNAL_ERROR, e.getMessage(), e);
    }
}
Also used : STSPublishException(org.forgerock.openam.sts.STSPublishException) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 2 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 3 with JaxWsServerFactoryBean

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

the class WSAddressingTest method setUp.

@Before
public void setUp() throws Exception {
    template = context.createProducerTemplate();
    JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean();
    svrBean.setAddress(getServerAddress());
    svrBean.setServiceClass(Greeter.class);
    svrBean.setServiceBean(new GreeterImpl());
    SpringBusFactory bf = new SpringBusFactory();
    URL cxfConfig = null;
    if (getCxfServerConfig() != null) {
        cxfConfig = ClassLoaderUtils.getResource(getCxfServerConfig(), this.getClass());
    }
    svrBean.setBus(bf.createBus(cxfConfig));
    serviceEndpoint = svrBean.create();
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) URL(java.net.URL) Before(org.junit.Before)

Example 4 with JaxWsServerFactoryBean

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

the class CxfBeanEndpoint method createServer.

private void createServer(List<Object> serviceBeans) {
    Object obj = serviceBeans.get(0).getClass().getAnnotation(WebService.class);
    if (obj != null) {
        JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
        bean.setTransportId(CxfBeanTransportFactory.TRANSPORT_ID);
        bean.setServiceClass(serviceBeans.get(0).getClass());
        // set the bean instance as well, otherwise CXF will re-create a new instance of the class
        bean.setServiceBean(serviceBeans.get(0));
        if (bean.getJaxWsServiceFactory() != null) {
            bean.getJaxWsServiceFactory().setPopulateFromClass(isPopulateFromClass());
        }
        bean.setBus(bus);
        bean.setStart(true);
        bean.setAddress("camel://" + createEndpointUri());
        if (loggingFeatureEnabled) {
            bean.getFeatures().add(new LoggingFeature());
        }
        server = bean.create();
    } else {
        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
        bean.setServiceBeans(serviceBeans);
        bean.setAddress("camel://" + createEndpointUri());
        bean.setStart(true);
        bean.setTransportId(CxfBeanTransportFactory.TRANSPORT_ID);
        bean.setBus(bus);
        if (loggingFeatureEnabled) {
            bean.getFeatures().add(new LoggingFeature());
        }
        bean.setProviders(providers);
        server = bean.create();
    }
}
Also used : LoggingFeature(org.apache.cxf.feature.LoggingFeature) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 5 with JaxWsServerFactoryBean

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

the class CxfSpringEndpoint method createServerFactoryBean.

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

                {
                    doInit = false;
                }
            };
            cls = Provider.class;
        } else {
            ObjectHelper.notNull(cls, CxfConstants.SERVICE_CLASS);
        }
    } else if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
        answer = new JaxWsServerFactoryBean();
    } else {
        answer = new ServerFactoryBean();
    }
    // setup server factory bean
    setupServerFactoryBean(answer, cls);
    // fill in values that have not been filled.
    if (answer.getServiceName() == null && getServiceLocalName() != null) {
        answer.setServiceName(new QName(getServiceNamespace(), getServiceLocalName()));
    }
    if (answer.getEndpointName() == null && getEndpointLocalName() != null) {
        answer.setEndpointName(new QName(getEndpointNamespace(), getEndpointLocalName()));
    }
    if (cls == null) {
        checkName(answer.getEndpointName(), "endpoint/port name");
        checkName(answer.getServiceName(), "service name");
    }
    return answer;
}
Also used : QName(javax.xml.namespace.QName) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)105 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