use of javax.wsdl.factory.WSDLFactory in project cxf by apache.
the class WSDLServiceFactory method create.
public Service create() {
List<ServiceInfo> services;
if (serviceName == null) {
try {
WSDLServiceBuilder builder = new WSDLServiceBuilder(getBus());
builder.setAllowElementRefs(allowRefs);
services = builder.buildServices(definition);
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
if (services.isEmpty()) {
throw new ServiceConstructionException(new Message("NO_SERVICE_EXC", LOG));
}
// @@TODO - this isn't good, need to return all the services
serviceName = services.get(0).getName();
// get all the service info's that match that first one.
Iterator<ServiceInfo> it = services.iterator();
while (it.hasNext()) {
if (!it.next().getName().equals(serviceName)) {
it.remove();
}
}
} else {
javax.wsdl.Service wsdlService = definition.getService(serviceName);
if (wsdlService == null) {
if ((!PartialWSDLProcessor.isServiceExisted(definition, serviceName)) && (!PartialWSDLProcessor.isBindingExisted(definition, serviceName)) && (PartialWSDLProcessor.isPortTypeExisted(definition, serviceName))) {
try {
Map<QName, PortType> portTypes = CastUtils.cast(definition.getAllPortTypes());
String existPortName = null;
PortType portType = null;
for (Map.Entry<QName, PortType> entry : portTypes.entrySet()) {
existPortName = entry.getKey().getLocalPart();
if (serviceName.getLocalPart().contains(existPortName)) {
portType = entry.getValue();
break;
}
}
WSDLFactory factory = WSDLFactory.newInstance();
ExtensionRegistry extReg = factory.newPopulatedExtensionRegistry();
Binding binding = PartialWSDLProcessor.doAppendBinding(definition, existPortName, portType, extReg);
definition.addBinding(binding);
wsdlService = PartialWSDLProcessor.doAppendService(definition, existPortName, extReg, binding);
definition.addService(wsdlService);
} catch (Exception e) {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
} else {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
}
try {
services = new WSDLServiceBuilder(getBus()).buildServices(definition, wsdlService, endpointName);
if (services.isEmpty()) {
throw new ServiceConstructionException(new Message("NO_SUCH_ENDPOINT_EXC", LOG, endpointName));
}
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
}
ServiceImpl service = new ServiceImpl(services);
setService(service);
return service;
}
use of javax.wsdl.factory.WSDLFactory in project cxf by apache.
the class OASISCatalogTest method testWSDLLocatorWithDefaultCatalog.
@Test
public void testWSDLLocatorWithDefaultCatalog() throws Exception {
URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
assertNotNull(wsdl);
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), OASISCatalogManager.getCatalogManager(null));
wsdlReader.setFeature("javax.wsdl.verbose", false);
wsdlReader.readWSDL(wsdlLocator);
}
use of javax.wsdl.factory.WSDLFactory in project cxf by apache.
the class OASISCatalogTest method testWSDLLocatorWithoutCatalog.
@Test
public void testWSDLLocatorWithoutCatalog() throws Exception {
URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
assertNotNull(wsdl);
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
OASISCatalogManager catalog = new OASISCatalogManager();
CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), catalog);
try {
wsdlReader.readWSDL(wsdlLocator);
fail("Test did not fail as expected");
} catch (WSDLException e) {
// ignore
}
}
use of javax.wsdl.factory.WSDLFactory in project tesb-studio-se by Talend.
the class WSDLUtils method getDefinition.
// public static Definition getDefinition(String pathToWsdl) throws CoreException {
// try {
// WSDLFactory wsdlFactory = WSDLFactory.newInstance();
// WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
//
// newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
// newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
// return newWSDLReader.readWSDL(pathToWsdl);
// } catch (WSDLException e) {
// throw new CoreException(StatusUtil.newStatus(IStatus.ERROR, e.getLocalizedMessage(), e));
// }
// }
public static Definition getDefinition(IFile pathToWsdl) throws CoreException {
try {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
return newWSDLReader.readWSDL(pathToWsdl.getLocationURI().toString());
} catch (WSDLException e) {
throw getCoreException(null, e);
}
}
use of javax.wsdl.factory.WSDLFactory in project jbossws-cxf by jbossws.
the class JBWS2150TestCase method getWSDLDefinition.
private Definition getWSDLDefinition(String wsdlLocation) throws Exception {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.importDocuments", false);
wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition definition = wsdlReader.readWSDL(null, wsdlLocation);
return definition;
}
Aggregations