use of javax.wsdl.WSDLException in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method init.
@Override
public boolean init(URL url) throws APIMgtWSDLException {
setMode(Mode.SINGLE);
WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
// switch off the verbose mode
wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);
try {
wsdlDefinition = wsdlReader.readWSDL(url.toString(), getSecuredParsedDocumentFromURL(url));
if (log.isDebugEnabled()) {
log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
}
} catch (WSDLException | APIManagementException e) {
// This implementation class cannot process the WSDL.
log.debug("Cannot process the WSDL by " + this.getClass().getName(), e);
setError(new ErrorItem(ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorMessage(), e.getMessage(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorCode(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getHttpStatusCode()));
}
return !hasError;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class SoapTransportFactory method createSoapExtensors.
private void createSoapExtensors(Bus bus, EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12) {
try {
String address = ei.getAddress();
if (address == null) {
address = "http://localhost:9090";
}
ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
SoapAddress soapAddress = SOAPBindingUtil.createSoapAddress(registry, isSoap12);
soapAddress.setLocationURI(address);
ei.addExtensor(soapAddress);
} catch (WSDLException e) {
e.printStackTrace();
}
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class SoapBindingFactory method createBindingInfo.
public BindingInfo createBindingInfo(ServiceInfo si, String bindingid, Object conf) {
SoapBindingConfiguration config;
if (conf instanceof SoapBindingConfiguration) {
config = (SoapBindingConfiguration) conf;
} else {
config = new SoapBindingConfiguration();
}
if (WSDLConstants.NS_SOAP12.equals(bindingid) || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(bindingid)) {
config.setVersion(Soap12.getInstance());
config.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
}
SoapBindingInfo info = new SoapBindingInfo(si, bindingid, config.getVersion());
info.setName(config.getBindingName(si));
info.setStyle(config.getStyle());
info.setTransportURI(config.getTransportURI());
if (config.isMtomEnabled()) {
info.setProperty(Message.MTOM_ENABLED, Boolean.TRUE);
}
for (OperationInfo op : si.getInterface().getOperations()) {
SoapOperationInfo sop = new SoapOperationInfo();
sop.setAction(config.getSoapAction(op));
sop.setStyle(config.getStyle(op));
BindingOperationInfo bop = info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());
bop.addExtensor(sop);
info.addOperation(bop);
BindingMessageInfo bInput = bop.getInput();
if (bInput != null) {
final MessageInfo input;
BindingMessageInfo unwrappedMsg = bInput;
if (bop.isUnwrappedCapable()) {
input = bop.getOperationInfo().getUnwrappedOperation().getInput();
unwrappedMsg = bop.getUnwrappedOperation().getInput();
} else {
input = bop.getOperationInfo().getInput();
}
setupHeaders(bop, bInput, unwrappedMsg, input, config);
}
BindingMessageInfo bOutput = bop.getOutput();
if (bOutput != null) {
final MessageInfo output;
BindingMessageInfo unwrappedMsg = bOutput;
if (bop.isUnwrappedCapable()) {
output = bop.getOperationInfo().getUnwrappedOperation().getOutput();
unwrappedMsg = bop.getUnwrappedOperation().getOutput();
} else {
output = bop.getOperationInfo().getOutput();
}
setupHeaders(bop, bOutput, unwrappedMsg, output, config);
}
}
try {
createSoapBinding(info);
} catch (WSDLException e) {
e.printStackTrace();
}
return info;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDLManagerImpl method getDefinition.
public Definition getDefinition(final Element el) throws WSDLException {
synchronized (definitionsMap) {
if (definitionsMap.containsKey(el)) {
return definitionsMap.get(el);
}
}
final WSDLReader reader = factory.newWSDLReader();
reader.setFeature("javax.wsdl.verbose", false);
reader.setExtensionRegistry(registry);
final Definition def;
// This is needed to avoid security exceptions when running with a security manager
if (System.getSecurityManager() == null) {
def = reader.readWSDL("", el);
} else {
try {
def = AccessController.doPrivileged((PrivilegedExceptionAction<Definition>) () -> reader.readWSDL("", el));
} catch (PrivilegedActionException paex) {
throw new WSDLException(WSDLException.PARSER_ERROR, paex.getMessage(), paex);
}
}
synchronized (definitionsMap) {
definitionsMap.put(el, def);
}
return def;
}
use of javax.wsdl.WSDLException in project cxf by apache.
the class WSDLManagerImpl method loadDefinition.
protected Definition loadDefinition(String url) throws WSDLException {
final WSDLReader reader = factory.newWSDLReader();
reader.setFeature("javax.wsdl.verbose", false);
reader.setFeature("javax.wsdl.importDocuments", true);
reader.setExtensionRegistry(registry);
// we'll create a new String here to make sure the passed in key is not referenced in the loading of
// the wsdl and thus would be held onto from the cached map from both the weak reference (key) and
// from the strong reference (Definition). For example, the Definition sometimes keeps the original
// string as the documentBaseLocation which would result in it being held onto strongly
// from the definition. With this, the String the definition holds onto would be unique
url = new String(url);
CatalogWSDLLocator catLocator = new CatalogWSDLLocator(url, bus);
final ResourceManagerWSDLLocator wsdlLocator = new ResourceManagerWSDLLocator(url, catLocator, bus);
InputSource src = wsdlLocator.getBaseInputSource();
final Definition def;
if (src.getByteStream() != null || src.getCharacterStream() != null) {
final Document doc;
XMLStreamReader xmlReader = null;
try {
xmlReader = StaxUtils.createXMLStreamReader(src);
if (xmlStreamReaderWrapper != null) {
xmlReader = xmlStreamReaderWrapper.wrap(xmlReader);
}
doc = StaxUtils.read(xmlReader, true);
if (src.getSystemId() != null) {
try {
doc.setDocumentURI(new String(src.getSystemId()));
} catch (Exception e) {
// ignore - probably not DOM level 3
}
}
} catch (Exception e) {
throw new WSDLException(WSDLException.PARSER_ERROR, e.getMessage(), e);
} finally {
try {
StaxUtils.close(xmlReader);
} catch (XMLStreamException ex) {
throw new WSDLException(WSDLException.PARSER_ERROR, ex.getMessage(), ex);
}
}
// This is needed to avoid security exceptions when running with a security manager
if (System.getSecurityManager() == null) {
def = reader.readWSDL(wsdlLocator, doc.getDocumentElement());
} else {
try {
def = AccessController.doPrivileged((PrivilegedExceptionAction<Definition>) () -> reader.readWSDL(wsdlLocator, doc.getDocumentElement()));
} catch (PrivilegedActionException paex) {
throw new WSDLException(WSDLException.PARSER_ERROR, paex.getMessage(), paex);
}
}
} else {
if (System.getSecurityManager() == null) {
def = reader.readWSDL(wsdlLocator);
} else {
try {
def = AccessController.doPrivileged((PrivilegedExceptionAction<Definition>) () -> reader.readWSDL(wsdlLocator));
} catch (PrivilegedActionException paex) {
throw new WSDLException(WSDLException.PARSER_ERROR, paex.getMessage(), paex);
}
}
}
return def;
}
Aggregations