Search in sources :

Example 36 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project carbon-apimgt by wso2.

the class APIMWSDLReader method readWSDL2File.

@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;
}
Also used : EndpointElement(org.apache.woden.wsdl20.xml.EndpointElement) OMElement(org.apache.axiom.om.OMElement) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) WSDLSource(org.apache.woden.WSDLSource) Document(org.w3c.dom.Document) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 37 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project carbon-apimgt by wso2.

the class APIMWSDLReader method getWSDLDefinitionFromByteContent.

/**
 * Returns WSDL definition from a byte content of the WSDL
 *
 * @param wsdl byte content of the WSDL document
 * @return {@link Definition} - WSDL4j definition constructed form the wsdl
 * @throws APIManagementException
 */
public Definition getWSDLDefinitionFromByteContent(byte[] wsdl, boolean readDependencies) throws APIManagementException {
    try {
        WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
        // switch off the verbose mode
        wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
        wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);
        if (!readDependencies) {
            if (wsdlReader instanceof WSDLReaderImpl) {
                ((WSDLReaderImpl) wsdlReader).setIgnoreSchemaContent(true);
            }
        }
        return wsdlReader.readWSDL(null, getSecuredParsedDocumentFromContent(wsdl));
    } catch (Exception e) {
        String msg = " Error occurs when updating WSDL ";
        throw new APIManagementException(msg, e);
    }
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) WSDLReader(javax.wsdl.xml.WSDLReader) WSDLReaderImpl(com.ibm.wsdl.xml.WSDLReaderImpl) APIUtil.handleException(org.wso2.carbon.apimgt.impl.utils.APIUtil.handleException) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) WSDLException(javax.wsdl.WSDLException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException)

Example 38 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project cxf by apache.

the class JAXBDataBindingTest method setUp.

@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);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader) Before(org.junit.Before)

Example 39 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project cxf by apache.

the class JaxWsServiceConfigurationTest method getMockedServiceModel.

private ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    Service service = null;
    for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof Service) {
            service = (Service) obj;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
    return serviceInfo;
}
Also used : IMocksControl(org.easymock.IMocksControl) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Definition(javax.wsdl.Definition) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) WebService(javax.jws.WebService) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 40 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project cxf by apache.

the class TestBase method getMockedServiceModel.

protected ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(wsdlUrl);
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    Service service = null;
    for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof Service) {
            service = (Service) obj;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
    return serviceInfo;
}
Also used : IMocksControl(org.easymock.IMocksControl) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Definition(javax.wsdl.Definition) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Aggregations

WSDLReader (javax.wsdl.xml.WSDLReader)60 Definition (javax.wsdl.Definition)35 WSDLFactory (javax.wsdl.factory.WSDLFactory)25 WSDLException (javax.wsdl.WSDLException)16 URL (java.net.URL)15 Test (org.junit.Test)13 Service (javax.wsdl.Service)8 File (java.io.File)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 JBossWSTest (org.jboss.wsf.test.JBossWSTest)7 Document (org.w3c.dom.Document)7 QName (javax.xml.namespace.QName)6 InputSource (org.xml.sax.InputSource)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Bus (org.apache.cxf.Bus)5 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)5 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4