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);
}
}
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();
}
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();
}
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();
}
}
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;
}
Aggregations