Class WSDLDocument

java.lang.Object
org.apache.wsil.util.WSDLDocument

public class WSDLDocument extends Object
Provides an easy way to read and write information to and from WSDL documents.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    Class name.
    static final String
     
    static final String
     
    static final String
     
    static final String
    WSDL related namespaces.
    static final String
    WSDL factory class
    protected static javax.wsdl.WSDLException
     
    protected static javax.wsdl.factory.WSDLFactory
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new WSDL document from the specified Reader.
    WSDLDocument(String fileName)
    Constructs a new WSDL document from the specified file.
    WSDLDocument(URL documentURL)
    Constructs a new WSDL document from the specified URL.
    WSDLDocument(javax.wsdl.Definition definition)
    Constructs a new WSDL document from a UDDI businessService.
    Constructs a new WSDL document from a Document DOM.
  • Method Summary

    Modifier and Type
    Method
    Description
    Find the Service Interface document which this Service Implementation document references.
    javax.wsdl.Binding[]
    Get all the binding elements from the WSDL document.
    javax.wsdl.Definition
    Get the definition element of the WSDL document.
    javax.wsdl.Import[]
    Get all the import elements from the WSDL document.
    javax.wsdl.Message[]
    Get all the message elements from the WSDL document.
    javax.wsdl.PortType[]
    Get all the portType elements from the WSDL document.
    javax.wsdl.Service[]
    Get all the service elements from the WSDL document.
    static javax.wsdl.xml.WSDLReader
    Constructs a WSDLReader Set verbose option off.
    static javax.wsdl.xml.WSDLReader
    getWSDLReader(boolean imports)
    Constructs a WSDLReader Set verbose option off.
    static javax.wsdl.xml.WSDLWriter
    Constructs a WSDLWriter
    boolean
    Check if this document is both a service interface and a service implementation.
    boolean
    Check if this document is a service implementation.
    boolean
    Check if this document is a service interface.
    boolean
    Check if this document is a service interface with bindings only.
    static void
    main(String[] args)
    Command line interface for validating WSDL documents.
    void
    read(String fileName)
    Read the information contained in a WSDL file.
    void
    read(String fileName, boolean imports)
    Read the information contained in a WSDL file
    Generate an XML string that represents the WSDL document content.
    Return string representation of this object.
    void
    write(Writer writer)
    Write the WSDL document content to the specified writer.
    void
    write(String fileName)
    Write the WSDL document to the specified file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • WSDLDocument

      public WSDLDocument(String fileName) throws javax.wsdl.WSDLException
      Constructs a new WSDL document from the specified file.
      Parameters:
      fileName - The name of the WSDL file to be read. Specify either the full path to the file, or a URL address.
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • WSDLDocument

      public WSDLDocument(URL documentURL) throws javax.wsdl.WSDLException
      Constructs a new WSDL document from the specified URL.
      Parameters:
      documentURL - the URL where the WSDL document is located
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • WSDLDocument

      public WSDLDocument(Reader reader) throws javax.wsdl.WSDLException
      Constructs a new WSDL document from the specified Reader.
      Parameters:
      reader - the reader that will be used to get the contents of the WSDL document
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • WSDLDocument

      public WSDLDocument(Document document) throws javax.wsdl.WSDLException
      Constructs a new WSDL document from a Document DOM.
      Parameters:
      document - A parsed XML document that conforms to the WSDL schema.
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • WSDLDocument

      public WSDLDocument(javax.wsdl.Definition definition) throws javax.wsdl.WSDLException
      Constructs a new WSDL document from a UDDI businessService.
      Parameters:
      definition - A WSDL definition element.
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
  • Method Details

    • getWSDLReader

      public static javax.wsdl.xml.WSDLReader getWSDLReader() throws javax.wsdl.WSDLException
      Constructs a WSDLReader Set verbose option off. Sets reslove imports off.
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • getWSDLReader

      public static javax.wsdl.xml.WSDLReader getWSDLReader(boolean imports) throws javax.wsdl.WSDLException
      Constructs a WSDLReader Set verbose option off.
      Parameters:
      imports - set to true if imports are to be reslolved, false if not.
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • getWSDLWriter

      public static javax.wsdl.xml.WSDLWriter getWSDLWriter() throws javax.wsdl.WSDLException
      Constructs a WSDLWriter
      Throws:
      javax.wsdl.WSDLException - if the WSDL document cannot be created.
    • read

      public void read(String fileName) throws javax.wsdl.WSDLException
      Read the information contained in a WSDL file.
      Parameters:
      fileName - The name of the WSDL file to be read. Specify either the full path to the file, or a URL address.
      Throws:
      javax.wsdl.WSDLException - if a error occurs processing the file.
    • read

      public void read(String fileName, boolean imports) throws javax.wsdl.WSDLException
      Read the information contained in a WSDL file
      Parameters:
      fileName - the name of the WSDL file to be read. Specify either the full path to the file, or a URL address.
      imports - true if imports in the WSDL file should be resolved
      Throws:
      javax.wsdl.WSDLException - if an error occurs processing the file.
    • write

      public void write(String fileName)
      Write the WSDL document to the specified file.
      Parameters:
      fileName - The name of the file to write to.
    • write

      public void write(Writer writer)
      Write the WSDL document content to the specified writer.
      Parameters:
      writer - The Writer to use.
    • serializeToXML

      public String serializeToXML()
      Generate an XML string that represents the WSDL document content.
      Returns:
      String The string containing this document serialized as XML.
    • getDefinitions

      public javax.wsdl.Definition getDefinitions()
      Get the definition element of the WSDL document.
      Returns:
      The definition element
    • getMessages

      public javax.wsdl.Message[] getMessages()
      Get all the message elements from the WSDL document.
      Returns:
      The list of message elements.
    • getPortTypes

      public javax.wsdl.PortType[] getPortTypes()
      Get all the portType elements from the WSDL document.
      Returns:
      The list of portType elements.
    • getBindings

      public javax.wsdl.Binding[] getBindings()
      Get all the binding elements from the WSDL document.
      Returns:
      The list of binding elements.
    • getImports

      public javax.wsdl.Import[] getImports()
      Get all the import elements from the WSDL document.
      Returns:
      The list of import elements.
    • getServices

      public javax.wsdl.Service[] getServices()
      Get all the service elements from the WSDL document.
      Returns:
      The list of service elements.
    • isServiceInterface

      public boolean isServiceInterface()
      Check if this document is a service interface. That means it must contain Message, PortType and Binding elements.
      Returns:
      true if Message, PortType and Binding elements are all found; false otherwise
    • isServiceInterfaceWithBindingsOnly

      public boolean isServiceInterfaceWithBindingsOnly()
      Check if this document is a service interface with bindings only. That means it must contain Binding elements only.
      Returns:
      true if Binding element is found; false otherwise
    • isServiceImplementation

      public boolean isServiceImplementation()
      Check if this document is a service implementation. That means it must contain at least one Import and one Service element. No attempt is made to verify the content of any imported document.
      Returns:
      true if at least one Import and one Service element is found; false otherwise
    • isCompleteServiceDefinition

      public boolean isCompleteServiceDefinition()
      Check if this document is both a service interface and a service implementation. That means it must contain Message, PortType, Binding and Service elements.
      Returns:
      true if Message, PortType, Binding and Service elements are all found; false otherwise
    • findServiceInterface

      public WSDLDocument findServiceInterface() throws javax.wsdl.WSDLException
      Find the Service Interface document which this Service Implementation document references. A Service Implementation document is expected to contain an Import statement that references the Service Interface document.
      Returns:
      WSDLDocument the Service Interface document. A null is returned if the source document is not a service implementation document or we didn't find an import for a service implementation document.
      Throws:
      javax.wsdl.WSDLException - if an error occurs while reading an imported document.
    • toString

      public String toString()
      Return string representation of this object.
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)
      Command line interface for validating WSDL documents.