Example #1
0
  /**
   * Loads nested schema type definitions from wsdl.
   *
   * @throws IOException
   * @throws WSDLException
   * @throws TransformerFactoryConfigurationError
   * @throws TransformerException
   * @throws TransformerConfigurationException
   */
  private void loadSchemas()
      throws WSDLException, IOException, TransformerConfigurationException, TransformerException,
          TransformerFactoryConfigurationError {
    Definition definition =
        WSDLFactory.newInstance().newWSDLReader().readWSDL(wsdl.getFile().getAbsolutePath());

    Types types = definition.getTypes();
    List<?> schemaTypes = types.getExtensibilityElements();

    for (Object schemaObject : schemaTypes) {
      if (schemaObject instanceof SchemaImpl) {
        SchemaImpl schema = (SchemaImpl) schemaObject;

        inheritNamespaces(schema, definition);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Source source = new DOMSource(schema.getElement());
        Result result = new StreamResult(bos);

        TransformerFactory.newInstance().newTransformer().transform(source, result);
        Resource schemaResource = new ByteArrayResource(bos.toByteArray());

        schemas.add(schemaResource);

        if (definition
            .getTargetNamespace()
            .equals(schema.getElement().getAttribute("targetNamespace"))) {
          setXsd(schemaResource);
        }
      } else {
        log.warn("Found unsupported schema type implementation " + schemaObject.getClass());
      }
    }
  }