Package javax.wsdl

Examples of javax.wsdl.Import


  {
    if(importInvalid)
    {
      return null;
    }
    Import importDef = importingDef.createImport();
   
    if (namespace != null)
    {
      importDef.setNamespaceURI(namespace);
    }

    if (location != null)
    {
      importDef.setLocationURI(location);
    }
   
    if(element != null)
    {
      Element tempEl = DOMUtils.getFirstChildElement(element);

      while (tempEl != null)
      {
        if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
        {
          importDef.setDocumentationElement(tempEl);
        }

        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
    }
View Full Code Here


  protected Import parseImport(Element importEl,
                               Definition def,
                               Map importedDefs)
                                 throws WSDLException
  {
    Import importDef = def.createImport();

    try
    {
      String namespaceURI = DOMUtils.getAttribute(importEl,
                                                  Constants.ATTR_NAMESPACE);
      String locationURI = DOMUtils.getAttribute(importEl,
                                                 Constants.ATTR_LOCATION);
      String contextURI = null;

      if (namespaceURI != null)
      {
        importDef.setNamespaceURI(namespaceURI);
      }

      if (locationURI != null)
      {
        importDef.setLocationURI(locationURI);

        if (importDocuments)
        {
          try
          {
            contextURI = def.getDocumentBaseURI();
            Definition importedDef = null;
            InputStream inputStream = null;
            InputSource inputSource = null;
            URL url = null;

            if (loc != null)
            {
              inputSource = loc.getImportInputSource(contextURI, locationURI);

              /*
                We now have available the latest import URI. This might
                differ from the locationURI so check the importedDefs for it
                since it is this that we pass as the documentBaseURI later.
              */
              String liu = loc.getLatestImportURI();

              importedDef = (Definition)importedDefs.get(liu);

              inputSource.setSystemId(liu);
            }
            else
            {
              URL contextURL = (contextURI != null)
                               ? StringUtils.getURL(null, contextURI)
                               : null;

              url = StringUtils.getURL(contextURL, locationURI);
              importedDef = (Definition)importedDefs.get(url.toString());

              if (importedDef == null)
              {
                inputStream = StringUtils.getContentAsInputStream(url);

                if (inputStream != null)
                {
                  inputSource = new InputSource(inputStream);
                  inputSource.setSystemId(url.toString());
                }
              }
            }

            if (importedDef == null)
            {
              if (inputSource == null)
              {
                throw new WSDLException(WSDLException.OTHER_ERROR,
                                        "Unable to locate imported document " +
                                        "at '" + locationURI + "'" +
                                        (contextURI == null
                                         ? "."
                                         : ", relative to '" + contextURI +
                                         "'."));
              }

              Document doc = getDocument(inputSource, inputSource.getSystemId());

              if (inputStream != null)
              {
                inputStream.close();
              }

              Element documentElement = doc.getDocumentElement();

              /*
                Check if it's a wsdl document.
                If it's not, don't retrieve and process it.
                This should later be extended to allow other types of
                documents to be retrieved and processed, such as schema
                documents (".xsd"), etc...
              */
              if (QNameUtils.matches(Constants.Q_ELEM_DEFINITIONS,
                                     documentElement))
              {
                if (verbose)
                {
                  System.out.println("Retrieving document at '" + locationURI +
                                     "'" +
                                     (contextURI == null
                                      ? "."
                                      : ", relative to '" + contextURI + "'."));
                }

                String urlString =
                  (loc != null)
                  ? loc.getLatestImportURI()
                  : (url != null)
                    ? url.toString()
                    : locationURI;

                importedDef = readWSDL(urlString,
                                       documentElement,
                                       importedDefs);
              }
              else
              {
                QName docElementQName = QNameUtils.newQName(documentElement);

                if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName))
                {
                  if (verbose)
                  {
                    System.out.println("Retrieving schema wsdl:imported from '" + locationURI +
                                       "'" +
                                       (contextURI == null
                                        ? "."
                                        : ", relative to '" + contextURI + "'."));
                  }

                  WSDLFactory factory = getWSDLFactory();

                  importedDef = factory.newDefinition();

                  if (extReg != null)
                  {
                    importedDef.setExtensionRegistry(extReg);
                  }

                  String urlString =
                    (loc != null)
                    ? loc.getLatestImportURI()
                    : (url != null)
                      ? url.toString()
                      : locationURI;

                  importedDef.setDocumentBaseURI(urlString);

                  Types types = importedDef.createTypes();
                  types.addExtensibilityElement(
                      parseSchema(Types.class, documentElement, importedDef));
                  importedDef.setTypes(types);
                }
              }
            }

            if (importedDef != null)
            {
              importDef.setDefinition(importedDef);
            }
          }
          catch (WSDLException e)
          {
           throw e;
          }
          catch (RuntimeException e)
          {
            throw e;
          }
          catch (Exception e)
          {
            throw new WSDLException(WSDLException.OTHER_ERROR,
                                    "Unable to resolve imported document at '" +
                                    locationURI +
                                    (contextURI == null
                                    ? "'." : "', relative to '" + contextURI + "'")
                                    , e);
          }
        } //end importDocs
      } //end locationURI

    }
    catch (WSDLException e)
    {
      if (e.getLocation() == null)
      {
        e.setLocation(XPathUtils.getXPathExprFromNode(importEl));
      }
      else
      {
        //If definitions are being parsed recursively for nested imports
        //the exception location must be built up recursively too so
        //prepend this element's xpath to exception location.
        String loc = XPathUtils.getXPathExprFromNode(importEl) + e.getLocation();
        e.setLocation(loc);
      }

    throw e;
  }

    //register any NS decls with the Definition
    NamedNodeMap attrs = importEl.getAttributes();
    registerNSDeclarations(attrs, def);

    Element tempEl = DOMUtils.getFirstChildElement(importEl);

    while (tempEl != null)
    {
      if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
      {
        importDef.setDocumentationElement(tempEl);
      }
      else
      {
        importDef.addExtensibilityElement(
          parseExtensibilityElement(Import.class, tempEl, def));
      }

      tempEl = DOMUtils.getNextSiblingElement(tempEl);
     }
View Full Code Here

     */
    private void adjustReferencedElements(Definition definition,
            String requestBasePath) {
        List imports = definition
            .getImports("http://www.oasis-open.org/asap/0.9/asap.wsdl");
        Import asapImport = (Import) imports.get(0);
        asapImport.setLocationURI(requestBasePath + "/asap.wsdl");

        // TODO: The types are not properly written to the definition.
        Types types = definition.getTypes();
        List typeList = types.getExtensibilityElements();
        Iterator iterator = typeList.iterator();
View Full Code Here

        WSDLFactory wsdlFactory = WSDLFactory.newInstance();
        Definition def = wsdlFactory.newDefinition();
        for( WsdlInterface iface : mockedInterfaces )
        {
          StringToStringMap parts = wsdlCache.get( iface.getName() );
          Import wsdlImport = def.createImport();
          wsdlImport.setLocationURI( getInterfacePrefix( iface ) + "&part=" + parts.get( "#root#" ) );
          wsdlImport.setNamespaceURI( WsdlUtils.getTargetNamespace( iface.getWsdlContext().getDefinition() ) );

          def.addImport( wsdlImport );
        }

        response.setStatus( HttpServletResponse.SC_OK );
View Full Code Here

            for (Iterator iterator = imports.entrySet().iterator(); iterator.hasNext();) {
                Map.Entry entry = (Map.Entry) iterator.next();
                String namespaceURI = (String) entry.getKey();
                List importList = (List) entry.getValue();
                for (Iterator iterator1 = importList.iterator(); iterator1.hasNext();) {
                    Import anImport = (Import) iterator1.next();
                    //according to the 1.1 jwsdl mr shcema imports are supposed to show up here,
                    //but according to the 1.0 spec there is supposed to be no Definition.
                    Definition definition1 = anImport.getDefinition();
                    if (definition1 != null) {
                        try {
                            URI uri = new URI(definition1.getDocumentBaseURI());
                            uris.push(uri);
                        } catch (URISyntaxException e) {
View Full Code Here

        Definition definition = model.getDefinition();
        if (definition != null) {
            for (Object imports : definition.getImports().values()) {
                List importList = (List)imports;
                for (Object i : importList) {
                    Import imp = (Import)i;
                    if (imp.getDefinition() != null) {
                        continue;
                    }
                    if (imp.getLocationURI() == null) {
                        // FIXME: [rfeng] By the WSDL 1.1 spec, the location attribute is required
                        // We need to resolve it by QName
                        WSDLDefinition proxy = factory.createWSDLDefinition();
                        proxy.setUnresolved(true);
                        proxy.setNamespace(imp.getNamespaceURI());
                        WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, proxy);
                        if (resolved != null && !resolved.isUnresolved()) {
                            imp.setDefinition(resolved.getDefinition());
                        }
                    } else {
                        String location = imp.getLocationURI();
                        URI uri = URI.create(location);
                        if (uri.isAbsolute()) {
                            WSDLDefinition resolved;
                            try {
                                resolved = read(null, uri, uri.toURL());
                                imp.setDefinition(resolved.getDefinition());
                            } catch (Exception e) {
                                throw new ContributionResolveException(e);
                            }
                        } else {
                            if (location.startsWith("/")) {
                                // This is a relative URI against a contribution
                                location = location.substring(1);
                                // TODO: Need to resolve it against the contribution
                            } else {
                                // This is a relative URI against the WSDL document
                                URI baseURI = URI.create(model.getDefinition().getDocumentBaseURI());
                                URI locationURI = baseURI.resolve(location);
                                WSDLDefinition resolved;
                                try {
                                    resolved = read(null, locationURI, locationURI.toURL());
                                    imp.setDefinition(resolved.getDefinition());
                                } catch (Exception e) {
                                    throw new ContributionResolveException(e);
                                }
                            }
                        }
View Full Code Here

        // Add other imports to mapping
        Map imports = def.getImports();
        for (Iterator iter = imports.values().iterator(); iter.hasNext();) {
            List imps = (List) iter.next();
            for (Iterator iterator = imps.iterator(); iterator.hasNext();) {
                Import imp = (Import) iterator.next();
                Definition impDef = imp.getDefinition();
                String impLoc = imp.getLocationURI();
                if (impDef != null && impLoc != null && !URI.create(impLoc).isAbsolute()) {
                    wsdls.put(impLoc, createWsdlWriter().getDocument(impDef));
                    mapImports(impDef);
                }
            }
View Full Code Here

        // Check imported wsdls
        Collection imports = rootDef.getImports().values();
        for (Iterator iter = imports.iterator(); iter.hasNext();) {
            List imps = (List) iter.next();
            for (Iterator iterator = imps.iterator(); iterator.hasNext();) {
                Import imp = (Import) iterator.next();
                checkDefinition(imp.getDefinition(), false);
            }
        }
    }
View Full Code Here

        }
        if (def.getImports() != null) {
            for (Iterator itImp = def.getImports().values().iterator(); itImp.hasNext();) {
                Collection imps = (Collection) itImp.next();
                for (Iterator iter = imps.iterator(); iter.hasNext();) {
                    Import imp = (Import) iter.next();
                    parseSchemas(imp.getDefinition());
                }
            }
        }
    }
View Full Code Here

    private void addNamespaces(Definition flat, Definition def) {
        for (Iterator itImport = def.getImports().values().iterator(); itImport.hasNext();) {
            List defImports = (List) itImport.next();
            for (Iterator iter = defImports.iterator(); iter.hasNext();) {
                Import defImport = (Import) iter.next();
                addNamespaces(flat, defImport.getDefinition());
            }
        }
        for (Iterator itNs = def.getNamespaces().keySet().iterator(); itNs.hasNext();) {
            String key = (String) itNs.next();
            String val = def.getNamespace(key);
View Full Code Here

TOP

Related Classes of javax.wsdl.Import

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.