use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class XSDToWSDLProcessor method addWSDLTypes.
private void addWSDLTypes() throws ToolException {
Element sourceElement = this.xsdDoc.getDocumentElement();
Element targetElement = (Element) sourceElement.cloneNode(true);
this.wsdlDefinition.setTargetNamespace((String) env.get(ToolConstants.CFG_NAMESPACE));
this.wsdlDefinition.setQName(new QName(WSDLConstants.NS_WSDL11, (String) env.get(ToolConstants.CFG_NAME)));
Types types = this.wsdlDefinition.createTypes();
ExtensibilityElement extElement;
try {
registry = wsdlFactory.newPopulatedExtensionRegistry();
registerJAXWSBinding(Definition.class);
registerJAXWSBinding(Types.class);
registerJAXWSBinding(Schema.class);
extElement = registry.createExtension(Types.class, WSDLConstants.QNAME_SCHEMA);
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SCHEMA_EXTENSION", LOG);
throw new ToolException(msg, wse);
}
((Schema) extElement).setElement(targetElement);
types.addExtensibilityElement(extElement);
this.wsdlDefinition.setTypes(types);
WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
Writer outputWriter = getOutputWriter();
try {
wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG);
throw new ToolException(msg, wse);
}
try {
outputWriter.close();
} catch (IOException ioe) {
Message msg = new Message("FAIL_TO_CLOSE_WSDL_FILE", LOG);
throw new ToolException(msg, ioe);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class XSDToWSDLProcessor method initXSD.
private void initXSD() throws ToolException {
InputStream in;
try {
in = new URL(xsdUrl).openStream();
} catch (Exception m) {
try {
in = Files.newInputStream(Paths.get(xsdUrl));
} catch (IOException ioe) {
Message msg = new Message("FAIL_TO_OPEN_XSD_FILE", LOG, xsdUrl);
throw new ToolException(msg, ioe);
}
}
if (in == null) {
throw new NullPointerException("Cannot create a ToolSpec object from a null stream");
}
try {
xsdBuilder.setValidating(false);
this.xsdDoc = xsdBuilder.parse(in);
} catch (Exception ex) {
Message msg = new Message("FAIL_TO_PARSE_TOOLSPEC", LOG);
throw new ToolException(msg, ex);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class AbstractWSDLToProcessor method getOutputWriter.
protected Writer getOutputWriter(String newNameExt) throws ToolException {
final String newName;
final String outputDir;
if (env.get(ToolConstants.CFG_OUTPUTFILE) != null) {
newName = (String) env.get(ToolConstants.CFG_OUTPUTFILE);
} else {
String oldName = (String) env.get(ToolConstants.CFG_WSDLURL);
int position = oldName.lastIndexOf('/');
if (position < 0) {
position = oldName.lastIndexOf('\\');
}
if (position >= 0) {
oldName = oldName.substring(position + 1, oldName.length());
}
if (oldName.toLowerCase().indexOf(WSDL_FILE_NAME_EXT) >= 0) {
newName = oldName.substring(0, oldName.length() - 5) + newNameExt + WSDL_FILE_NAME_EXT;
} else {
newName = oldName + newNameExt;
}
}
if (env.get(ToolConstants.CFG_OUTPUTDIR) != null) {
outputDir = (String) env.get(ToolConstants.CFG_OUTPUTDIR);
} else {
outputDir = "./";
}
FileWriterUtil fw = new FileWriterUtil(outputDir, env.get(OutputStreamCreator.class));
try {
return fw.getWriter("", newName);
} catch (IOException ioe) {
Message msg = new Message("FAIL_TO_WRITE_FILE", LOG, env.get(ToolConstants.CFG_OUTPUTDIR) + System.getProperty("file.seperator") + newName);
throw new ToolException(msg, ioe);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class WSDLToSoapProcessor method getSoapBody.
private SoapBody getSoapBody(Class<?> parent) throws ToolException {
if (extReg == null) {
extReg = wsdlFactory.newPopulatedExtensionRegistry();
}
final SoapBody soapBody;
try {
soapBody = SOAPBindingUtil.createSoapBody(extReg, parent, isSOAP12());
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
throw new ToolException(msg, wse);
}
soapBody.setUse((String) env.get(ToolConstants.CFG_USE));
if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE)) && env.optionSet(ToolConstants.CFG_NAMESPACE)) {
soapBody.setNamespaceURI((String) env.get(ToolConstants.CFG_NAMESPACE));
}
return soapBody;
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class WSDLToSoapProcessor method setSoapBindingExtElement.
private void setSoapBindingExtElement() throws ToolException {
if (extReg == null) {
extReg = wsdlFactory.newPopulatedExtensionRegistry();
}
SOAPBindingUtil.addSOAPNamespace(wsdlDefinition, isSOAP12());
final SoapBinding soapBinding;
try {
soapBinding = SOAPBindingUtil.createSoapBinding(extReg, isSOAP12());
} catch (WSDLException wse) {
Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
throw new ToolException(msg, wse);
}
soapBinding.setStyle((String) env.get(ToolConstants.CFG_STYLE));
binding.addExtensibilityElement(soapBinding);
}
Aggregations