Java Code Examples for javax.wsdl.xml.WSDLReader#setFeature()
The following examples show how to use
javax.wsdl.xml.WSDLReader#setFeature() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BPELPlanContext.java From container with Apache License 2.0 | 6 votes |
/** * Returns the Services inside the given WSDL file which implement the given portType * * @param portType the portType to search with * @param wsdlFile the WSDL file to look in * @return a List of Service which implement the given portType * @throws WSDLException is thrown when the WSDLFactory to read the WSDL can't be initialized */ private List<Service> getServicesInWSDLFile(final Path wsdlFile, final QName portType) throws WSDLException { final List<Service> servicesInWsdl = new ArrayList<>(); final WSDLFactory factory = WSDLFactory.newInstance(); final WSDLReader reader = factory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); final Definition wsdlInstance = reader.readWSDL(wsdlFile.toAbsolutePath().toString()); final Map services = wsdlInstance.getAllServices(); for (final Object key : services.keySet()) { final Service service = (Service) services.get(key); final Map ports = service.getPorts(); for (final Object portKey : ports.keySet()) { final Port port = (Port) ports.get(portKey); if (port.getBinding().getPortType().getQName().getNamespaceURI().equals(portType.getNamespaceURI()) && port.getBinding().getPortType().getQName().getLocalPart().equals(portType.getLocalPart())) { servicesInWsdl.add(service); } } } return servicesInWsdl; }
Example 2
Source File: CXFServletTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testGetWSDLWithMultiplePublishedEndpointUrl() throws Exception { ServletUnitClient client = newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter5?wsdl"); WebResponse res = client.getResponse(req); assertEquals(200, res.getResponseCode()); assertEquals("text/xml", res.getContentType()); Document doc = StaxUtils.read(res.getInputStream()); assertNotNull(doc); WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); assertValid("//wsdl:service[@name='SOAPService']/wsdl:port[@name='SoapPort']/wsdlsoap:address[@location='" + "http://cxf.apache.org/publishedEndpointUrl1']", doc); assertValid("//wsdl:service[@name='SOAPService']/wsdl:port[@name='SoapPort1']/wsdlsoap:address[@location='" + "http://cxf.apache.org/publishedEndpointUrl2']", doc); }
Example 3
Source File: WSDL11ProcessorImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Override public boolean init(URL url) throws APIMgtWSDLException { setMode(Mode.SINGLE); WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader(); // switch off the verbose mode wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false); wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false); try { wsdlDefinition = wsdlReader.readWSDL(url.toString(), getSecuredParsedDocumentFromURL(url)); if (log.isDebugEnabled()) { log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL."); } } catch (WSDLException | APIManagementException e) { //This implementation class cannot process the WSDL. log.debug("Cannot process the WSDL by " + this.getClass().getName(), e); setError(new ErrorItem(ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorMessage(), e.getMessage(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorCode(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getHttpStatusCode())); } return !hasError; }
Example 4
Source File: WSDL11ProcessorImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Override public boolean init(byte[] wsdlContent) throws APIMgtWSDLException { setMode(Mode.SINGLE); WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader(); // switch off the verbose mode wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false); wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false); try { wsdlDefinition = wsdlReader.readWSDL(null, getSecuredParsedDocumentFromContent(wsdlContent)); if (log.isDebugEnabled()) { log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL."); } } catch (WSDLException | APIManagementException e) { //This implementation class cannot process the WSDL. log.debug("Cannot process the WSDL by " + this.getClass().getName(), e); setError(new ErrorItem(ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorMessage(), e.getMessage(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorCode(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getHttpStatusCode())); } return !hasError; }
Example 5
Source File: APIMWSDLReader.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * 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 */ @Deprecated 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_IMPORT_DOCUMENTS, false); if (reader instanceof WSDLReaderImpl) { ((WSDLReaderImpl) reader).setIgnoreSchemaContent(true); } if (log.isDebugEnabled()) { log.debug("Reading the WSDL. Base uri is " + baseURI); } return reader.readWSDL(null, getSecuredParsedDocumentFromURL(baseURI)); }
Example 6
Source File: APIMWSDLReader.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Deprecated 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_IMPORT_DOCUMENTS, 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); Document document = getSecuredParsedDocumentFromURL(baseURI); Element domElement = document.getDocumentElement(); WSDLSource wsdlSource = wReader.createWSDLSource(); wsdlSource.setSource(domElement); return wReader.readWSDL(wsdlSource); } catch (org.apache.woden.WSDLException e) { String error = "Error occurred reading wsdl document."; log.error(error, e); } if (log.isDebugEnabled()) { log.debug("Reading the WSDL. Base uri is " + baseURI); } return null; }
Example 7
Source File: BPELPlanContext.java From container with Apache License 2.0 | 6 votes |
/** * Returns a List of Port which implement the given portType inside the given WSDL File * * @param portType the portType to use * @param wsdlFile the WSDL File to look in * @return a List of Port which implement the given PortType * @throws WSDLException is thrown when the given File is not a WSDL File or initializing the WSDL Factory failed */ public List<Port> getPortsInWSDLFileForPortType(final QName portType, final File wsdlFile) throws WSDLException { final List<Port> wsdlPorts = new ArrayList<>(); // taken from http://www.java.happycodings.com/Other/code24.html final WSDLFactory factory = WSDLFactory.newInstance(); final WSDLReader reader = factory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); final Definition wsdlInstance = reader.readWSDL(wsdlFile.getAbsolutePath()); final Map services = wsdlInstance.getAllServices(); for (final Object key : services.keySet()) { final Service service = (Service) services.get(key); final Map ports = service.getPorts(); for (final Object portKey : ports.keySet()) { final Port port = (Port) ports.get(portKey); if (port.getBinding().getPortType().getQName().getNamespaceURI().equals(portType.getNamespaceURI()) && port.getBinding().getPortType().getQName().getLocalPart().equals(portType.getLocalPart())) { wsdlPorts.add(port); } } } return wsdlPorts; }
Example 8
Source File: BPELPlanContext.java From container with Apache License 2.0 | 6 votes |
/** * Checks whether the given portType is declared in the given WSDL File * * @param portType the portType to check with * @param wsdlFile the WSDL File to check in * @return true if the portType is declared in the given WSDL file * @throws WSDLException is thrown when either the given File is not a WSDL File or initializing the WSDL Factory * failed */ public boolean containsPortType(final QName portType, final Path wsdlFile) throws WSDLException { final WSDLFactory factory = WSDLFactory.newInstance(); final WSDLReader reader = factory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); final Definition wsdlInstance = reader.readWSDL(wsdlFile.toAbsolutePath().toString()); final Map portTypes = wsdlInstance.getAllPortTypes(); for (final Object key : portTypes.keySet()) { final PortType portTypeInWsdl = (PortType) portTypes.get(key); if (portTypeInWsdl.getQName().getNamespaceURI().equals(portType.getNamespaceURI()) && portTypeInWsdl.getQName().getLocalPart().equals(portType.getLocalPart())) { return true; } } return false; }
Example 9
Source File: WsdlXmlValidator.java From iaf with Apache License 2.0 | 6 votes |
@IbisDoc({"the wsdl to read the xsd's from", " "}) public void setWsdl(String wsdl) throws ConfigurationException { this.wsdl = wsdl; WSDLReader reader = FACTORY.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); reader.setFeature("javax.wsdl.importDocuments", true); ClassLoaderWSDLLocator wsdlLocator = new ClassLoaderWSDLLocator(getConfigurationClassLoader(), wsdl); URL url = wsdlLocator.getUrl(); if (wsdlLocator.getUrl() == null) { throw new ConfigurationException("Could not find WSDL: " + wsdl); } try { definition = reader.readWSDL(wsdlLocator); } catch (WSDLException e) { throw new ConfigurationException("WSDLException reading WSDL or import from url: " + url, e); } if (wsdlLocator.getIOException() != null) { throw new ConfigurationException("IOException reading WSDL or import from url: " + url, wsdlLocator.getIOException()); } }
Example 10
Source File: WSDLGenerationTester.java From cxf with Apache License 2.0 | 6 votes |
public File writeDefinition(File targetDir, File defnFile) throws Exception { WSDLManager wm = BusFactory.getThreadDefaultBus().getExtension(WSDLManager.class); 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); reader.setExtensionRegistry(wm.getExtensionRegistry()); final String url = defnFile.toString(); CatalogWSDLLocator locator = new CatalogWSDLLocator(url, (Bus)null); Definition wsdlDefn = reader.readWSDL(locator); WSDLWriter wsdlWriter = factory.newWSDLWriter(); wsdlWriter.writeWSDL(wsdlDefn, writer); writer.close(); writer = null; reader = null; return bkFile; }
Example 11
Source File: WSDLHelper.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public static Definition load(String wsdlLocation, String filenamePrefix) throws InvocationTargetException, WSDLException { WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader newWSDLReader = wsdlFactory.newWSDLReader(); newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry()); newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false); return newWSDLReader.readWSDL(new InMemoryWSDLLocator(wsdlLocation, new WSDLLoader().load(wsdlLocation, filenamePrefix + "%d.wsdl"))); }
Example 12
Source File: Wsdl.java From hop with Apache License 2.0 | 5 votes |
/** * Get a WSDLReader. * * @return WSDLReader. * @throws WSDLException on error. */ private WSDLReader getReader() throws WSDLException { WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); ExtensionRegistry registry = wsdlFactory.newPopulatedExtensionRegistry(); wsdlReader.setExtensionRegistry( registry ); wsdlReader.setFeature( "javax.wsdl.verbose", true ); wsdlReader.setFeature( "javax.wsdl.importDocuments", true ); return wsdlReader; }
Example 13
Source File: JAXBDataBindingTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { jaxbDataBinding = new JAXBDataBinding(); String wsdlUrl = getClass().getResource(WSDL_PATH).toString(); LOG.info("the path of wsdl file is " + wsdlUrl); WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); def = wsdlReader.readWSDL(wsdlUrl); control = EasyMock.createNiceControl(); bus = control.createMock(Bus.class); bindingFactoryManager = control.createMock(BindingFactoryManager.class); destinationFactoryManager = control.createMock(DestinationFactoryManager.class); EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager); EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)) .andStubReturn(destinationFactoryManager); control.replay(); WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus); for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) { if (serv != null) { service = serv; break; } } wsdlServiceBuilder.buildServices(def, service); }
Example 14
Source File: APIMWSDLReader.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Update WSDL 1.0 service definitions saved in registry * * @param wsdl byte array of registry content * @param api API object * @return the OMElemnt of the new WSDL content * @throws APIManagementException */ public OMElement updateWSDL(byte[] wsdl, API api) throws APIManagementException { try { // Generate wsdl document from registry data WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader(); // switch off the verbose mode wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false); wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false); if (wsdlReader instanceof WSDLReaderImpl) { ((WSDLReaderImpl) wsdlReader).setIgnoreSchemaContent(true); } Definition wsdlDefinition = wsdlReader.readWSDL(null, getSecuredParsedDocumentFromContent(wsdl)); // Update transports setServiceDefinition(wsdlDefinition, api); WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); writer.writeWSDL(wsdlDefinition, byteArrayOutputStream); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( byteArrayOutputStream.toByteArray()); return APIUtil.buildOMElement(byteArrayInputStream); } catch (Exception e) { String msg = " Error occurs when updating WSDL "; log.error(msg); throw new APIManagementException(msg, e); } }
Example 15
Source File: WSDLCache.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
public synchronized Definition get( String url ) throws WSDLException { Definition definition = cache.get( url ); if( definition == null ) { WSDLReader reader = factory.newWSDLReader(); reader.setFeature( "javax.wsdl.verbose", false ); definition = reader.readWSDL( url ); cache.put( url, definition ); } return definition; }
Example 16
Source File: ServiceWSDLBuilderTest.java From cxf with Apache License 2.0 | 5 votes |
private void setupWSDL(String wsdlPath, boolean doXsdImports) throws Exception { String wsdlUrl = getClass().getResource(wsdlPath).toString(); LOG.info("the path of wsdl file is " + wsdlUrl); WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); def = wsdlReader.readWSDL(wsdlUrl); control = EasyMock.createNiceControl(); bus = control.createMock(Bus.class); bindingFactoryManager = control.createMock(BindingFactoryManager.class); destinationFactoryManager = control.createMock(DestinationFactoryManager.class); destinationFactory = control.createMock(DestinationFactory.class); wsdlServiceBuilder = new WSDLServiceBuilder(bus, false); for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) { if (serv != null) { service = serv; break; } } EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(new WSDLManagerImpl()).anyTimes(); EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager); EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)) .andReturn(destinationFactoryManager); EasyMock.expect(destinationFactoryManager .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/")) .andReturn(destinationFactory); control.replay(); serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0); ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, serviceInfo); builder.setUseSchemaImports(doXsdImports); builder.setBaseFileName("HelloWorld"); newDef = builder.build(new HashMap<String, SchemaInfo>()); }
Example 17
Source File: SoapApiModelParser.java From syndesis with Apache License 2.0 | 5 votes |
private static WSDLReader getWsdlReader() throws BusException { WSDLManager wsdlManager = new WSDLManagerImpl(); // this is similar to what WSDLManager does, // but we need to read and store WSDL specification, so we create the reader ourselves final WSDLFactory wsdlFactory = wsdlManager.getWSDLFactory(); final WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); wsdlReader.setFeature("javax.wsdl.importDocuments", true); wsdlReader.setExtensionRegistry(wsdlManager.getExtensionRegistry()); return wsdlReader; }
Example 18
Source File: Wsdl.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Get a WSDLReader. * * @return WSDLReader. * @throws WSDLException * on error. */ private WSDLReader getReader() throws WSDLException { WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); ExtensionRegistry registry = wsdlFactory.newPopulatedExtensionRegistry(); wsdlReader.setExtensionRegistry( registry ); wsdlReader.setFeature( "javax.wsdl.verbose", true ); wsdlReader.setFeature( "javax.wsdl.importDocuments", true ); return wsdlReader; }
Example 19
Source File: WSDLImporter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Parse the WSDL definition using WSDL4J. */ protected Definition parseWSDLDefinition() throws WSDLException { WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader reader = wsdlFactory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); reader.setFeature("javax.wsdl.importDocuments", true); Definition definition = reader.readWSDL(this.wsdlLocation); return definition; }
Example 20
Source File: WSDL11ProcessorImpl.java From carbon-apimgt with Apache License 2.0 | 4 votes |
@Override public boolean initPath(String path) throws APIMgtWSDLException { setMode(Mode.ARCHIVE); pathToDefinitionMap = new HashMap<>(); wsdlArchiveExtractedPath = path; WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader(); try { // switch off the verbose mode wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false); wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false); File folderToImport = new File(path); Collection<File> foundWSDLFiles = APIFileUtil.searchFilesWithMatchingExtension(folderToImport, "wsdl"); if (log.isDebugEnabled()) { log.debug("Found " + foundWSDLFiles.size() + " WSDL file(s) in path " + path); } for (File file : foundWSDLFiles) { String absWSDLPath = file.getAbsolutePath(); if (log.isDebugEnabled()) { log.debug("Processing WSDL file: " + absWSDLPath); } Definition definition = wsdlReader.readWSDL(path, getSecuredParsedDocumentFromPath(absWSDLPath)); pathToDefinitionMap.put(absWSDLPath, definition); // set the first found WSDL as wsdlDefinition variable assuming that it is the root WSDL if (wsdlDefinition == null) { wsdlDefinition = definition; } } if (foundWSDLFiles.isEmpty()) { setError(ExceptionCodes.NO_WSDL_FOUND_IN_WSDL_ARCHIVE); } if (log.isDebugEnabled()) { log.debug("Successfully processed all WSDL files in path " + path); } } catch (WSDLException | APIManagementException e) { //This implementation class cannot process the WSDL. Continuing after setting canProcess = false log.debug(this.getClass().getName() + " was unable to process the WSDL Files for the path: " + path, e); setError(new ErrorItem(ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorMessage(), e.getMessage(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorCode(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getHttpStatusCode())); } return !hasError; }