Package javax.wsdl

Examples of javax.wsdl.WSDLException


            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);
View Full Code Here


    {
      extReg = def.getExtensionRegistry();

      if (extReg == null)
      {
        throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
                                "No ExtensionRegistry set for this " +
                                "Definition, so unable to deserialize " +
                                "a '" + elementType + "' element in the " +
                                "context of a '" + parentType.getName() +
                                "'.");
View Full Code Here

            inputSource = loc.getImportInputSource(
              schema.getDocumentBaseURI(), schemaRef.getSchemaLocationURI());

            if (inputSource == null)
            {
              throw new WSDLException(WSDLException.OTHER_ERROR,
                        "Unable to locate with a locator "
                        + "the schema referenced at '"
                        + schemaRef.getSchemaLocationURI()
                        + "' relative to document base '"
                        + schema.getDocumentBaseURI() + "'");
            }
            location = loc.getLatestImportURI();

            //if a schema from this location has been read previously, use it.
            referencedSchema = (Schema) this.allSchemas.get(location);
          }
          else
           {
            // We don't have a wsdl locator, so try to retrieve the schema by its URL
            String contextURI = schema.getDocumentBaseURI();
            URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null;
            URL url = StringUtils.getURL(contextURL, schemaRef.getSchemaLocationURI());
            location = url.toExternalForm();

          //if a schema from this location has been retrieved previously, use it.
            referencedSchema = (Schema) this.allSchemas.get(location);

            if (referencedSchema == null)
            {
              // We haven't read this schema in before so do it now
              inputStream = StringUtils.getContentAsInputStream(url);

              if (inputStream != null)
              {
                inputSource = new InputSource(inputStream);
              }

              if (inputSource == null)
              {
                throw new WSDLException(WSDLException.OTHER_ERROR,
                          "Unable to locate with a url "
                          + "the document referenced at '"
                          + schemaRef.getSchemaLocationURI()
                          + "'"
                          + (contextURI == null ? "." : ", relative to '"
                          + contextURI + "'."));
              }
            }

          } //end if loc

          // If we have not previously read the schema, get its DOM element now.
          if (referencedSchema == null)
          {
            inputSource.setSystemId(location);
            Document doc = getDocument(inputSource, location);

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

            Element documentElement = doc.getDocumentElement();

            // If it's a schema doc process it, otherwise the schema reference remains null

            QName docElementQName = QNameUtils.newQName(documentElement);

            if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName))
            {
              //We now need to call parseSchema recursively to parse the referenced
              //schema. The document base URI of the referenced schema will be set to
              //the document base URI of the current schema plus the schemaLocation in
              //the schemaRef. We cannot explicitly pass in a new document base URI
              //to the schema deserializer, so instead we will create a dummy
              //Definition and set its documentBaseURI to the new document base URI.
              //We can leave the other definition fields empty because we know
              //that the SchemaDeserializer.unmarshall method uses the definition
              //parameter only to get its documentBaseURI. If the unmarshall method
              //implementation changes (ie: its use of definition changes) we may need
              //to rethink this approach.

              WSDLFactory factory = getWSDLFactory();
              Definition dummyDef = factory.newDefinition();

              dummyDef.setDocumentBaseURI(location);

              //By this point, we know we have a SchemaDeserializer registered
              //so we can safely cast the ExtensibilityElement to a Schema.
              referencedSchema = (Schema) parseSchema( parentType,
                                                       documentElement,
                                                       dummyDef,
                                                       extReg);
            }

          } //end if referencedSchema

          schemaRef.setReferencedSchema(referencedSchema);
        }
        catch (WSDLException e)
        {
          throw e;
        }
            catch (RuntimeException e)
            {
              throw e;
            }
        catch (Exception e)
        {
              throw new WSDLException(WSDLException.OTHER_ERROR,
                    "An error occurred trying to resolve schema referenced at '"
                    + schemaRef.getSchemaLocationURI()
                    + "'"
                  + (schema.getDocumentBaseURI() == null ? "." : ", relative to '"
                  + schema.getDocumentBaseURI() + "'."),
View Full Code Here

          attrExt.setExtensionAttribute(qname, val);
        }
      }
      else if (!nativeAttributeNames.contains(localName))
      {
        WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
                                                  "Encountered illegal " +
                                                  "extension attribute '" +
                                                  qname + "'. Extension " +
                                                  "attributes must be in " +
                                                  "a namespace other than " +
                                                  "WSDL's.");

        wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));

        throw wsdlExc;
      }
    }
  }
View Full Code Here

    String namespaceURI = el.getNamespaceURI();
    try
    {
      if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL))
      {
        throw new WSDLException(WSDLException.INVALID_WSDL,
                  "Encountered illegal extension element '" +
                  elementType +
                  "' in the context of a '" +
                  parentType.getName() +
                  "'. Extension elements must be in " +
                  "a namespace other than WSDL's.");
      }

      ExtensionRegistry extReg = def.getExtensionRegistry();

      if (extReg == null)
      {
        throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
                                "No ExtensionRegistry set for this " +
                                "Definition, so unable to deserialize " +
                                "a '" + elementType + "' element in the " +
                                "context of a '" + parentType.getName() +
                                "'.");
View Full Code Here

  private static void checkElementName(Element el, QName qname)
    throws WSDLException
  {
    if (!QNameUtils.matches(qname, el))
    {
      WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
                                                "Expected element '" +
                                                qname + "'.");

      wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));

      throw wsdlExc;
    }
  }
View Full Code Here

    {
      throw e;
    }
    catch (Exception e)
    {
      throw new WSDLException(WSDLException.PARSER_ERROR,
                                "Problem parsing '" + desc + "'.",
                                e);
    }
  }
View Full Code Here

    {
      throw e;
    }
    catch (Exception e)
    {
      throw new WSDLException(WSDLException.OTHER_ERROR,
                              "Unable to resolve imported document at '" +
                              wsdlURI +
                              (contextURI == null
                              ? "'."
                              : "', relative to '" + contextURI + "'.")
View Full Code Here

    InputSource is = locator.getBaseInputSource();
    String base = locator.getBaseURI();

    if (is == null)
    {
      throw new WSDLException(WSDLException.OTHER_ERROR,
                              "Unable to locate document at '" + base + "'.");
    }
    is.setSystemId(base);

    this.loc = locator;
View Full Code Here

            }
          }
          if (definition1 == null)
          {
            if (inputsource == null)
              throw new WSDLException(
                "OTHER_ERROR",
                "Unable to locate imported document at '"
                  + s1
                  + "'"
                  + (s2 != null ? ", relative to '" + s2 + "'." : "."));
            Document document = null;
            try
            {
              document = getDocument(inputsource, s1);
            }
            catch (WSDLException ex)
            {
              addElementToList(element, import1);
              return import1;
            }
            if (inputstream != null)
              inputstream.close();
            Element element2 = document.getDocumentElement();
            if (QNameUtils.matches(Constants.Q_ELEM_DEFINITIONS, element2))
            {
              //if (verbose)
              //  System.out.println(
              //    "Retrieving document at '"
              //      + s1
              //      + "'"
              //      + (s2 != null ? ", relative to '" + s2 + "'." : "."));
              String s4 =
                loc == null
                  ? url == null
                  ? s1
                  : url.toString() : loc.getLatestImportURI();
              definition1 = readWSDL(s4, element2, map);
            }
            else
            {
              QName qname = QNameUtils.newQName(element2);
              if (SchemaConstants.XSD_QNAME_LIST.contains(qname))
              {
                WSDLFactory wsdlfactory =
                  factoryImplName == null
                    ? WSDLFactory.newInstance()
                    : WSDLFactory.newInstance(factoryImplName);
                definition1 = wsdlfactory.newDefinition();
                if (extReg != null)
                  definition1.setExtensionRegistry(extReg);
                String s5 =
                  loc == null
                    ? url == null
                    ? s1
                    : url.toString() : loc.getLatestImportURI();
                definition1.setDocumentBaseURI(s5);
                /* Don't add types element since it doesn't exist.  Adding it causes problems
                 * since it will add a types element for processing that does not exist.
                Types types = definition1.createTypes();
                UnknownExtensibilityElement unknownextensibilityelement =
                  new UnknownExtensibilityElement();
                unknownextensibilityelement.setElement(element2);
                types.addExtensibilityElement(
                  unknownextensibilityelement);
                definition1.setTypes(types);
                */
              }
            }
          }
          if (definition1 != null)
            import1.setDefinition(definition1);
        }
        catch (WSDLException wsdlexception)
        {
          wsdlexception.setLocation(XPathUtils.getXPathExprFromNode(element));
          throw wsdlexception;
        }
        catch (Throwable throwable)
        {
          throw new WSDLException(
            "OTHER_ERROR",
            "Unable to resolve imported document at '" + s1 + "'.",
            throwable);
        }
    }
View Full Code Here

TOP

Related Classes of javax.wsdl.WSDLException

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.