public static IStatus isWSDLAccessible(URL contextURL) {
    Properties props = System.getProperties();
    String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);

    props.setProperty(DEF_FACTORY_PROPERTY_NAME, PRIVATE_DEF_FACTORY_CLASS);

    WSDLFactory factory;
    try {
      factory = WSDLFactory.newInstance();
      WSDLReader wsdlReader = factory.newWSDLReader();
      wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
      wsdlReader.setFeature("javax.wsdl.importDocuments", true); // $NON-NLS-1$
      String context = null;
      if (contextURL != null) context = contextURL.toString();
      wsdlReader.readWSDL(context);
    } catch (WSDLException e) {
      if (contextURL.getProtocol().equalsIgnoreCase("https")) { // $NON-NLS-1$
        return StatusUtils.warningStatus(
            JBossWSUIMessages.TesterWSDLUtils_WSDL_HTTPS_Secured_Inaccessible);
      } else {
        return StatusUtils.errorStatus(JBossWSUIMessages.TesterWSDLUtils_WSDL_Inaccessible, e);
      }
    }

    if (oldPropValue != null) {
      props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
    } else {
      props.remove(DEF_FACTORY_PROPERTY_NAME);
    }
    return Status.OK_STATUS;
  }
Пример #2
0
  /**
   * Create the WSDL definition <javax.wsdl.Definition> from the baseURI of the WSDL
   *
   * @return {@link Definition} - WSDL4j definition constructed form the wsdl original baseuri
   * @throws APIManagementException
   * @throws WSDLException
   */
  private Definition readWSDLFile() throws APIManagementException, WSDLException {
    WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
    // switch off the verbose mode
    reader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
    reader.setFeature("javax.wsdl.importDocuments", false);

    Definition wsdlDefinition;
    if (log.isDebugEnabled()) {
      log.debug("Reading  the WSDL. Base uri is " + baseURI);
    }
    wsdlDefinition = reader.readWSDL(baseURI);
    return wsdlDefinition;
  }
  public static Definition readWSDLURL(URL contextURL, String wsdlLoc) throws WSDLException {
    Properties props = System.getProperties();
    String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);

    props.setProperty(DEF_FACTORY_PROPERTY_NAME, PRIVATE_DEF_FACTORY_CLASS);

    WSDLFactory factory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = factory.newWSDLReader();
    wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
    wsdlReader.setFeature("javax.wsdl.importDocuments", true); // $NON-NLS-1$
    String context = null;
    if (contextURL != null) context = contextURL.toString();
    Definition def = wsdlReader.readWSDL(context, wsdlLoc);

    if (oldPropValue != null) {
      props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
    } else {
      props.remove(DEF_FACTORY_PROPERTY_NAME);
    }
    return def;
  }
Пример #4
0
 private org.apache.woden.wsdl20.Description readWSDL2File()
     throws APIManagementException, WSDLException {
   WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
   reader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
   reader.setFeature("javax.wsdl.importDocuments", false);
   try {
     org.apache.woden.WSDLFactory wFactory = org.apache.woden.WSDLFactory.newInstance();
     org.apache.woden.WSDLReader wReader = wFactory.newWSDLReader();
     wReader.setFeature(org.apache.woden.WSDLReader.FEATURE_VALIDATION, true);
     //            wReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
     //            wReader.setFeature("javax.wsdl.importDocuments", false);
     return wReader.readWSDL(baseURI);
   } catch (org.apache.woden.WSDLException e) {
     String error = "Error occurred reading wsdl document.";
     log.error(error);
   }
   if (log.isDebugEnabled()) {
     log.debug("Reading  the WSDL. Base uri is " + baseURI);
   }
   return null;
 }
Пример #5
0
  @Test
  public void testWSDLLocatorWithDefaultCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);

    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();

    CatalogWSDLLocator wsdlLocator =
        new CatalogWSDLLocator(wsdl.toString(), OASISCatalogManager.getCatalogManager(null));
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    wsdlReader.readWSDL(wsdlLocator);
  }
Пример #6
0
 public File writeDefinition(File targetDir, File defnFile) throws Exception {
   File bkFile = new File(targetDir, "bk_" + defnFile.getName());
   FileWriter writer = new FileWriter(bkFile);
   WSDLFactory factory =
       WSDLFactory.newInstance("org.apache.cxf.tools.corba.utils.TestWSDLCorbaFactoryImpl");
   WSDLReader reader = factory.newWSDLReader();
   reader.setFeature("javax.wsdl.importDocuments", false);
   ExtensionRegistry extReg = new ExtensionRegistry();
   addExtensions(extReg);
   reader.setExtensionRegistry(extReg);
   Definition wsdlDefn = reader.readWSDL(defnFile.toString());
   WSDLWriter wsdlWriter = factory.newWSDLWriter();
   wsdlWriter.writeWSDL(wsdlDefn, writer);
   writer.close();
   writer = null;
   reader = null;
   return bkFile;
 }
Пример #7
0
  @Test
  public void testWSDLLocatorWithoutCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);

    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);

    OASISCatalogManager catalog = new OASISCatalogManager();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), catalog);
    try {
      wsdlReader.readWSDL(wsdlLocator);
      fail("Test did not fail as expected");
    } catch (WSDLException e) {
      // ignore
    }
  }