use of org.wso2.carbon.apimgt.api.model.Wsdl in project carbon-apimgt by wso2.
the class APIMWSDLReader method setServiceDefinition.
/**
* Clear the actual service Endpoint and use Gateway Endpoint instead of the
* actual Endpoint.
*
* @param definition
* - {@link Definition} - WSDL4j wsdl definition
* @throws APIManagementException
*/
private void setServiceDefinition(Definition definition, API api) throws APIManagementException {
Map serviceMap = definition.getAllServices();
Iterator serviceItr = serviceMap.entrySet().iterator();
URL addressURI;
try {
while (serviceItr.hasNext()) {
Map.Entry svcEntry = (Map.Entry) serviceItr.next();
Service svc = (Service) svcEntry.getValue();
Map portMap = svc.getPorts();
for (Object o : portMap.entrySet()) {
Map.Entry portEntry = (Map.Entry) o;
Port port = (Port) portEntry.getValue();
List<ExtensibilityElement> extensibilityElementList = port.getExtensibilityElements();
for (ExtensibilityElement extensibilityElement : extensibilityElementList) {
addressURI = new URL(getAddressUrl(extensibilityElement));
String endpointTransport = determineURLTransport(addressURI.getProtocol(), api.getTransports());
setAddressUrl(extensibilityElement, endpointTransport, api);
}
}
}
} catch (Exception e) {
String errorMsg = "Error occurred while getting the wsdl address location";
log.error(errorMsg, e);
throw new APIManagementException(errorMsg, e);
}
}
use of org.wso2.carbon.apimgt.api.model.Wsdl in project carbon-apimgt by wso2.
the class APIMWSDLReader method isWSDL2BaseURI.
/**
* Given a URL, this method checks if the underlying document is a WSDL2
*
* @return true if the underlying document is a WSDL2
* @throws APIManagementException if error occurred while checking whether baseURI is WSDL2.0
*/
@Deprecated
public boolean isWSDL2BaseURI() throws APIManagementException {
URL wsdl;
boolean isWsdl2 = false;
BufferedReader in = null;
try {
wsdl = new URL(baseURI);
in = new BufferedReader(new InputStreamReader(wsdl.openStream(), Charset.defaultCharset()));
String inputLine;
StringBuilder urlContent = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
urlContent.append(inputLine);
isWsdl2 = urlContent.indexOf(WSDL20_NAMESPACE) > 0;
}
} catch (MalformedURLException e) {
throw new APIManagementException("Malformed URL encountered", e);
} catch (IOException e) {
throw new APIManagementException("Error Reading Input from Stream from " + baseURI, e);
} finally {
IOUtils.closeQuietly(in);
}
try {
if (isWsdl2) {
readAndValidateWSDL20();
}
} catch (org.apache.woden.WSDLException e) {
throw new APIManagementException("Error while reading WSDL Document from " + baseURI, e);
}
return isWsdl2;
}
use of org.wso2.carbon.apimgt.api.model.Wsdl in project carbon-apimgt by wso2.
the class APIMWSDLReader method getSecuredParsedDocumentFromContent.
/**
* Returns an "XXE safe" built DOM XML object by reading the content from the byte array.
*
* @param content xml content
* @return an "XXE safe" built DOM XML object by reading the content from the byte array
* @throws APIManagementException When error occurred while reading from the byte array
*/
@Deprecated
private Document getSecuredParsedDocumentFromContent(byte[] content) throws APIManagementException {
String errorMsg = "Error while reading WSDL document";
InputStream inputStream = null;
try {
DocumentBuilderFactory factory = getSecuredDocumentBuilder();
DocumentBuilder builder = factory.newDocumentBuilder();
inputStream = new ByteArrayInputStream(content);
return builder.parse(inputStream);
} catch (ParserConfigurationException e) {
throw new APIManagementException(errorMsg, e);
} catch (IOException e) {
throw new APIManagementException(errorMsg, e);
} catch (SAXException e) {
throw new APIManagementException(errorMsg, e);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
use of org.wso2.carbon.apimgt.api.model.Wsdl in project carbon-apimgt by wso2.
the class APIMWSDLReader method getWSDLSOAPOperationExtractor.
/**
* Returns a WSDL11SOAPOperationExtractor for the WSDL byte content {@code content}. Only WSDL 1.1 is supported.
*
* @param content WSDL byte[] content
* @return WSDL11SOAPOperationExtractor for the provided URL
* @throws APIManagementException If an error occurs while determining the processor
*/
public static WSDL11SOAPOperationExtractor getWSDLSOAPOperationExtractor(byte[] content) throws APIManagementException {
WSDL11SOAPOperationExtractor processor = new WSDL11SOAPOperationExtractor();
processor.init(content);
return processor;
}
use of org.wso2.carbon.apimgt.api.model.Wsdl in project carbon-apimgt by wso2.
the class APIMWSDLReader method getWSDLSOAPOperationExtractorForUrl.
/**
* Returns a WSDL11SOAPOperationExtractor for the url {@code url}. Only WSDL 1.1 is supported.
*
* @param url WSDL url
* @return WSDL11SOAPOperationExtractor for the provided URL
* @throws APIManagementException If an error occurs while determining the processor
*/
public static WSDL11SOAPOperationExtractor getWSDLSOAPOperationExtractorForUrl(URL url) throws APIManagementException {
WSDL11SOAPOperationExtractor processor = new WSDL11SOAPOperationExtractor();
processor.init(url);
return processor;
}
Aggregations