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; }
public synchronized Definition get(String url) throws WSDLException { Definition definition = cache.get(url); if (definition == null) { WSDLReader reader = factory.newWSDLReader(); definition = reader.readWSDL(url); cache.put(url, definition); } return definition; }
@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); }
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; }
@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 } }
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; }