Beispiel #1
0
  private void convertPort(Port port) throws IOException {
    String comment = "";
    String name = port.getName();
    String protocol = "soap";
    String location = "socket://localhost:80/";
    if (port.getDocumentationElement() != null) {
      comment = port.getDocumentationElement().getNodeValue();
    }
    List<ExtensibilityElement> extElements = port.getExtensibilityElements();
    for (ExtensibilityElement element : extElements) {
      if (element instanceof SOAPAddress) {
        location = ((SOAPAddress) element).getLocationURI().toString();
        StringBuilder builder = new StringBuilder();
        builder
            .append("soap {\n")
            .append("\t.wsdl = \"")
            .append(definition.getDocumentBaseURI())
            .append("\";\n")
            .append("\t.wsdl.port = \"")
            .append(port.getName())
            .append("\"\n}");
        protocol = builder.toString();

      } else if (element instanceof HTTPAddress) {
        location = ((HTTPAddress) element).getLocationURI().toString();
        protocol = "http";
      }
    }
    try {
      URI uri = new URI(location);
      uri =
          new URI(
              "socket",
              uri.getUserInfo(),
              uri.getHost(),
              (uri.getPort() < 1) ? 80 : uri.getPort(),
              uri.getPath(),
              uri.getQuery(),
              uri.getFragment());
      location = uri.toString();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
    Binding binding = port.getBinding();
    PortType portType = binding.getPortType();
    convertPortType(portType, binding);
    outputPorts.put(
        name,
        new OutputPort(name, location, protocol, portType.getQName().getLocalPart(), comment));
  }
Beispiel #2
0
  private List<Document> getWSDLDocuments() {
    List<Document> docs = new ArrayList<Document>();
    try {
      docs.add(getWSDLDocument());

      if (null != importedDefinitions) {
        for (Definition d : importedDefinitions) {
          docs.add(getWSDLDocument(d.getDocumentBaseURI()));
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      // ignore
    }

    return docs;
  }
Beispiel #3
0
 private void parseSchemaElement(Element element) throws IOException {
   try {
     Transformer transformer = transformerFactory.newTransformer();
     transformer.setOutputProperty("indent", "yes");
     StringWriter sw = new StringWriter();
     StreamResult result = new StreamResult(sw);
     DOMSource source = new DOMSource(element);
     transformer.transform(source, result);
     InputSource schemaSource = new InputSource(new StringReader(sw.toString()));
     schemaSource.setSystemId(definition.getDocumentBaseURI());
     schemaParser.parse(schemaSource);
   } catch (TransformerConfigurationException e) {
     throw new IOException(e);
   } catch (TransformerException e) {
     throw new IOException(e);
   } catch (SAXException e) {
     throw new IOException(e);
   }
 }
  public static EprMetaData getBindingForTypeId(String repId, Definition wsdlDef) {
    LOG.log(
        Level.FINE, "RepositoryId " + repId + ", wsdl namespace " + wsdlDef.getTargetNamespace());
    EprMetaData ret = new EprMetaData();
    Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
    for (Binding b : bindings) {
      List<?> extElements = b.getExtensibilityElements();

      // Get the list of all extensibility elements
      for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext(); ) {
        java.lang.Object element = extIter.next();

        // Find a binding type so we can check against its repository ID
        if (element instanceof BindingType) {
          BindingType type = (BindingType) element;
          if (repId.equals(type.getRepositoryID())) {
            ret.setCandidateWsdlDef(wsdlDef);
            ret.setBinding(b);
            return ret;
          }
        }
      }
    }

    if (!ret.isValid()) {
      // recursivly check imports
      Iterator<?> importLists = wsdlDef.getImports().values().iterator();
      while (importLists.hasNext()) {
        List<?> imports = (List<?>) importLists.next();
        for (java.lang.Object imp : imports) {
          if (imp instanceof Import) {
            Definition importDef = ((Import) imp).getDefinition();
            LOG.log(Level.INFO, "Following import " + importDef.getDocumentBaseURI());
            ret = getBindingForTypeId(repId, importDef);
            if (ret.isValid()) {
              return ret;
            }
          }
        }
      }
    }
    return ret;
  }
  public void testCompare() throws WSDLException, ComparisonException {

    Comparator<Definition> comparator = new WSDLDeclarationComparator();
    Definition originalWSDL = WSDLTestUtils.getWSDLDefinition();
    Definition changedWSDL = WSDLTestUtils.getWSDLDefinitionWithDetails();

    //        originalWSDL.setExtensionAttribute();

    //        originalWSDL.setTypes();

    //      originalWSDL.addBinding();
    //      originalWSDL.addImport();
    //        originalWSDL.addMessage();
    //        originalWSDL.addBinding();
    //        originalWSDL.addPortType();
    //        originalWSDL.addService();
    //        originalWSDL.addExtensibilityElement();

    originalWSDL.getAllBindings();
    originalWSDL.getAllPortTypes();
    originalWSDL.getAllServices();
    originalWSDL.getDocumentBaseURI();
    originalWSDL.getImports();
    originalWSDL.getMessages();
    originalWSDL.getNamespaces();
    originalWSDL.getPortTypes();
    originalWSDL.getQName();
    originalWSDL.getTargetNamespace();
    originalWSDL.getTypes();
    originalWSDL.getDocumentationElement();
    originalWSDL.getExtensibilityElements();
    // TODO Fix me
    originalWSDL.getExtensionAttributes();

    Comparison defaultComparison = new DefaultComparison();
    comparator.compare(originalWSDL, changedWSDL, defaultComparison);
    System.out.println(defaultComparison);
    assertNotNull(defaultComparison);
  }
  public static void populateEprInfo(EprMetaData info) {
    if (!info.isValid()) {
      return;
    }
    Binding match = info.getBinding();
    Definition wsdlDef = info.getCandidateWsdlDef();
    Collection<Service> services = CastUtils.cast(wsdlDef.getServices().values());
    for (Service serv : services) {
      Collection<Port> ports = CastUtils.cast(serv.getPorts().values());
      for (Port pt : ports) {
        if (pt.getBinding().equals(match)) {
          info.setPortName(pt.getName());
          info.setServiceQName(serv.getQName());
          break;
        }
      }
    }

    if (info.getServiceQName() == null) {
      Iterator<?> importLists = wsdlDef.getImports().values().iterator();
      while (info.getServiceQName() == null && importLists.hasNext()) {
        List<?> imports = (List<?>) importLists.next();
        for (java.lang.Object imp : imports) {
          if (imp instanceof Import) {
            Definition importDef = ((Import) imp).getDefinition();
            LOG.log(Level.FINE, "following wsdl import " + importDef.getDocumentBaseURI());
            info.setCandidateWsdlDef(importDef);
            populateEprInfo(info);
            if (info.getServiceQName() != null) {
              break;
            }
          }
        }
      }
    }
  }
 public static String getWSDLLocation(Definition wsdlDef) {
   return wsdlDef.getDocumentBaseURI();
 }