use of javax.wsdl.WSDLException in project cxf by apache.
the class ServiceWSDLBuilder method getSchemaImplementation.
private Schema getSchemaImplementation(Definition def) {
ExtensionRegistry reg = def.getExtensionRegistry();
ExtensibilityElement extension;
try {
extension = reg.createExtension(javax.wsdl.Types.class, WSDLConstants.QNAME_SCHEMA);
} catch (WSDLException e) {
throw new RuntimeException("Problem creating schema implementation", e);
}
// try to cast the resulting extension:
try {
return Schema.class.cast(extension);
} catch (ClassCastException e) {
throw new RuntimeException("Schema implementation problem", e);
}
}
use of javax.wsdl.WSDLException 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.WSDLException in project cxf by apache.
the class WSDLToCorbaBinding method generateCORBAServiceForBinding.
private void generateCORBAServiceForBinding(Definition definition, PortType portType, Binding binding) throws Exception {
if (extReg == null) {
extReg = def.getExtensionRegistry();
}
String interfaceName = portType.getQName().getLocalPart();
interfaceName = mangleInterfaceName(interfaceName);
String serviceName = interfaceName + "CORBAService";
String portName = interfaceName + "CORBAPort";
String prefix = definition.getPrefix(definition.getTargetNamespace());
if (prefix == null) {
prefix = "";
}
String corbaPrefix = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
if (corbaPrefix == null) {
corbaPrefix = "corba";
def.addNamespace(corbaPrefix, CorbaConstants.NU_WSDL_CORBA);
}
// Build the service and port information and add it to the wsdl
Service service = def.createService();
Port servicePort = def.createPort();
servicePort.setName(portName);
servicePort.setBinding(binding);
try {
AddressType addressType = (AddressType) def.getExtensionRegistry().createExtension(Port.class, CorbaConstants.NE_CORBA_ADDRESS);
String addr;
if (getAddressFile() != null) {
File addrFile = new File(getAddressFile());
try {
FileReader fileReader = new FileReader(addrFile);
try (BufferedReader bufferedReader = new BufferedReader(fileReader)) {
addr = bufferedReader.readLine();
}
} catch (Exception ex) {
throw new ToolException(ex.getMessage(), ex);
}
} else {
addr = getAddress();
}
if (addr == null) {
addr = "file:./" + interfaceName + ".ref";
}
addressType.setLocation(addr);
servicePort.addExtensibilityElement((ExtensibilityElement) addressType);
} catch (WSDLException ex) {
throw new Exception("Failed to create CORBA address for service", ex);
}
QName serviceQName = new QName(definition.getTargetNamespace(), serviceName, prefix);
service.setQName(serviceQName);
service.addPort(servicePort);
definition.addService(service);
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDLToCorbaBinding method addCorbaOperationExtElement.
private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
final OperationType operationType;
try {
operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
} catch (WSDLException wse) {
LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
throw new Exception(LOG.toString(), wse);
}
operationType.setName(op.getName());
List<ParamType> params = new ArrayList<>();
List<ArgType> returns = new ArrayList<>();
wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
for (ParamType paramtype : params) {
operationType.getParam().add(paramtype);
}
for (ArgType retType : returns) {
operationType.setReturn(retType);
}
Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
for (Fault fault : faults) {
RaisesType raisestype = new RaisesType();
CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
if (extype != null) {
raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
operationType.getRaises().add(raisestype);
}
}
bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDLToProcessor method parseWSDL.
public void parseWSDL(String wsdlUrl) {
try {
Bus bus = BusFactory.getThreadDefaultBus();
WSDLManager mgr = bus.getExtension(WSDLManager.class);
wsdlDefinition = mgr.getDefinition(wsdlUrl);
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
builder.buildMockServices(wsdlDefinition);
schemas = mgr.getSchemasForDefinition(wsdlDefinition);
// remove this as we're going to be modifying it
mgr.removeDefinition(wsdlDefinition);
} catch (WSDLException we) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("FAIL_TO_CREATE_WSDL_DEFINITION", LOG);
throw new ToolException(msg, we);
}
}
Aggregations