use of javax.wsdl.xml.WSDLReader in project Activiti by Activiti.
the class WSDLImporter method parseWSDLDefinition.
/**
* Parse the WSDL definition using WSDL4J.
*/
private Definition parseWSDLDefinition() throws WSDLException {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader reader = wsdlFactory.newWSDLReader();
reader.setFeature("javax.wsdl.verbose", false);
reader.setFeature("javax.wsdl.importDocuments", true);
Definition definition = reader.readWSDL(this.wsdlLocation);
return definition;
}
use of javax.wsdl.xml.WSDLReader in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method init.
/**
* {@inheritDoc}
* Will return true if the provided WSDL is of 1.1 and can be successfully parsed by WSDL4J.
*/
@Override
public boolean init(byte[] wsdlContent) throws APIMgtWSDLException {
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(null, new InputSource(new ByteArrayInputStream(wsdlContent)));
canProcess = true;
if (log.isDebugEnabled()) {
log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
}
} catch (WSDLException e) {
// This implementation class cannot process the WSDL.
log.debug("Cannot process the WSDL by " + this.getClass().getName(), e);
canProcess = false;
}
return canProcess;
}
use of javax.wsdl.xml.WSDLReader in project wso2-synapse by wso2.
the class ProxyServiceTest method testWSDLWithoutPublishWSDL.
/**
* Test that a proxy service without publishWSDL will produce a meaningful WSDL.
* This is a regression test for SYNAPSE-366.
*/
public void testWSDLWithoutPublishWSDL() throws Exception {
// Build the proxy service
SynapseConfiguration synCfg = new SynapseConfiguration();
AxisConfiguration axisCfg = new AxisConfiguration();
ProxyService proxyService = new ProxyService("Test");
AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg);
// Serialize the WSDL
ByteArrayOutputStream baos = new ByteArrayOutputStream();
axisService.printWSDL(baos);
// Check that the produced WSDL can be read by WSDL4J
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.readWSDL(null, new InputSource(new ByteArrayInputStream(baos.toByteArray())));
}
use of javax.wsdl.xml.WSDLReader in project wso2-synapse by wso2.
the class WSDL11EndpointBuilder method populateEndpointDefinitionFromWSDL.
/**
* Creates an EndpointDefinition for WSDL endpoint from an inline WSDL supplied in the WSDL
* endpoint configuration.
*
* @param endpointDefinition the endpoint definition to populate
* @param baseUri base uri of the wsdl
* @param wsdl OMElement representing the inline WSDL
* @param service Service of the endpoint
* @param port Port of the endpoint
* @return EndpointDefinition containing the information retrieved from the WSDL
*/
public EndpointDefinition populateEndpointDefinitionFromWSDL(EndpointDefinition endpointDefinition, String baseUri, OMElement wsdl, String service, String port) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
wsdl.serialize(baos);
InputStream in = new ByteArrayInputStream(baos.toByteArray());
InputSource inputSource = new InputSource(in);
WSDLLocator wsdlLocator = new CustomWSDLLocator(inputSource, baseUri);
Document doc = null;
try {
doc = XMLUtils.newDocument(inputSource);
} catch (ParserConfigurationException e) {
handleException("Parser Configuration Error", e);
} catch (SAXException e) {
handleException("Parser SAX Error", e);
} catch (IOException e) {
handleException(WSDLException.INVALID_WSDL + "IO Error", e);
}
if (doc != null) {
WSDLFactory fac = WSDLFactory.newInstance();
WSDLReader reader = fac.newWSDLReader();
Definition definition = reader.readWSDL(wsdlLocator, doc.getDocumentElement());
return createEndpointDefinitionFromWSDL(endpointDefinition, definition, service, port);
}
} catch (XMLStreamException e) {
handleException("Error retrieving the WSDL definition from the inline WSDL.", e);
} catch (WSDLException e) {
handleException("Error retrieving the WSDL definition from the inline WSDL.", e);
}
return null;
}
use of javax.wsdl.xml.WSDLReader in project carbon-business-process by wso2.
the class ArchiveBasedHumanTaskDeploymentUnitBuilder method readInTheWSDLFile.
/**
* Read the WSDL file given the input stream for the WSDL source
*
* @param in WSDL input stream
* @param entryName ZIP file entry name
* @param fromRegistry whether the wsdl is read from registry
* @return WSDL Definition
* @throws javax.wsdl.WSDLException at parser error
*/
public static Definition readInTheWSDLFile(InputStream in, String entryName, boolean fromRegistry) throws WSDLException {
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
// switch off the verbose mode for all usecases
reader.setFeature(HumanTaskConstants.JAVAX_WSDL_VERBOSE_MODE_KEY, false);
reader.setFeature("javax.wsdl.importDocuments", true);
Definition def;
Document doc;
try {
doc = XMLUtils.newDocument(in);
} catch (ParserConfigurationException e) {
throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Error", e);
} catch (SAXException e) {
throw new WSDLException(WSDLException.PARSER_ERROR, "Parser SAX Error", e);
} catch (IOException e) {
throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
}
// Log when and from where the WSDL is loaded.
if (log.isDebugEnabled()) {
log.debug("Reading 1.1 WSDL with base uri = " + entryName);
log.debug(" the document base uri = " + entryName);
}
if (fromRegistry) {
throw new UnsupportedOperationException("This operation is not currently " + "supported in this version of WSO2 BPS.");
} else {
def = reader.readWSDL(entryName, doc.getDocumentElement());
}
def.setDocumentBaseURI(entryName);
return def;
}
Aggregations