Search in sources :

Example 46 with WSDLReader

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

the class AegisTest method testAegisReconfigureDatabinding.

@Test
public void testAegisReconfigureDatabinding() throws Exception {
    final String sei = org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName();
    File wsdlFile = new File(folder.getRoot(), "aegis.wsdl");
    String[] args = new String[] { "-wsdl", "-o", wsdlFile.toString(), "-beans", new File(getClass().getResource("/revisedAegisDefaultBeans.xml").toURI()).toString(), "-verbose", "-s", folder.getRoot().toString(), "-frontend", "jaxws", "-databinding", "aegis", "-client", "-server", sei };
    JavaToWS.main(args);
    assertTrue("wsdl is not generated " + getStdErr(), wsdlFile.exists());
    WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    Definition def = reader.readWSDL(wsdlFile.toURI().toURL().toString());
    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
    assertValid("//xsd:element[@type='ns0:Something']", wsdl);
    XPathUtils xpu = new XPathUtils(getNSMap());
    String s = (String) xpu.getValue("//xsd:complexType[@name='takeSomething']/" + "xsd:sequence/xsd:element[@name='arg0']/@minOccurs", wsdl, XPathConstants.STRING);
    assertEquals("50", s);
    assertFalse(xpu.isExist("//xsd:complexType[@name='Something']/xsd:sequence/" + "xsd:element[@name='singular']/@minOccurs", wsdl, XPathConstants.NODE));
}
Also used : XPathUtils(org.apache.cxf.helpers.XPathUtils) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 47 with WSDLReader

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

the class JAXWSDefinitionBuilder method buildCustomizedDefinition.

private Definition buildCustomizedDefinition() throws Exception {
    Map<String, Element> eleMap = cusParser.getCustomizedWSDLElements();
    String wsdlUrl = URIParserUtil.getAbsoluteURI((String) context.get(ToolConstants.CFG_WSDLURL));
    CustomizedWSDLLocator wsdlLocator = new CustomizedWSDLLocator(wsdlUrl, eleMap);
    wsdlLocator.setCatalogResolver(OASISCatalogManager.getCatalogManager(bus));
    WSDLManager mgr = bus.getExtension(WSDLManager.class);
    WSDLReader reader = mgr.getWSDLFactory().newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    reader.setExtensionRegistry(mgr.getExtensionRegistry());
    Element el = eleMap.get(wsdlLocator.getBaseURI());
    if (el == null) {
        el = (Element) cusParser.getWSDLNode();
    }
    return reader.readWSDL(wsdlLocator, el);
}
Also used : Element(org.w3c.dom.Element) WSDLManager(org.apache.cxf.wsdl.WSDLManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 48 with WSDLReader

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

the class OASISCatalogTest method testWSDLLocatorWithDefaultCatalog.

@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);
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 49 with WSDLReader

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

the class OASISCatalogTest method testWSDLLocatorWithoutCatalog.

@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
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) OASISCatalogManager(org.apache.cxf.catalog.OASISCatalogManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 50 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project tesb-studio-se by Talend.

the class WSDLUtils method getDefinition.

// public static Definition getDefinition(String pathToWsdl) throws CoreException {
// try {
// WSDLFactory wsdlFactory = WSDLFactory.newInstance();
// WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
// 
// newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
// newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
// return newWSDLReader.readWSDL(pathToWsdl);
// } catch (WSDLException e) {
// throw new CoreException(StatusUtil.newStatus(IStatus.ERROR, e.getLocalizedMessage(), e));
// }
// }
public static Definition getDefinition(IFile pathToWsdl) throws CoreException {
    try {
        WSDLFactory wsdlFactory = WSDLFactory.newInstance();
        WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
        newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
        newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
        return newWSDLReader.readWSDL(pathToWsdl.getLocationURI().toString());
    } catch (WSDLException e) {
        throw getCoreException(null, e);
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) 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