use of javax.wsdl.WSDLException in project tdi-studio-se by Talend.
the class ComponentBuilder method createschemafromtype.
private XmlSchema createschemafromtype(org.w3c.dom.Element schemaElement, Definition wsdlDefinition, String documentBase) throws WSDLException {
if (schemaElement == null) {
throw new WSDLException(WSDLException.INVALID_WSDL, "Unable to find schema extensibility element in WSDL");
}
XmlSchema xmlSchema = null;
XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
xmlSchemaCollection.setBaseUri(fixDocumentBase(documentBase));
xmlSchema = xmlSchemaCollection.read(schemaElement);
return xmlSchema;
}
use of javax.wsdl.WSDLException in project Activiti by Activiti.
the class CxfWSDLImporter method importFrom.
public void importFrom(String url) {
this.wsServices.clear();
this.wsOperations.clear();
this.structures.clear();
this.wsdlLocation = url;
try {
Bus bus = BusFactory.getDefaultBus();
final Enumeration<URL> xjcBindingUrls = Thread.currentThread().getContextClassLoader().getResources(JAXB_BINDINGS_RESOURCE);
if (xjcBindingUrls.hasMoreElements()) {
final URL xjcBindingUrl = xjcBindingUrls.nextElement();
if (xjcBindingUrls.hasMoreElements()) {
throw new ActivitiException("Several JAXB binding definitions found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
}
DynamicClientFactory.newInstance(bus).createClient(url, Arrays.asList(new String[] { xjcBindingUrl.toString() }));
WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
Definition def = wsdlManager.getDefinition(url);
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
List<ServiceInfo> services = builder.buildServices(def);
for (ServiceInfo service : services) {
WSService wsService = this.importService(service);
this.wsServices.put(this.namespace + wsService.getName(), wsService);
}
if (def != null && def.getTypes() != null) {
this.importTypes(def.getTypes());
}
} else {
throw new ActivitiException("The JAXB binding definitions are not found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
}
} catch (WSDLException e) {
e.printStackTrace();
} catch (IOException e) {
throw new ActivitiException("Error retrieveing the JAXB binding definitions", e);
}
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDLToCorbaBinding method generateCORBABinding.
private Binding generateCORBABinding(Definition definition, PortType portType) throws Exception {
QName bqname = null;
if (extReg == null) {
extReg = def.getExtensionRegistry();
}
bindingNames = new ArrayList<>();
String interfaceName = portType.getQName().getLocalPart();
String bname = getMappedBindingName(interfaceName);
String prefix = definition.getPrefix(definition.getTargetNamespace());
if (prefix == null) {
prefix = "";
}
if (bname == null && !allbindings) {
bname = bindingName;
}
if (bname == null) {
bname = mangleInterfaceName(interfaceName) + "CORBABinding";
setBindingName(bname);
bqname = new QName(definition.getTargetNamespace(), bname, prefix);
int count = 0;
StringBuilder builder = new StringBuilder(bname);
while (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
builder.append(count);
bqname = new QName(definition.getTargetNamespace(), builder.toString(), prefix);
}
bname = builder.toString();
} else {
bqname = new QName(definition.getTargetNamespace(), bname, prefix);
// Check if the Binding with name already exists
if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
String msgStr = "Binding " + bqname.getLocalPart() + " already exists in WSDL.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
}
// jwsdl model should have all other bindings in it.
String pfx = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
if (pfx == null) {
pfx = "corba";
def.addNamespace(pfx, CorbaConstants.NU_WSDL_CORBA);
}
Binding binding = null;
binding = def.createBinding();
binding.setPortType(portType);
binding.setQName(bqname);
bindingNames.add(bname);
mapBindingToInterface(portType.getQName().getLocalPart(), bname);
BindingType bindingType = null;
addCorbaTypeMap(def);
try {
bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
bindingType.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + binding.getPortType().getQName().getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
binding.addExtensibilityElement((ExtensibilityElement) bindingType);
} catch (WSDLException ex) {
ex.printStackTrace();
}
try {
addBindingOperations(def, portType, binding);
binding.setUndefined(false);
definition.addBinding(binding);
} catch (Exception ex) {
binding.setUndefined(true);
}
cleanUpTypeMap(typeMappingType);
return binding;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDL11Generator method generate.
public Definition generate(final File dir) {
File file = getOutputBase();
if (file == null && dir != null) {
if (dir.isDirectory()) {
file = new File(dir, getServiceModel().getName().getLocalPart() + ".wsdl");
} else {
file = dir;
}
} else if (dir == null) {
file = new File(getServiceModel().getName().getLocalPart() + ".wsdl");
}
File outputdir = createOutputDir(file);
Definition def = null;
try {
Writer os = new FileWriterUtil(file.getParent(), getOutputStreamCreator()).getWriter(file, StandardCharsets.UTF_8.name());
WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(getBus(), getServiceModel());
builder.setUseSchemaImports(this.allowImports());
String name = file.getName();
if (name.endsWith(".wsdl")) {
name = name.substring(0, name.lastIndexOf(".wsdl"));
}
builder.setBaseFileName(name);
Map<String, SchemaInfo> imports = new HashMap<>();
def = builder.build(imports);
wsdlWriter.writeWSDL(def, os);
os.close();
if (def.getImports().size() > 0) {
for (Import wsdlImport : WSDLDefinitionBuilder.getImports(def)) {
Definition wsdlDef = wsdlImport.getDefinition();
File wsdlFile = null;
if (!StringUtils.isEmpty(wsdlImport.getLocationURI())) {
wsdlFile = new File(outputdir, wsdlImport.getLocationURI());
} else {
wsdlFile = new File(outputdir, wsdlDef.getQName().getLocalPart() + ".wsdl");
}
try (OutputStream wsdlOs = new BufferedOutputStream(Files.newOutputStream(wsdlFile.toPath()))) {
wsdlWriter.writeWSDL(wsdlDef, wsdlOs);
}
}
}
for (Map.Entry<String, SchemaInfo> imp : imports.entrySet()) {
File impfile = new File(file.getParentFile(), imp.getKey());
Element el = imp.getValue().getElement();
updateImports(el, imports);
FileWriterUtil fileWriterUtil = new FileWriterUtil(impfile.getParent(), getToolContext().get(OutputStreamCreator.class));
os = fileWriterUtil.getWriter(impfile, StandardCharsets.UTF_8.name());
StaxUtils.writeTo(el, os, 2);
os.close();
}
customizing(outputdir, name, imports.keySet());
} catch (WSDLException wex) {
wex.printStackTrace();
} catch (FileNotFoundException fnfe) {
throw new ToolException("Output file " + file + " not found", fnfe);
} catch (IOException e) {
e.printStackTrace();
} catch (XMLStreamException e) {
e.printStackTrace();
}
return def;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class AttributeVisitor method generateCorbaOperation.
/**
* Generates a corba:operation in the corba:binding container within a wsdl:binding.
*
* Only one (or none) corba parameter and only one (or none) corba return parameter are supported.
*
* @param op is the wsdl operation to bind.
* @param param is the corba parameter, none if null.
* @param arg is the corba return parameter, none if null.
* @return the generated corba:operation.
*/
private OperationType generateCorbaOperation(Operation op, ParamType param, ArgType arg) {
OperationType operation = null;
try {
operation = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
} catch (WSDLException ex) {
throw new RuntimeException(ex);
}
operation.setName(op.getName());
if (param != null) {
operation.getParam().add(param);
}
if (arg != null) {
operation.setReturn(arg);
}
return operation;
}
Aggregations