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