javax.wsdl.factory.WSDLFactory Java Examples

The following examples show how to use javax.wsdl.factory.WSDLFactory. 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: BesDAO.java    From development with Apache License 2.0 7 votes vote down vote up
void validateVersion(String wsdlUrl) {
    WSDLLocator locator = new BasicAuthWSDLLocator(wsdlUrl, null, null);
    WSDLFactory wsdlFactory;
    Definition serviceDefinition;
    try {
        wsdlFactory = WSDLFactory.newInstance();
        WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
        // avoid importing external documents
        wsdlReader.setExtensionRegistry(new WSVersionExtensionRegistry());
        serviceDefinition = wsdlReader.readWSDL(locator);
        Element versionElement = serviceDefinition
                .getDocumentationElement();
        if (!CTMGApiVersion.version.equals(versionElement.getTextContent())) {
            LOGGER.warn("Web service mismatches and the version value, expected: "
                    + CTMGApiVersion.version
                    + " and the one got from wsdl: "
                    + versionElement.getTextContent());
        }
    } catch (WSDLException e) {
        LOGGER.warn("Remote wsdl cannot be retrieved from CT_MG. [Cause: "
                + e.getMessage() + "]", e);
    }

}
 
Example #2
Source File: WSDLGenerationTester.java    From cxf with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: APIMWSDLReader.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Deprecated
public OMElement readAndCleanWsdl2(API api) throws APIManagementException {

    try {
        org.apache.woden.wsdl20.Description wsdlDefinition = readWSDL2File();
        setServiceDefinitionForWSDL2(wsdlDefinition, api);
        org.apache.woden.WSDLWriter writer = org.apache.woden.WSDLFactory.newInstance().newWSDLWriter();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer.writeWSDL(wsdlDefinition.toElement(), byteArrayOutputStream);
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( byteArrayOutputStream.toByteArray());
        return APIUtil.buildOMElement(byteArrayInputStream);
    } catch (Exception e) {
        String msg = " Error occurs when change the addres URL of the WSDL";
        log.error(msg);
        throw new APIManagementException(msg, e);
    }

}
 
Example #4
Source File: ParameterMappingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testParametersWSDL() throws Exception {
    Node doc = getWSDLDocument("AddNumbers");
    Definition def = getWSDLDefinition("AddNumbers");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
    assertValid("/wsdl:definitions/wsdl:types/"
                + "xsd:schema[@targetNamespace='http://services.aegis.cxf.apache.org']"
                + "/xsd:complexType[@name='add']"
                + "/xsd:sequence"
                + "/xsd:element[@name='value1']", doc);
    assertValid(
                "/wsdl:definitions/wsdl:types/"
                    + "xsd:schema[@targetNamespace='http://services.aegis.cxf.apache.org']"
                    + "/xsd:complexType[@name='unmappedAdd']" + "/xsd:sequence"
                    + "/xsd:element[@name='one']", doc);
}
 
Example #5
Source File: BPELPlanContext.java    From container with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #6
Source File: BPELPlanContext.java    From container with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #7
Source File: BPELPlanContext.java    From container with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #8
Source File: APIMWSDLReader.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: NamespaceConfusionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNameNamespace() throws Exception {

    org.w3c.dom.Document doc = getWSDLDocument("NameServiceImpl");
    Element rootElement = doc.getDocumentElement();

    Definition def = getWSDLDefinition("NameServiceImpl");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
    NodeList aonNodes =
        assertValid("//xsd:complexType[@name='ArrayOfName']/xsd:sequence/xsd:element", doc);
    Element arrayOfNameElement = (Element)aonNodes.item(0);

    String typename = arrayOfNameElement.getAttribute("type");
    String prefix = typename.split(":")[0];

    String uri = getNamespaceForPrefix(rootElement, arrayOfNameElement, prefix);
    assertNotNull(uri);
    AegisType nameType = tm.getTypeCreator().createType(Name.class);
    QName tmQname = nameType.getSchemaType();
    assertEquals(tmQname.getNamespaceURI(), uri);

}
 
Example #10
Source File: CompressAndEncodeTool.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
/**
    * Gets WSDL as ZLIB-compressed and Base64-encoded String.
    * Use ZipStream -> InflaterStream -> Base64Stream to read.
    * @return WSDL as String object. Or null in case errors/not possible to create object.
    * @throws WSDLException 
    * @throws IOException 
    */
public static String compressAndEncode(Definition definition) throws IOException, WSDLException {
   	ByteArrayOutputStream wsdlOs = new ByteArrayOutputStream();
       OutputStream os = compressAndEncodeStream(wsdlOs);
       ZipOutputStream zipOs = new ZipOutputStream(os);
       try {
       	ZipEntry zipEntry = new ZipEntry("main.wsdl");
		zipOs.putNextEntry(zipEntry);
           WSDLFactory.newInstance().newWSDLWriter().writeWSDL(definition, zipOs);
           appendImportDifinitions(definition, zipOs);
	} finally {
           if (null != zipOs) {
               zipOs.close();
           }
       }
       return wsdlOs.toString();
   }
 
Example #11
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Definition initWsdl( String serviceName, String filename ) {
	try {
		wsdlFactory = WSDLFactory.newInstance();
		localDef = wsdlFactory.newDefinition();
		extensionRegistry = wsdlFactory.newPopulatedExtensionRegistry();
		if( serviceName != null ) {
			QName servDefQN = new QName( serviceName );
			localDef.setQName( servDefQN );
		}
		localDef.addNamespace( NameSpacesEnum.WSDL.getNameSpacePrefix(), NameSpacesEnum.WSDL.getNameSpaceURI() );
		localDef.addNamespace( NameSpacesEnum.SOAP.getNameSpacePrefix(), NameSpacesEnum.SOAP.getNameSpaceURI() );
		localDef.addNamespace( "tns", tns );
		localDef.addNamespace( NameSpacesEnum.XML_SCH.getNameSpacePrefix(),
			NameSpacesEnum.XML_SCH.getNameSpaceURI() );
		localDef.setTargetNamespace( tns );
		localDef.addNamespace( "xsd1", tnsSchema );
	} catch( WSDLException ex ) {
		Logger.getLogger( WSDLDocCreator.class.getName() ).log( Level.SEVERE, null, ex );
	}

	return localDef;
}
 
Example #12
Source File: OASISCatalogTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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
    }
}
 
Example #13
Source File: CodeFirstTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWrappedModel() throws Exception {
    Definition d = createService(true);

    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(d);

    addNamespace("svc", "http://service.jaxws.cxf.apache.org");

    assertValid("/wsdl:definitions/wsdl:service[@name='HelloService']", wsdl);
    assertValid("//wsdl:port/wsdlsoap:address[@location='" + address + "']", wsdl);
    assertValid("//wsdl:portType[@name='Hello']", wsdl);
    assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']"
                + "/wsdl:part[@element='tns:sayHi'][@name='parameters']",
                wsdl);
    assertValid("/wsdl:definitions/wsdl:message[@name='sayHiResponse']"
                + "/wsdl:part[@element='tns:sayHiResponse'][@name='parameters']",
                wsdl);
    assertValid("//xsd:complexType[@name='sayHi']"
                + "/xsd:sequence/xsd:element[@name='arg0']",
                wsdl);
}
 
Example #14
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setUpDefinition(String wsdl, int serviceSeq) throws Exception {
    URL url = getClass().getResource(wsdl);
    assertNotNull("could not find wsdl " + wsdl, url);
    String wsdlUrl = url.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(new CatalogWSDLLocator(wsdlUrl));

    int seq = 0;
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            if (seq == serviceSeq) {
                break;
            }
            seq++;
        }
    }
}
 
Example #15
Source File: CXFServletTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: AegisTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testAegisBasic() throws Exception {
    final String sei = org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName();
    String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/aegis.wsdl", "-verbose", "-d",
                                  output.getPath(), "-s", output.getPath(),
                                  "-frontend", "jaxws", "-databinding", "aegis",
                                  "-client", "-server", sei};
    File wsdlFile = null;
    wsdlFile = outputFile("aegis.wsdl");
    JavaToWS.main(args);
    assertTrue("wsdl is not generated", 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);
}
 
Example #17
Source File: MapsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testMapWsdl() throws WSDLException {
    Definition wsdlDef = getWSDLDefinition("MapTestService");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(wsdlDef, sink);
    String wsdl = sink.toString();
    assertTrue(wsdl.contains("name=\"anyType2intMap\""));
    assertTrue(wsdl.contains("name=\"string2booleanMap\""));
    assertTrue(wsdl.contains("name=\"long2stringMap\""));
    assertTrue(wsdl.contains("name=\"string2longMap\""));
}
 
Example #18
Source File: JaxWsServiceFactoryBeanTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWebSeviceException() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(WebServiceExceptionTestImpl.class);
    Service service = bean.create();
    ServiceInfo si = service.getServiceInfos().get(0);
    ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, si);
    Definition def = builder.build();

    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);

    assertInvalid("/wsdl:definitions/wsdl:message[@name='WebServiceException']", wsdl);
}
 
Example #19
Source File: CodeFirstTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDocLitModel() throws Exception {
    Definition d = createService(false);

    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(d);
    addNamespace("svc", "http://service.jaxws.cxf.apache.org/");

    assertValid("/wsdl:definitions/wsdl:service[@name='HelloService']", wsdl);
    assertValid("//wsdl:port/wsdlsoap:address[@location='" + address + "']", wsdl);
    assertValid("//wsdl:portType[@name='Hello']", wsdl);

    assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
                + "[@targetNamespace='http://service.jaxws.cxf.apache.org/']"
                + "/xsd:import[@namespace='http://jaxb.dev.java.net/array']", wsdl);

    assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
                + "[@targetNamespace='http://service.jaxws.cxf.apache.org/']"
                + "/xsd:element[@type='ns0:stringArray']", wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']"
                + "/wsdl:part[@element='tns:sayHi'][@name='sayHi']",
                wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='getGreetingsResponse']"
                + "/wsdl:part[@element='tns:getGreetingsResponse'][@name='getGreetingsResponse']",
                wsdl);

    assertValid("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='getGreetings']"
                + "/wsdlsoap:operation[@soapAction='myaction']",
                wsdl);


}
 
Example #20
Source File: ParameterMappingTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testOccursWSDL() throws Exception {
    Node doc = getWSDLDocument("ArrayService");
    Definition def = getWSDLDefinition("ArrayService");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
    assertXPathEquals("/wsdl:definitions/wsdl:types/"
                + "xsd:schema[@targetNamespace= 'http://services.aegis.cxf.apache.org']"
                + "/xsd:complexType[@name='ArrayOfString-2-50']"
                + "/xsd:sequence"
                + "/xsd:element[@name='string']/@minOccurs", "2", doc);
}
 
Example #21
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: Wsdl.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #23
Source File: JAXBExtensionHelperTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    wsdlFactory = WSDLFactory.newInstance();
    wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    registry = wsdlReader.getExtensionRegistry();
    if (registry == null) {
        registry = wsdlFactory.newPopulatedExtensionRegistry();
    }
}
 
Example #24
Source File: Wsdl.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #25
Source File: JaxWsServiceFactoryBeanTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBareBug() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(org.apache.cxf.test.TestInterfacePort.class);
    Service service = bean.create();
    ServiceInfo si = service.getServiceInfos().get(0);
    ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, si);
    Definition def = builder.build();

    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
    NodeList nodeList = assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
                                    + "[@targetNamespace='http://cxf.apache.org/"
                                    + "org.apache.cxf.test.TestInterface/xsd']"
                                    + "/xsd:element[@name='getMessage']", wsdl);
    assertEquals(1, nodeList.getLength());


    assertValid("/wsdl:definitions/wsdl:message[@name='setMessage']"
                + "/wsdl:part[@name = 'parameters'][@element='ns1:setMessage']", wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']"
                + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']", wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']"
                + "/wsdl:part[@name = 'return'][@element='ns1:charEl_return']", wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']"
                + "/wsdl:part[@name = 'z'][@element='ns1:charEl_z']", wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']"
                + "/wsdl:part[@name = 'x'][@element='ns1:charEl_x']", wsdl);

    assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']"
                + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']", wsdl);
}
 
Example #26
Source File: AbstractAegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Document getWSDLDocument(String string) throws WSDLException {
    Definition definition = getWSDLDefinition(string);
    if (definition == null) {
        return null;
    }
    WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
    return writer.getDocument(definition);
}
 
Example #27
Source File: AbstractAegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Collection<Document> getWSDLDocuments(String string) throws WSDLException {
    WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();

    Collection<Document> docs = new ArrayList<>();
    Definition definition = getWSDLDefinition(string);
    if (definition == null) {
        return null;
    }
    docs.add(writer.getDocument(definition));

    for (Import wsdlImport : getImports(definition)) {
        docs.add(writer.getDocument(wsdlImport.getDefinition()));
    }
    return docs;
}
 
Example #28
Source File: XSDToWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void initWSDL() throws ToolException {
    try {
        wsdlFactory = WSDLFactory.newInstance();
        wsdlDefinition = wsdlFactory.newDefinition();
    } catch (WSDLException we) {
        Message msg = new Message("FAIL_TO_CREATE_WSDL_DEFINITION", LOG);
        throw new ToolException(msg, we);
    }
}
 
Example #29
Source File: JavaToProcessorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Definition getDefinition(String wsdl) throws WSDLException {
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    return wsdlReader.readWSDL(wsdl);

}
 
Example #30
Source File: AegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testAegisReconfigureDatabinding() throws Exception {
    final String sei = org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName();
    String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/aegis.wsdl",
                                  "-beans",
                                  new File(inputData, "revisedAegisDefaultBeans.xml").
                                      getAbsolutePath(),
                                  "-verbose", "-s",
                                  output.getPath(), "-frontend", "jaxws", "-databinding", "aegis",
                                  "-client", "-server", sei};
    File wsdlFile = null;
    wsdlFile = outputFile("aegis.wsdl");
    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));
}