use of org.apache.woden.WSDLWriter in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method getUpdatedWSDLPath.
/**
* Updates the endpoints of all the WSDL files in the path based on the provided API (context) and Label (host).
*
* @param api Provided API object
* @param label Provided label object
* @return Updated WSDL file path
* @throws APIMgtWSDLException Error while updating WSDL files
*/
@Override
public String getUpdatedWSDLPath(API api, Label label) throws APIMgtWSDLException {
if (label != null) {
for (Map.Entry<String, Description> entry : pathToDescriptionMap.entrySet()) {
Description description = entry.getValue();
if (log.isDebugEnabled()) {
log.debug("Updating endpoints of WSDL: " + entry.getKey());
}
updateEndpoints(label.getAccessUrls(), api, description);
if (log.isDebugEnabled()) {
log.debug("Successfully updated endpoints of WSDL: " + entry.getKey());
}
try (FileOutputStream wsdlFileOutputStream = new FileOutputStream(new File(entry.getKey()))) {
WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
writer.writeWSDL(description.toElement(), wsdlFileOutputStream);
} catch (IOException | WSDLException e) {
throw new APIMgtWSDLException("Failed to create WSDL archive for API:" + api.getName() + ":" + api.getVersion() + " for label " + label.getName(), ExceptionCodes.ERROR_WHILE_CREATING_WSDL_ARCHIVE);
}
}
}
return wsdlArchiveExtractedPath;
}
use of org.apache.woden.WSDLWriter in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method getWSDL.
/**
* {@inheritDoc}
* @return WSDL 2.0 content bytes
*/
@Override
public byte[] getWSDL() throws APIMgtWSDLException {
WSDLWriter writer;
try {
writer = getWsdlFactoryInstance().newWSDLWriter();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
writer.writeWSDL(wsdlDescription.toElement(), byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
} catch (WSDLException e) {
throw new APIMgtWSDLException("Error while stringifying WSDL definition", e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
}
Aggregations