use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.
the class ReflectionServiceFactoryBean method buildServiceFromWSDL.
protected void buildServiceFromWSDL(String url) {
sendEvent(Event.CREATE_FROM_WSDL, url);
if (LOG.isLoggable(Level.INFO)) {
LOG.info("Creating Service " + getServiceQName() + " from WSDL: " + url);
}
populateFromClass = false;
WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName());
boolean setEPName = true;
if (features != null) {
for (Feature f : features) {
if (f.getClass().isAnnotationPresent(EvaluateAllEndpoints.class)) {
setEPName = false;
}
}
}
if (setEPName) {
// CXF will only evaluate this endpoint
factory.setEndpointName(getEndpointName(false));
}
sendEvent(Event.WSDL_LOADED, factory.getDefinition());
setService(factory.create());
setServiceProperties();
sendEvent(Event.SERVICE_SET, getService());
EndpointInfo epInfo = getEndpointInfo();
if (epInfo != null) {
serviceConfigurations.add(new WSDLBasedServiceConfiguration(getEndpointInfo().getBinding()));
}
initializeWSDLOperations();
Set<Class<?>> cls = getExtraClass();
if (cls != null && !cls.isEmpty()) {
for (ServiceInfo si : getService().getServiceInfos()) {
si.setProperty(EXTRA_CLASS, cls);
}
}
initializeDataBindings();
}
use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.
the class SimpleBatchSTSClient method createClient.
protected void createClient() throws BusException, EndpointException {
if (client != null) {
return;
}
bus.getExtension(Configurer.class).configureBean(name, this);
if (wsdlLocation != null) {
WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
SourceDataBinding dataBinding = new SourceDataBinding();
factory.setDataBinding(dataBinding);
Service service = factory.create();
service.setDataBinding(dataBinding);
EndpointInfo ei = service.getEndpointInfo(endpointName);
Endpoint endpoint = new EndpointImpl(bus, service, ei);
client = new ClientImpl(bus, endpoint);
} else {
Endpoint endpoint = STSUtils.createSTSEndpoint(bus, namespace, null, location, soapVersion, policy, endpointName);
client = new ClientImpl(bus, endpoint);
}
client.getInFaultInterceptors().addAll(inFault);
client.getInInterceptors().addAll(in);
client.getOutInterceptors().addAll(out);
client.getOutFaultInterceptors().addAll(outFault);
in = null;
out = null;
inFault = null;
outFault = null;
if (features != null) {
for (AbstractFeature f : features) {
f.initialize(client, bus);
}
}
}
use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.
the class ServiceImpl method initializePorts.
private void initializePorts() {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
javax.wsdl.Service serv = def.getService(serviceName);
if (serv == null) {
throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
}
Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
for (Port port : wsdlports.values()) {
QName name = new QName(serviceName.getNamespaceURI(), port.getName());
String address = null;
String bindingID = null;
List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
} else if (e instanceof SOAP12Binding) {
bindingID = SOAPBinding.SOAP12HTTP_BINDING;
} else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
}
}
extensions = CastUtils.cast(port.getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapAddress) {
address = ((SoapAddress) e).getLocationURI();
} else if (e instanceof AddressType) {
address = ((AddressType) e).getLocation();
} else if (e instanceof SOAP12Address) {
address = ((SOAP12Address) e).getLocationURI();
} else if (e instanceof SOAPAddress) {
address = ((SOAPAddress) e).getLocationURI();
} else if (e instanceof HTTPAddress) {
address = ((HTTPAddress) e).getLocationURI();
}
}
addPort(name, bindingID, address);
}
} catch (WebServiceException e) {
throw e;
} catch (Throwable e) {
if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, e.getLocalizedMessage(), e);
}
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
Service service = sf.create();
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
addPort(ei.getName(), bindingID, ei.getAddress());
}
}
}
}
use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.
the class ServiceImpl method createDispatchService.
private AbstractServiceFactoryBean createDispatchService(DataBinding db) {
AbstractServiceFactoryBean serviceFactory;
Service dispatchService = null;
if (null != wsdlURL) {
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
dispatchService = sf.create();
dispatchService.setDataBinding(db);
serviceFactory = sf;
} else {
ReflectionServiceFactoryBean sf = new JaxWsServiceFactoryBean();
sf.setBus(bus);
sf.setServiceName(serviceName);
// maybe we can find another way to create service which have no SEI
sf.setServiceClass(DummyImpl.class);
sf.setDataBinding(db);
dispatchService = sf.create();
serviceFactory = sf;
}
configureObject(dispatchService);
for (ServiceInfo si : dispatchService.getServiceInfos()) {
si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
if (null == wsdlURL) {
for (EndpointInfo ei : si.getEndpoints()) {
ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
}
}
for (BindingInfo bind : si.getBindings()) {
for (BindingOperationInfo bop : bind.getOperations()) {
// force to bare, no unwrapping
if (bop.isUnwrappedCapable()) {
bop.getOperationInfo().setUnwrappedOperation(null);
bop.setUnwrappedOperation(null);
}
}
}
}
return serviceFactory;
}
use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.
the class AbstractJMSTester method setupServiceInfo.
protected EndpointInfo setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {
URL wsdlUrl = getClass().getResource(wsdl);
if (wsdlUrl == null) {
throw new IllegalArgumentException("Wsdl file not found on class path " + wsdl);
}
WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlUrl.toExternalForm(), new QName(ns, serviceName));
Service service = factory.create();
return service.getEndpointInfo(new QName(ns, portName));
}
Aggregations