Esempio n. 1
0
  /*
   * 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.
   */
  private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
    // try MEX
    MetaDataResolver resolver;
    ServiceDescriptor serviceDescriptor = null;
    for (MetadataResolverFactory resolverFactory :
        ServiceFinder.find(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;
  }