use of javax.wsdl.xml.WSDLLocator 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;
}
Aggregations