org.apache.muse.ws.wsdl
Class WsdlUtils

java.lang.Object
  extended by org.apache.muse.ws.wsdl.WsdlUtils

public class WsdlUtils
extends Object

WsdlUtils is a collection of utility methods related to WSDL 1.1.

Author:
Dan Jemiolo (danj)

Field Summary
static QName ADDRESS_QNAME
           
static QName BINDING_QNAME
           
static String DEFAULT_SERVICE_NAME
           
static QName DEFINITIONS_QNAME
           
static QName IMPORT_QNAME
           
static QName INPUT_QNAME
           
static String LOCATION
           
static QName MESSAGE_QNAME
           
static String NAME
           
static String NAMESPACE_URI
          The WSDL 1.1 namespace URI.
static QName OPERATION_QNAME
           
static QName OUTPUT_QNAME
           
static QName PORT_QNAME
           
static QName PORT_TYPE_QNAME
           
static String PREFIX
           
static QName SERVICE_QNAME
           
static String SERVICES
           
static String SOAP_PREFIX
           
static String SOAP_URI
          The "WSDL-SOAP" namespace used for SOAP bindings.
static QName TYPES_QNAME
           
static String WSDL4J_VERBOSE_FLAG
           
 
Constructor Summary
WsdlUtils()
           
 
Method Summary
static Document addSchemaImports(Document wsdl, String wsdlPath, Environment environment, Set namespaces)
          This is a convenience method that resolves all of the schema imports referenced in a WSDL.
static Document addSchemaIncludes(Document wsdl, String wsdlPath, Environment environment, Set namespaces)
          This is a convenience method that resolves all of the schema includes referenced in a WSDL.
static javax.wsdl.Definition createDefinition(Document wsdlDoc, File wsdlDir)
           
static Document createWSDL(Environment environment, String wsdlPath, boolean resolveReferences)
          Loads the WSDL at the given path, resolving any imports if desired.
static String getAction(javax.wsdl.Operation op)
           
static Element getComplexTypeDeclaration(Node wsdl, QName qname)
          Searches a WSDL document's types section for a complex type defined with the given name.
static Element getElementDeclaration(Node wsdl, QName qname)
          Searches a WSDL document's types section for a type defined with the given name.
static Element getFirstPortType(Node wsdl)
          Returns the first portType (in document order) that's found in a given WSDL or null if the WSDL contains no portTypes.
static QName getInputPartName(javax.wsdl.Operation op)
           
static QName getOutputPartName(javax.wsdl.Operation op, Document wsdlDoc)
          This method is somewhat painful because of the lack of restrictions that WSDL 1.1 has for how you can specify input and output names and types.
static Element getPortType(Node wsdl, QName qname)
          Searches a WSDL document for a portType defined with the given name.
static Set getSchemaNamespaces(Document wsdl)
          Gathers the target namespaces for each schema in the WSDL's types section.
static String getServiceName(Element wsdlDefinition)
          Given a WSDL document try to get the address and parse out the name of the service.
static Collection getWsdlImports(Document wsdl, String wsdlPath, Environment environment)
          Creates the WSDLs that are imported in the given WSDL as independent Documents.
static void mergeWSDL(Document from, Document to, Set namespaces)
          Determines which schema content the first WSDL has that the second one doesn't and adds that content to the second WSDL.
static Element removeSchemaReferences(Element wsdl)
           
static Element removeWsdlReferences(Element wsdl)
          Iterates over a WSDL document and removes all WSDL imports and XSD imports.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE_URI

public static final String NAMESPACE_URI
The WSDL 1.1 namespace URI.

See Also:
Constant Field Values

PREFIX

public static final String PREFIX
See Also:
Constant Field Values

SOAP_URI

public static final String SOAP_URI
The "WSDL-SOAP" namespace used for SOAP bindings.

See Also:
Constant Field Values

SOAP_PREFIX

public static final String SOAP_PREFIX
See Also:
Constant Field Values

ADDRESS_QNAME

public static final QName ADDRESS_QNAME

BINDING_QNAME

public static final QName BINDING_QNAME

DEFINITIONS_QNAME

public static final QName DEFINITIONS_QNAME

IMPORT_QNAME

public static final QName IMPORT_QNAME

INPUT_QNAME

public static final QName INPUT_QNAME

LOCATION

public static final String LOCATION
See Also:
Constant Field Values

MESSAGE_QNAME

public static final QName MESSAGE_QNAME

NAME

public static final String NAME
See Also:
Constant Field Values

OPERATION_QNAME

public static final QName OPERATION_QNAME

OUTPUT_QNAME

public static final QName OUTPUT_QNAME

PORT_QNAME

public static final QName PORT_QNAME

PORT_TYPE_QNAME

public static final QName PORT_TYPE_QNAME

SERVICE_QNAME

public static final QName SERVICE_QNAME

TYPES_QNAME

public static final QName TYPES_QNAME

WSDL4J_VERBOSE_FLAG

public static final String WSDL4J_VERBOSE_FLAG
See Also:
Constant Field Values

DEFAULT_SERVICE_NAME

public static final String DEFAULT_SERVICE_NAME
See Also:
Constant Field Values

SERVICES

public static final String SERVICES
See Also:
Constant Field Values
Constructor Detail

WsdlUtils

public WsdlUtils()
Method Detail

addSchemaImports

public static Document addSchemaImports(Document wsdl,
                                        String wsdlPath,
                                        Environment environment,
                                        Set namespaces)
This is a convenience method that resolves all of the schema imports referenced in a WSDL. It iterates over every schema in the WSDL's types section and processes it via XsdUtils.addImports().

Returns:
The given WSDL, now with the imported schemas added to its types section.

addSchemaIncludes

public static Document addSchemaIncludes(Document wsdl,
                                         String wsdlPath,
                                         Environment environment,
                                         Set namespaces)
This is a convenience method that resolves all of the schema includes referenced in a WSDL. It iterates over every schema in the WSDL's types section and processes it via XsdUtils.addIncludes().

Returns:
The given WSDL, now with the included schemas added to its types section.

createDefinition

public static javax.wsdl.Definition createDefinition(Document wsdlDoc,
                                                     File wsdlDir)

createWSDL

public static Document createWSDL(Environment environment,
                                  String wsdlPath,
                                  boolean resolveReferences)
Loads the WSDL at the given path, resolving any imports if desired.

Parameters:
environment - The Muse environment is used to load the WSDL file.
wsdlPath - The relative path of the WSDL file.
resolveReferences - True if you want the method to process and WSDL and XSD imports that are in the WSDL document. The resulting Document may be much larger depending on how many imports are discovered while the method recurses through the other WSDLs/XSDs.
Returns:
A Document with the WSDL content. If the last parameter was 'true', the Document will have the contents of other WSDLs and XSDs merged into it.

getAction

public static String getAction(javax.wsdl.Operation op)

getComplexTypeDeclaration

public static Element getComplexTypeDeclaration(Node wsdl,
                                                QName qname)
Searches a WSDL document's types section for a complex type defined with the given name.

Parameters:
wsdl - The WDSL document to search.
qname - The name of the type definition to find.
Returns:
The schema definition of the given type. The method returns null if the type is not found.

getElementDeclaration

public static Element getElementDeclaration(Node wsdl,
                                            QName qname)
Searches a WSDL document's types section for a type defined with the given name.

Parameters:
wsdl - The WDSL document to search.
qname - The name of the type definition to find.
Returns:
The schema definition of the given type. The method returns null if the type is not found.

getFirstPortType

public static Element getFirstPortType(Node wsdl)
Returns the first portType (in document order) that's found in a given WSDL or null if the WSDL contains no portTypes.

Parameters:
wsdl - The WSDL document to search
Returns:
The first portType encountered or null if the document contains no portTypes

getInputPartName

public static QName getInputPartName(javax.wsdl.Operation op)

getOutputPartName

public static QName getOutputPartName(javax.wsdl.Operation op,
                                      Document wsdlDoc)
This method is somewhat painful because of the lack of restrictions that WSDL 1.1 has for how you can specify input and output names and types. Similar to the problem of generating proxies that have the proper return type/name, determining how to package response messages is hard because there are multiple ways to say the same thing (void, xsd:any, etc.) and almost everything is optional. This method is way too long, but I don't think breaking up the input and output message processing would help clarify things. The output message processing is most problematic, because each step of the way is optional. This is going to be ugly no matter what.


getPortType

public static Element getPortType(Node wsdl,
                                  QName qname)
Searches a WSDL document for a portType defined with the given name.

Parameters:
wsdl - The WDSL document to search.
qname - The name of the portType definition to find.
Returns:
The definition of the given portType. The method returns null if the portType is not found.

getSchemaNamespaces

public static Set getSchemaNamespaces(Document wsdl)
Gathers the target namespaces for each schema in the WSDL's types section.

Parameters:
wsdl -
Returns:
The set of schema namespaces declared in the types section.

getServiceName

public static String getServiceName(Element wsdlDefinition)
Given a WSDL document try to get the address and parse out the name of the service. If we can't find anything useful just return a default: the value of DEFAULT_SERVICE_NAME.

Parameters:
wsdlDefinition - The WSDL definition we're trying to parse
Returns:
The name of the service in the address element or the value of DEFAULT_SERVICE_NAME
See Also:
DEFAULT_SERVICE_NAME

getWsdlImports

public static Collection getWsdlImports(Document wsdl,
                                        String wsdlPath,
                                        Environment environment)
Creates the WSDLs that are imported in the given WSDL as independent Documents. For each WSDL import, the Document is created via createWSDL(), and then its imports are resolved. The resulting set of Documents may have content overlap and should be merged into the original WSDL with mergeWSDL().

Parameters:
wsdl - The original WSDL whose imports must be resolved.
wsdlPath - The relative path of the given WSDL. This is used to resolve the paths of the imported WSDLs.
environment - The Muse environment is used to load the WSDL files.
Returns:
A Collection of Documents - one for each WSDL imported by the given WSDL. The Collection may include WSDLs that were imported by those WSDLs (the method is recursive).

mergeWSDL

public static void mergeWSDL(Document from,
                             Document to,
                             Set namespaces)
Determines which schema content the first WSDL has that the second one doesn't and adds that content to the second WSDL.

The method addresses the issue of duplicate schema namespaces by using size: if both WSDLs have a schema for a given namespace, whichever schema is the largest will be put in the final (second) WSDL. This is the best heuristic to get all of the required schema content without analyzing every node in the schema content.

Parameters:
from - The WSDL that may have unique schema content.
to - The WSDL that will receive the first WSDL's unique schema content.
namespaces - The schema namespaces that have been processed by the second WSDL.

removeSchemaReferences

public static Element removeSchemaReferences(Element wsdl)

removeWsdlReferences

public static Element removeWsdlReferences(Element wsdl)
Iterates over a WSDL document and removes all WSDL imports and XSD imports. This is useful if you are trying to load a remote WSDL into an API such as WSDL4J, which tries to resolve imports. WSDL4J allows you to shut off WSDL imports, but not XSD imports, so removing these before parsing is important.

Parameters:
wsdl - The WSDL Document whose import elements will be removed.
Returns:
The given WSDL Document.


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.