use of com.sun.xml.ws.api.wsdl.parser.ServiceDescriptor in project metro-jax-ws by eclipse-ee4j.
the class MetadataFinder method getFromMetadataResolver.
/*
* If source and target namespace are also passed in,
* then if the mex resolver is found and it cannot get
* the data, wsimport attempts to add ?wsdl to the
* address and retrieve the data with a normal http get.
* This behavior should only happen when trying a
* mex request first.
*/
@Nullable
private Element getFromMetadataResolver(String systemId, Exception ex) {
// try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class, ServiceLoader.load(MetadataResolverFactory.class))) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
// we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
use of com.sun.xml.ws.api.wsdl.parser.ServiceDescriptor in project metro-jax-ws by eclipse-ee4j.
the class RuntimeWSDLParser method parseUsingMex.
private WSDLModel parseUsingMex(@NotNull URL wsdlLoc, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Class serviceClass, PolicyResolver policyResolver, WSDLParserExtension[] extensions) throws IOException, SAXException, XMLStreamException, URISyntaxException {
// try MEX
MetaDataResolver mdResolver = null;
ServiceDescriptor serviceDescriptor = null;
RuntimeWSDLParser wsdlParser = null;
// Currently we try the first available MetadataResolverFactory that gives us a WSDL document
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
mdResolver = resolverFactory.metadataResolver(resolver);
serviceDescriptor = mdResolver.resolve(wsdlLoc.toURI());
// we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
}
if (serviceDescriptor != null) {
List<? extends Source> wsdls = serviceDescriptor.getWSDLs();
wsdlParser = new RuntimeWSDLParser(wsdlLoc.toExternalForm(), new MexEntityResolver(wsdls), isClientSide, container, policyResolver, extensions);
wsdlParser.extensionFacade.start(wsdlParser.context);
for (Source src : wsdls) {
String systemId = src.getSystemId();
Parser parser = wsdlParser.resolver.resolveEntity(null, systemId);
wsdlParser.parseWSDL(parser, false);
}
}
// it a last shot else fail
if ((mdResolver == null || serviceDescriptor == null) && (wsdlLoc.getProtocol().equals("http") || wsdlLoc.getProtocol().equals("https")) && (wsdlLoc.getQuery() == null)) {
String urlString = wsdlLoc.toExternalForm();
urlString += "?wsdl";
wsdlLoc = new URL(urlString);
wsdlParser = new RuntimeWSDLParser(wsdlLoc.toExternalForm(), new EntityResolverWrapper(resolver), isClientSide, container, policyResolver, extensions);
wsdlParser.extensionFacade.start(wsdlParser.context);
Parser parser = resolveWSDL(wsdlLoc, new StreamSource(wsdlLoc.toExternalForm()), serviceClass);
wsdlParser.parseWSDL(parser, false);
}
if (wsdlParser == null)
return null;
wsdlParser.wsdlDoc.freeze();
wsdlParser.extensionFacade.finished(wsdlParser.context);
wsdlParser.extensionFacade.postFinished(wsdlParser.context);
return wsdlParser.wsdlDoc;
}
Aggregations