FileDocCategorySizeDatePackage
Emitter.javaAPI DocApache Axis 1.486368Sat Apr 22 18:57:28 BST 2006org.apache.axis.wsdl.fromJava

Emitter

public class Emitter extends Object
This class emits WSDL from Java classes. It is used by the ?WSDL Axis browser function and Java2WSDL commandline utility. See Java2WSDL and Java2WSDLFactory for more information.
author
Glen Daniels (gdaniels@apache.org)
author
Rich Scheuerle (scheu@us.ibm.com)

Fields Summary
protected static Log
log
Field log
public static final int
MODE_ALL
Field MODE_ALL
public static final int
MODE_INTERFACE
Field MODE_INTERFACE
public static final int
MODE_IMPLEMENTATION
Field MODE_IMPLEMENTATION
private Class
cls
Field cls
private Class[]
extraClasses
Field extraClasses
private Class
implCls
Field implCls
private Vector
allowedMethods
Field allowedMethods
private Vector
disallowedMethods
Field disallowedMethods
private ArrayList
stopClasses
Field stopClasses
private boolean
useInheritedMethods
Field useInheritedMethods
private String
intfNS
Field intfNS
private String
implNS
Field implNS
private String
inputSchema
Field inputSchema
private String
inputWSDL
Field inputWSDL
private String
locationUrl
Field locationUrl
private String
importUrl
Field importUrl
private String
servicePortName
Field servicePortName
private String
serviceElementName
Field serviceElementName
private String
targetService
Field targetService
private String
description
Field description
private org.apache.axis.constants.Style
style
Field style
private org.apache.axis.constants.Use
use
Field use
private org.apache.axis.encoding.TypeMapping
tm
Field tm
private org.apache.axis.encoding.TypeMappingRegistry
tmr
Field tmr
private Namespaces
namespaces
Field namespaces
private Map
exceptionMsg
Field exceptionMsg
private Map
usedElementNames
Global element names already in use
private ArrayList
encodingList
Field encodingList
protected Types
types
Field types
private String
clsName
Field clsName
private String
portTypeName
Field portTypeName
private String
bindingName
Field bindingName
private org.apache.axis.description.ServiceDesc
serviceDesc
Field serviceDesc
private org.apache.axis.description.JavaServiceDesc
serviceDesc2
Field serviceDesc2
private String
soapAction
Field soapAction
private boolean
emitAllTypes
Should we emit all mapped types in every WSDL?
private String
versionMessage
Version string to put at top of WSDL
private HashMap
qName2ClassMap
The mapping of generated type qname to its corresponding java type. For use with java<-->wsdl roundtripping
public static final int
MODE_RPC
DEPRECATED - Indicates style=rpc use=encoded
public static final int
MODE_DOCUMENT
DEPRECATED - Indicates style=document use=literal
public static final int
MODE_DOC_WRAPPED
DEPRECATED - Indicates style=wrapped use=literal
protected static org.apache.axis.encoding.TypeMapping
standardTypes
Field standardTypes
Document
docHolder
Field docHolder
Constructors Summary
public Emitter()
Construct Emitter. Set the contextual information using set* methods Invoke emit to emit the code


                        
      

        createDocumentFragment();

        namespaces = new Namespaces();
        exceptionMsg = new HashMap();
        usedElementNames = new HashMap();
        qName2ClassMap = new HashMap();
    
Methods Summary
protected javax.wsdl.DefinitioncreateDefinition()
Build a Definition from the input wsdl file or create a new Definition

return
WSDL Definition
throws
WSDLException
throws
SAXException
throws
IOException
throws
ParserConfigurationException


        Definition def;

        if (inputWSDL == null) {
            def = WSDLFactory.newInstance().newDefinition();
        } else {
            javax.wsdl.xml.WSDLReader reader =
                    WSDLFactory.newInstance().newWSDLReader();
            Document doc = XMLUtils.newDocument(inputWSDL);

            def = reader.readWSDL(null, doc);

            // The input wsdl types section is deleted.  The
            // types will be added back in at the end of processing.
            def.setTypes(null);
        }

        return def;
    
private voidcreateDocumentFragment()
Method createDocumentFragment


        try {
            this.docHolder = XMLUtils.newDocument();
        } catch (ParserConfigurationException e) {

            // This should not occur
            throw new InternalException(e);
        }
    
protected org.w3c.dom.ElementcreateDocumentationElement(java.lang.String documentation)
Create a documentation element

param
documentation
return

        Element element = docHolder.createElementNS(Constants.NS_URI_WSDL11, "documentation");
        element.setPrefix(Constants.NS_PREFIX_WSDL);
        Text textNode =
                docHolder.createTextNode(documentation);

        element.appendChild(textNode);
        return element;
    
protected javax.xml.namespace.QNamecreateMessageName(javax.wsdl.Definition def, java.lang.String methodName)
Method createMessageName

param
def
param
methodName
return


        QName qName = new QName(intfNS, methodName);

        // Check the make sure there isn't a message with this name already
        int messageNumber = 1;

        while (def.getMessage(qName) != null) {
            StringBuffer namebuf = new StringBuffer(methodName);

            namebuf.append(messageNumber);

            qName = new QName(intfNS, namebuf.toString());

            messageNumber++;
        }

        return qName;
    
protected TypescreateTypes(javax.wsdl.Definition def)
Build a Types object and load the input wsdl types

param
def Corresponding wsdl Definition
return
Types object
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


                                                                                        
       
               
             

        types = new Types(def, tm, (TypeMapping)tmr.getDefaultTypeMapping(),
                          namespaces, intfNS, stopClasses, serviceDesc, this);

        if (inputWSDL != null) {
            types.loadInputTypes(inputWSDL);
        }

        if (inputSchema != null) {
            StringTokenizer tokenizer = new StringTokenizer(inputSchema, ", ");

            while (tokenizer.hasMoreTokens()) {
                String token = tokenizer.nextToken();

                types.loadInputSchema(token);
            }
        }
        
        // If we're supposed to emit all mapped types, do it now.
        if (emitAllTypes && tm != null) { 
            Class[] mappedTypes = tm.getAllClasses(); 
            
            for (int i = 0; i < mappedTypes.length; i++) { 
                Class mappedType = mappedTypes[i]; 
                QName name = tm.getTypeQName(mappedType); 
                if (name.getLocalPart().indexOf(SymbolTable.ANON_TOKEN) != -1) { 
                    // If this is an anonymous type, it doesn't need to be
                    // written out here (and trying to do so will generate an
                    // error). Skip it. 
                    continue; 
                } 
                
                /** 
                 * If it's a non-standard type, make sure it shows up in 
                 * our WSDL 
                 */ 
                if (standardTypes.getSerializer(mappedType) == null) { 
                    types.writeTypeForPart(mappedType, name); 
                } 
            }
            
            // Don't bother checking for subtypes, since we already wrote
            // all the possibilities.
            types.mappedTypes = null;
        }
        
        return types;
    
public voidemit(java.lang.String filename1, java.lang.String filename2)
Generates WSDL documents for a given Class

param
filename1 interface WSDL
param
filename2 implementation WSDL
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        // Get interface and implementation defs
        Definition intf = getIntfWSDL();
        Definition impl = getImplWSDL();

        // Supply reasonable file names if not supplied
        if (filename1 == null) {
            filename1 = getServicePortName() + "_interface.wsdl";
        }

        if (filename2 == null) {
            filename2 = getServicePortName() + "_implementation.wsdl";
        }

        for (int i = 0; (extraClasses != null) && (i < extraClasses.length);
             i++) {
            types.writeTypeForPart(extraClasses[i], null);
        }

        // types.updateNamespaces();
        // Write out the interface def
        Document doc =
                WSDLFactory.newInstance().newWSDLWriter().getDocument(intf);

        types.insertTypesFragment(doc);
        prettyDocumentToFile(doc, filename1);

        // Write out the implementation def
        doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(impl);

        prettyDocumentToFile(doc, filename2);
    
public voidemit(java.lang.String filename)
Generates a complete WSDL document for a given Class

param
filename WSDL
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException

        emit(filename, MODE_ALL);
    
public org.w3c.dom.Documentemit(int mode)
Generates a WSDL document for a given Class. The WSDL generated is controlled by the mode parameter mode 0: All mode 1: Interface mode 2: Implementation

param
mode generation mode - all, interface, implementation
return
Document
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        Document doc;
        Definition def;

        switch (mode) {

            default:
            case MODE_ALL:
                def = getWSDL();

                for (int i = 0;
                     (extraClasses != null) && (i < extraClasses.length);
                     i++) {
                    types.writeTypeForPart(extraClasses[i], null);
                }

                // types.updateNamespaces();
                doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(
                        def);

                types.insertTypesFragment(doc);
                break;

            case MODE_INTERFACE:
                def = getIntfWSDL();

                for (int i = 0;
                     (extraClasses != null) && (i < extraClasses.length);
                     i++) {
                    types.writeTypeForPart(extraClasses[i], null);
                }

                // types.updateNamespaces();
                doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(
                        def);

                types.insertTypesFragment(doc);
                break;

            case MODE_IMPLEMENTATION:
                def = getImplWSDL();
                doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(
                        def);
                break;
        }

        // Add Axis version info as comment to beginnning of generated WSDL
        if (versionMessage == null) {
            versionMessage = Messages.getMessage(
                    "wsdlCreated00",
                    XMLUtils.xmlEncodeString(Version.getVersion()));
        }
        // If version is empty string, don't emit one
        if (versionMessage != null && versionMessage.length() > 0) {
            Comment wsdlVersion = doc.createComment(versionMessage);
            doc.getDocumentElement().insertBefore(
                    wsdlVersion, doc.getDocumentElement().getFirstChild());
        }

        // Return the document
        return doc;
    
public voidemit(java.lang.String filename, int mode)
Generates a WSDL document for a given Class. The WSDL generated is controlled by the mode parameter mode 0: All mode 1: Interface mode 2: Implementation

param
filename WSDL
param
mode generation mode - all, interface, implementation
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        Document doc = emit(mode);

        // Supply a reasonable file name if not supplied
        if (filename == null) {
            filename = getServicePortName();

            switch (mode) {

                case MODE_ALL:
                    filename += ".wsdl";
                    break;

                case MODE_INTERFACE:
                    filename += "_interface.wsdl";
                    break;

                case MODE_IMPLEMENTATION:
                    filename += "_implementation.wsdl";
                    break;
            }
        }

        prettyDocumentToFile(doc, filename);
    
public java.lang.StringemitToString(int mode)
Generates a String containing the WSDL for a given Class. The WSDL generated is controlled by the mode parameter mode 0: All mode 1: Interface mode 2: Implementation

param
mode generation mode - all, interface, implementation
return
String
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        Document doc = emit(mode);
        StringWriter sw = new StringWriter();

        XMLUtils.PrettyDocumentToWriter(doc, sw);

        return sw.toString();
    
public java.util.VectorgetAllowedMethods()
Returns a vector of methods to export

return
a space separated list of methods to export

        return allowedMethods;
    
public java.lang.StringgetBindingName()
Returns the String representation of the binding name

return
String representation of the binding name

        return bindingName;
    
public java.lang.ClassgetCls()
Returns the Class to export

return
the Class to export

        return cls;
    
public org.apache.axis.encoding.TypeMappinggetDefaultTypeMapping()
Returns the defaultTypeMapping used by the service

return
the defaultTypeMapping used by the service
deprecated
Use getTypeMappingRegistry instead

        return (TypeMapping) tmr.getDefaultTypeMapping();
    
public java.lang.StringgetDescription()
Returns the service description

return
service description String

        return description;
    
public java.util.VectorgetDisallowedMethods()
Return list of methods that should not be exported

return

        return disallowedMethods;
    
public java.lang.Class[]getExtraClasses()
Return the list of extra classes that the emitter will produce WSDL for.

return

        return extraClasses;
    
public java.lang.ClassgetImplCls()
Returns the implementation Class if set

return
the implementation Class or null

        return implCls;
    
public java.lang.StringgetImplNamespace()
Returns the implementation namespace

return
implementation target namespace

        return implNS;
    
public javax.wsdl.DefinitiongetImplWSDL()
Get implementation WSDL Definition for the current configuration parameters

return
WSDL Definition
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        // Invoke the init() method to ensure configuration is setup
        init(MODE_IMPLEMENTATION);

        // Create a Definition for the output wsdl
        Definition def = createDefinition();

        // Write implementation header and import
        writeDefinitions(def, implNS);
        writeImport(def, intfNS, importUrl);

        // Write the implementation WSDL constructs and return Definition
        Binding binding = writeBinding(def, false);    // Don't add binding to def

        writeService(def, binding);

        return def;
    
public java.lang.StringgetImportUrl()
Returns the String representation of the interface import location URL

return
String representation of the interface import location URL

        return importUrl;
    
public java.lang.StringgetInputSchema()

return
the name of the input schema, or null

        return inputSchema;
    
public java.lang.StringgetInputWSDL()
Get the name of the input WSDL

return
name of the input wsdl or null

        return inputWSDL;
    
public java.lang.StringgetIntfNamespace()
Returns the interface namespace

return
interface target namespace

        return intfNS;
    
public javax.wsdl.DefinitiongetIntfWSDL()
Get a interface WSDL Definition for the current configuration parameters

return
WSDL Definition
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        // Invoke the init() method to ensure configuration is setup
        init(MODE_INTERFACE);

        // Create a definition for the output wsdl
        Definition def = createDefinition();

        // Write interface header
        writeDefinitions(def, intfNS);

        // Create Types
        types = createTypes(def);

        // Write the interface WSDL constructs and return the Definition
        Binding binding = writeBinding(def, true);

        writePortType(def, binding);

        return def;
    
public java.lang.StringgetLocationUrl()
Returns the String representation of the service endpoint URL

return
String representation of the service endpoint URL

        return locationUrl;
    
public intgetMode()
getMode (gets the mode based on the style setting)

return
returns the mode (-1 if invalid)
deprecated
(use getStyle and getUse)


        if (style == Style.RPC) {
            return MODE_RPC;
        } else if (style == Style.DOCUMENT) {
            return MODE_DOCUMENT;
        } else if (style == Style.WRAPPED) {
            return MODE_DOC_WRAPPED;
        }

        return -1;
    
public java.util.MapgetNamespaceMap()
get the packagename to namespace map

return
Map

        return namespaces;
    
public java.lang.StringgetPortTypeName()
Returns the String representation of the portType name

return
String representation of the portType name

        return portTypeName;
    
public java.util.HashMapgetQName2ClassMap()
Return the type qname to java type mapping

return
mapping of type qname to its corresponding java type

        return qName2ClassMap;   
    
protected javax.xml.namespace.QNamegetRequestQName(org.apache.axis.description.OperationDesc oper)
Method getRequestQName

param
oper
return


        qualifyOperation(oper);

        QName qname = oper.getElementQName();

        if (qname == null) {
            qname = new QName(oper.getName());
        }

        return qname;
    
protected javax.xml.namespace.QNamegetResponseQName(org.apache.axis.description.OperationDesc oper)
Method getResponseQName

param
oper
return


        qualifyOperation(oper);

        QName qname = oper.getElementQName();

        if (qname == null) {
            return new QName(oper.getName() + "Response");
        }

        return new QName(qname.getNamespaceURI(),
                qname.getLocalPart() + "Response");
    
public org.apache.axis.description.ServiceDescgetServiceDesc()
Method getServiceDesc

return

        return serviceDesc;
    
public java.lang.StringgetServiceElementName()
Returns the String representation of the service element name

return
String representation of the service element name

        return serviceElementName;
    
public java.lang.StringgetServicePortName()
Returns the String representation of the service port name

return
String representation of the service port name

        return servicePortName;
    
public java.lang.StringgetSoapAction()
Returns the soapAction option value

return
the String DEFAULT, NONE or OPERATION

        return soapAction;
    
public java.util.ArrayListgetStopClasses()
Return the list of classes which stop inhertance searches

return

        return stopClasses;
    
public org.apache.axis.constants.StylegetStyle()
getStyle

return
Style setting (Style.RPC, Style.DOCUMENT, Style.WRAPPED, etc.)

        return style;
    
public java.lang.StringgetTargetService()
Returns the target service name

return
the target service name

        return targetService;
    
public org.apache.axis.encoding.TypeMappinggetTypeMapping()
Returns the TypeMapping used by the service

return
the TypeMapping used by the service

        return tm;
    
public org.apache.axis.constants.UsegetUse()
getUse

return
Use setting (Use.ENCODED, Use.LITERAL)

        return use;
    
public booleangetUseInheritedMethods()
Indicates if the emitter will search classes for inherited methods

return

        return useInheritedMethods;
    
public java.lang.StringgetVersionMessage()
Return the version message

return
message or null if emitter will use the default

        return versionMessage;
    
public javax.wsdl.DefinitiongetWSDL()
Get a Full WSDL Definition for the current configuration parameters

return
WSDL Definition
throws
IOException
throws
WSDLException
throws
SAXException
throws
ParserConfigurationException


        // Invoke the init() method to ensure configuration is setup
        init(MODE_ALL);

        // Create a Definition for the output wsdl
        Definition def = createDefinition();

        // Write interface header
        writeDefinitions(def, intfNS);

        // Create Types
        types = createTypes(def);

        // Write the WSDL constructs and return full Definition
        Binding binding = writeBinding(def, true);

        writePortType(def, binding);
        writeService(def, binding);

        return def;
    
protected voidinit(int mode)
Invoked prior to building a definition to ensure parms and data are set up.

param
mode


        // Default use depending on setting of style
        if (use == null) {
            if (style == Style.RPC) {
                use = Use.ENCODED;
            } else {
                use = Use.LITERAL;
            }
        }

        if (tm == null) {
            String encodingStyle = "";
            if (use == Use.ENCODED) {
                encodingStyle = Constants.URI_SOAP11_ENC;
                /** TODO : Set this correctly if we do SOAP 1.2 support here */
            }
            tm = (TypeMapping)tmr.getTypeMapping(encodingStyle);
        }

        // Set up a ServiceDesc to use to introspect the Service
        if (serviceDesc == null) {
            JavaServiceDesc javaServiceDesc = new JavaServiceDesc();
            serviceDesc = javaServiceDesc;

            javaServiceDesc.setImplClass(cls);

            // Set the typeMapping to the one provided.
            serviceDesc.setTypeMapping(tm);

            javaServiceDesc.setStopClasses(stopClasses);
            serviceDesc.setAllowedMethods(allowedMethods);
            javaServiceDesc.setDisallowedMethods(disallowedMethods);
            serviceDesc.setStyle(style);
            serviceDesc.setUse(use);

            // If the class passed in is a portType,
            // there may be an implClass that is used to
            // obtain the method parameter names.  In this case,
            // a serviceDesc2 is built to get the method parameter names.
            if ((implCls != null) && (implCls != cls)
                    && (serviceDesc2 == null)) {
                serviceDesc2 = new JavaServiceDesc();

                serviceDesc2.setImplClass(implCls);

                // Set the typeMapping to the one provided.
                serviceDesc2.setTypeMapping(tm);

                serviceDesc2.setStopClasses(stopClasses);
                serviceDesc2.setAllowedMethods(allowedMethods);
                serviceDesc2.setDisallowedMethods(disallowedMethods);
                serviceDesc2.setStyle(style);
            }
        }

        if (encodingList == null) {

            // if cls contains a Class object with the service implementation use the Name of the
            // class else use the service name
            if (cls != null) {
                clsName = cls.getName();
                clsName = clsName.substring(clsName.lastIndexOf('.") + 1);
            } else {
                clsName = getServiceDesc().getName();
            }

            // Default the portType name
            if (getPortTypeName() == null) {
                setPortTypeName(clsName);
            }

            // Default the serviceElementName
            if (getServiceElementName() == null) {
                setServiceElementName(getPortTypeName() + "Service");
            }

            // If service port name is null, construct it from location or className
            if (getServicePortName() == null) {
                String name = getLocationUrl();

                if (name != null) {
                    if (name.lastIndexOf('/") > 0) {
                        name = name.substring(name.lastIndexOf('/") + 1);
                    } else if (name.lastIndexOf('\\") > 0) {
                        name = name.substring(name.lastIndexOf('\\") + 1);
                    } else {
                        name = null;
                    }

                    // if we got the name from the location, strip .jws from it
                    if ((name != null) && name.endsWith(".jws")) {
                        name = name.substring(0, (name.length()
                                - ".jws".length()));
                    }
                }

                if ((name == null) || name.equals("")) {
                    name = clsName;
                }

                setServicePortName(name);
            }

            // Default the bindingName
            if (getBindingName() == null) {
                setBindingName(getServicePortName() + "SoapBinding");
            }

            encodingList = new ArrayList();

            encodingList.add(Constants.URI_DEFAULT_SOAP_ENC);

            if (intfNS == null) {
                Package pkg = cls.getPackage();

                intfNS = namespaces.getCreate((pkg == null)
                        ? null
                        : pkg.getName());
            }

            // Default the implementation namespace to the interface
            // namespace if not split wsdl mode.
            if (implNS == null) {
                if (mode == MODE_ALL) {
                    implNS = intfNS;
                } else {
                    implNS = intfNS + "-impl";
                }
            }

            // set the namespaces in the serviceDesc(s)
            serviceDesc.setDefaultNamespace(intfNS);

            if (serviceDesc2 != null) {
                serviceDesc2.setDefaultNamespace(implNS);
            }

            if (cls != null) {
                String clsName = cls.getName();
                int idx = clsName.lastIndexOf(".");
                if (idx > 0) {
                    String pkgName = clsName.substring(0, idx);
                    namespaces.put(pkgName, intfNS, "intf");
                }
            }

            namespaces.putPrefix(implNS, "impl");
        }
    
protected voidprettyDocumentToFile(org.w3c.dom.Document doc, java.lang.String filename)
Write a prettified document to a file.

param
doc the Document to write
param
filename the name of the file to be written
throws
IOException various file i/o exceptions


        FileOutputStream fos = new FileOutputStream(new File(filename));

        XMLUtils.PrettyDocumentToStream(doc, fos);
        fos.close();
    
private voidqualifyOperation(org.apache.axis.description.OperationDesc oper)
Method qualifyOperation

param
oper


        if ((style == Style.WRAPPED) && (use == Use.LITERAL)) {
            QName qname = oper.getElementQName();

            if (qname == null) {
                qname = new QName(intfNS, oper.getName());
            } else if (qname.getNamespaceURI().equals("")) {
                qname = new QName(intfNS, qname.getLocalPart());
            }

            oper.setElementQName(qname);
        }
    
public voidsetAllowedMethods(java.lang.String text)
Add a list of methods to export

param
text


        if (text != null) {
            StringTokenizer tokenizer = new StringTokenizer(text, " ,+");

            if (allowedMethods == null) {
                allowedMethods = new Vector();
            }

            while (tokenizer.hasMoreTokens()) {
                allowedMethods.add(tokenizer.nextToken());
            }
        }
    
public voidsetAllowedMethods(java.util.Vector allowedMethods)
Add a Vector of methods to export

param
allowedMethods a vector of methods to export


        if (this.allowedMethods == null) {
            this.allowedMethods = new Vector();
        }

        this.allowedMethods.addAll(allowedMethods);
    
public voidsetBindingName(java.lang.String bindingName)
Set the String representation of the binding name

param
bindingName the String representation of the binding name

        this.bindingName = bindingName;
    
public voidsetCls(java.lang.Class cls)
Sets the Class to export

param
cls the Class to export

        this.cls = cls;
    
public voidsetCls(java.lang.String className)
Sets the Class to export

param
className the name of the Class to export
throws
ClassNotFoundException

        cls = ClassUtils.forName(className);
    
public voidsetClsSmart(java.lang.Class cls, java.lang.String location)
Sets the Class to export.

param
cls the Class to export
param
location


        if ((cls == null) || (location == null)) {
            return;
        }

        // Strip off \ and / from location
        if (location.lastIndexOf('/") > 0) {
            location = location.substring(location.lastIndexOf('/") + 1);
        } else if (location.lastIndexOf('\\") > 0) {
            location = location.substring(location.lastIndexOf('\\") + 1);
        }

        // Get the constructors of the class
        java.lang.reflect.Constructor[] constructors =
                cls.getDeclaredConstructors();
        Class intf = null;

        for (int i = 0; (i < constructors.length) && (intf == null); i++) {
            Class[] parms = constructors[i].getParameterTypes();

            // If the constructor has a single parameter
            // that is an interface which
            // matches the location, then use this as the interface class.
            if ((parms.length == 1) && parms[0].isInterface()
                    && (parms[0].getName() != null)
                    && Types.getLocalNameFromFullName(
                            parms[0].getName()).equals(location)) {
                intf = parms[0];
            }
        }

        if (intf != null) {
            setCls(intf);

            if (implCls == null) {
                setImplCls(cls);
            }
        } else {
            setCls(cls);
        }
    
public voidsetDefaultTypeMapping(org.apache.axis.encoding.TypeMapping tm)
Sets the defaultTypeMapping used by the service

param
tm the defaultTypeMapping used by the service
deprecated
Use setTypeMappingRegistry instead

        tmr.registerDefault(tm);
    
public voidsetDescription(java.lang.String description)
Set the service description

param
description service description String

        this.description = description;
    
public voidsetDisallowedMethods(java.util.Vector disallowedMethods)
Add a list of methods NOT to export

param
disallowedMethods vector of method name strings


        if (this.disallowedMethods == null) {
            this.disallowedMethods = new Vector();
        }

        this.disallowedMethods.addAll(disallowedMethods);
    
public voidsetDisallowedMethods(java.lang.String text)
Add a list of methods NOT to export

param
text space separated list of method names


        if (text != null) {
            StringTokenizer tokenizer = new StringTokenizer(text, " ,+");

            if (disallowedMethods == null) {
                disallowedMethods = new Vector();
            }

            disallowedMethods = new Vector();

            while (tokenizer.hasMoreTokens()) {
                disallowedMethods.add(tokenizer.nextToken());
            }
        }
    
public voidsetEmitAllTypes(boolean emitAllTypes)

        this.emitAllTypes = emitAllTypes;
    
public voidsetExtraClasses(java.lang.String text)
Provide a comma or space seperated list of classes which the emitter will produce WSDL type definitions for. The classes will be added to the current list.

param
text
throws
ClassNotFoundException


        ArrayList clsList = new ArrayList();

        if (text != null) {
            StringTokenizer tokenizer = new StringTokenizer(text, " ,");

            while (tokenizer.hasMoreTokens()) {
                String clsName = tokenizer.nextToken();

                // Let the caller handler ClassNotFoundException
                Class cls = ClassUtils.forName(clsName);

                clsList.add(cls);
            }
        }

        // Allocate the new array
        Class[] ec;
        int startOffset = 0;

        if (extraClasses != null) {
            ec = new Class[clsList.size() + extraClasses.length];

            // copy existing elements
            for (int i = 0; i < extraClasses.length; i++) {
                Class c = extraClasses[i];

                ec[i] = c;
            }
            startOffset = extraClasses.length;
        } else {
            ec = new Class[clsList.size()];
        }

        // copy the new classes
        for (int i = 0; i < clsList.size(); i++) {
            Class c = (Class) clsList.get(i);

            ec[startOffset + i] = c;
        }

        // set the member variable
        this.extraClasses = ec;
    
public voidsetExtraClasses(java.lang.Class[] extraClasses)
Provide a list of classes which the emitter will produce WSDL type definitions for.

param
extraClasses

        this.extraClasses = extraClasses;
    
public voidsetImplCls(java.lang.Class implCls)
Sets the implementation Class

param
implCls the Class to export

        this.implCls = implCls;
    
public voidsetImplCls(java.lang.String className)
Sets the implementation Class

param
className the name of the implementation Class


        try {
            implCls = ClassUtils.forName(className);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    
public voidsetImplNamespace(java.lang.String ns)
Set the implementation namespace

param
ns implementation target namespace

        this.implNS = ns;
    
public voidsetImportUrl(java.lang.String importUrl)
Set the String representation of the interface location URL for importing

param
importUrl the String representation of the interface location URL for importing

        this.importUrl = importUrl;
    
public voidsetInputSchema(java.lang.String inputSchema)
Set the name of the input schema

param
inputSchema the name of the input schema

        this.inputSchema = inputSchema;
    
public voidsetInputWSDL(java.lang.String inputWSDL)
Set the name of the input WSDL

param
inputWSDL the name of the input WSDL

        this.inputWSDL = inputWSDL;
    
public voidsetIntfNamespace(java.lang.String ns)
Set the interface namespace

param
ns interface target namespace

        this.intfNS = ns;
    
public voidsetLocationUrl(java.lang.String locationUrl)
Set the String representation of the service endpoint URL

param
locationUrl the String representation of the service endpoint URL

        this.locationUrl = locationUrl;
    
public voidsetMode(int mode)
setMode (sets style and use)

param
mode
deprecated
(use setStyle and setUse)


        if (mode == MODE_RPC) {
            setStyle(Style.RPC);
            setUse(Use.ENCODED);
        } else if (mode == MODE_DOCUMENT) {
            setStyle(Style.DOCUMENT);
            setUse(Use.LITERAL);
        } else if (mode == MODE_DOC_WRAPPED) {
            setStyle(Style.WRAPPED);
            setUse(Use.LITERAL);
        }
    
public voidsetNamespaceMap(java.util.Map map)
Set the packagename to namespace map with the given map

param
map packagename/namespace Map


        if (map != null) {
            namespaces.putAll(map);
        }
    
public voidsetPortTypeName(java.lang.String portTypeName)
Set the String representation of the portType name

param
portTypeName the String representation of the portType name

        this.portTypeName = portTypeName;
    
public voidsetServiceDesc(org.apache.axis.description.ServiceDesc serviceDesc)
Method setServiceDesc

param
serviceDesc

        this.serviceDesc = serviceDesc;
    
public voidsetServiceElementName(java.lang.String serviceElementName)
Set the String representation of the service element name

param
serviceElementName the String representation of the service element name

        this.serviceElementName = serviceElementName;
    
public voidsetServicePortName(java.lang.String servicePortName)
Set the String representation of the service port name

param
servicePortName the String representation of the service port name

        this.servicePortName = servicePortName;
    
public voidsetSoapAction(java.lang.String value)
Sets the soapAction option value

param
value must be DEFAULT, NONE, or OPERATION

        soapAction = value;
    
public voidsetStopClasses(java.util.ArrayList stopClasses)
Adds a list of classes (fully qualified) that will stop the traversal of the inheritance tree if encounter in method or complex type generation

param
stopClasses vector of class name strings


        if (this.stopClasses == null) {
            this.stopClasses = new ArrayList();
        }

        this.stopClasses.addAll(stopClasses);
    
public voidsetStopClasses(java.lang.String text)
Add a list of classes (fully qualified) that will stop the traversal of the inheritance tree if encounter in method or complex type generation

param
text space separated list of class names


        if (text != null) {
            StringTokenizer tokenizer = new StringTokenizer(text, " ,+");

            if (stopClasses == null) {
                stopClasses = new ArrayList();
            }

            while (tokenizer.hasMoreTokens()) {
                stopClasses.add(tokenizer.nextToken());
            }
        }
    
public voidsetStyle(java.lang.String value)
setStyle

param
value String representing a style ("document", "rpc", "wrapped") Note that the case of the string is not important. "document" and "DOCUMENT" are both treated as document style. If the value is not a know style, the default setting is used. See org.apache.axis.constants.Style for a description of the interaction between Style/Use
NOTE: If style is specified as "wrapped", use is set to literal.

        setStyle(Style.getStyle(value));
    
public voidsetStyle(org.apache.axis.constants.Style value)
setStyle

param
value Style setting


        style = value;

        if (style.equals(Style.WRAPPED)) {
            setUse(Use.LITERAL);
        }
    
public voidsetTargetService(java.lang.String targetService)
Set the target service name

param
targetService the target service name

        this.targetService = targetService;
    
public voidsetTypeMapping(org.apache.axis.encoding.TypeMapping tm)
Sets the TypeMapping used by the service

param
tm the TypeMapping used by the service

        this.tm = tm;
    
public voidsetTypeMappingRegistry(org.apache.axis.encoding.TypeMappingRegistry tmr)
Set the TypeMappingRegistry for this Emitter.

        this.tmr = tmr;
    
public voidsetUse(java.lang.String value)
setUse

param
value String representing a use ("literal", "encoded") Note that the case of the string is not important. "literal" and "LITERAL" are both treated as literal use. If the value is not a know use, the default setting is used. See org.apache.axis.constants.Style for a description of the interaction between Style/Use

        use = Use.getUse(value);
    
public voidsetUse(org.apache.axis.constants.Use value)
setUse

param
value Use setting

        use = value;
    
public voidsetUseInheritedMethods(boolean useInheritedMethods)
Turn on or off inherited method WSDL generation.

param
useInheritedMethods

        this.useInheritedMethods = useInheritedMethods;
    
public voidsetVersionMessage(java.lang.String versionMessage)
Set the version message that appears at the top of the WSDL If not set, we use the default version message. If set to an empty string, no version message will be emitted

param
versionMessage the message to emit

        this.versionMessage = versionMessage;
    
protected javax.wsdl.BindingwriteBinding(javax.wsdl.Definition def, boolean add)
Create the binding.

param
def Definition
param
add true if binding should be added to the def
return


        QName bindingQName = new QName(intfNS, getBindingName());

        // If a binding already exists, don't replace it.
        Binding binding = def.getBinding(bindingQName);

        if (binding != null) {
            return binding;
        }

        // Create a binding
        binding = def.createBinding();

        binding.setUndefined(false);
        binding.setQName(bindingQName);

        SOAPBinding soapBinding = new SOAPBindingImpl();
        String styleStr = (style == Style.RPC)
                ? "rpc"
                : "document";

        soapBinding.setStyle(styleStr);
        soapBinding.setTransportURI(Constants.URI_SOAP11_HTTP);
        binding.addExtensibilityElement(soapBinding);

        if (add) {
            def.addBinding(binding);
        }

        return binding;
    
protected javax.wsdl.BindingOperationwriteBindingOperation(javax.wsdl.Definition def, javax.wsdl.Binding binding, javax.wsdl.Operation oper, org.apache.axis.description.OperationDesc desc)
Create a Binding Operation

param
def
param
binding
param
oper
param
desc
return


        BindingOperation bindingOper = def.createBindingOperation();
        BindingInput bindingInput = def.createBindingInput();
        BindingOutput bindingOutput = null;
        
        // TODO : Make this deal with all MEPs
        if (OperationType.REQUEST_RESPONSE.equals(desc.getMep())) 
            bindingOutput = def.createBindingOutput();

        bindingOper.setName(oper.getName());
        bindingOper.setOperation(oper);

        SOAPOperation soapOper = new SOAPOperationImpl();

        // If the soapAction option is OPERATION, force
        // soapAction to the name of the operation. If NONE,
        // force soapAction to "".
        // Otherwise use the information in the operationDesc.
        String soapAction;
        if (getSoapAction().equalsIgnoreCase("OPERATION")) {
            soapAction = oper.getName();
        } else if (getSoapAction().equalsIgnoreCase("NONE")) {
            soapAction = "";
        } else {
            soapAction = desc.getSoapAction();

            if (soapAction == null) {
                soapAction = "";
            }
        }

        soapOper.setSoapActionURI(soapAction);

        // Until we have per-operation configuration, this will always be
        // the same as the binding default.
        // soapOper.setStyle("rpc");
        bindingOper.addExtensibilityElement(soapOper);

        // Add soap:body element to the binding <input> element
        ExtensibilityElement inputBody = writeSOAPBody(desc.getElementQName());
        bindingInput.addExtensibilityElement(inputBody);

        // add soap:headers, if any, to binding <input> element
        // only when we write the Message and parts.

        // Add soap:body element to the binding <output> element
        if (bindingOutput != null) {
            ExtensibilityElement outputBody = writeSOAPBody(desc.getReturnQName());
            bindingOutput.addExtensibilityElement(outputBody);
            bindingOper.setBindingOutput(bindingOutput);

            // add soap:headers, if any, to binding <output> element
            // only when we write the Message and parts.
        }
        
        // Add input to operation
        bindingOper.setBindingInput(bindingInput);

        // Faults clause
        // Comment out the following part 
        // because it actually does the same thing as in writeMessages.
        /*
        ArrayList faultList = desc.getFaults();

        if (faultList != null) {
            for (Iterator it = faultList.iterator(); it.hasNext();) {
                FaultDesc faultDesc = (FaultDesc) it.next();

                // Get a soap:fault
                ExtensibilityElement soapFault = writeSOAPFault(faultDesc);

                // Get a wsdl:fault to put the soap:fault in
                BindingFault bindingFault = new BindingFaultImpl();

                bindingFault.setName(faultDesc.getName());
                bindingFault.addExtensibilityElement(soapFault);
                bindingOper.addBindingFault(bindingFault);
            }
        }
        */

        binding.addBindingOperation(bindingOper);

        return bindingOper;
    
protected voidwriteDefinitions(javax.wsdl.Definition def, java.lang.String tns)
Create the definition header information.

param
def Definition
param
tns target namespace


        def.setTargetNamespace(tns);
        def.addNamespace("intf", intfNS);
        def.addNamespace("impl", implNS);
        def.addNamespace(Constants.NS_PREFIX_WSDL_SOAP,
                Constants.URI_WSDL11_SOAP);
        namespaces.putPrefix(Constants.URI_WSDL11_SOAP,
                Constants.NS_PREFIX_WSDL_SOAP);
        def.addNamespace(Constants.NS_PREFIX_WSDL, Constants.NS_URI_WSDL11);
        namespaces.putPrefix(Constants.NS_URI_WSDL11, Constants.NS_PREFIX_WSDL);

        if (use == Use.ENCODED) {
            def.addNamespace(Constants.NS_PREFIX_SOAP_ENC,
                    Constants.URI_DEFAULT_SOAP_ENC);
            namespaces.putPrefix(Constants.URI_DEFAULT_SOAP_ENC,
                    Constants.NS_PREFIX_SOAP_ENC);
        }

        def.addNamespace(Constants.NS_PREFIX_SCHEMA_XSD,
                Constants.URI_DEFAULT_SCHEMA_XSD);
        namespaces.putPrefix(Constants.URI_DEFAULT_SCHEMA_XSD,
                Constants.NS_PREFIX_SCHEMA_XSD);
        def.addNamespace(Constants.NS_PREFIX_XMLSOAP, Constants.NS_URI_XMLSOAP);
        namespaces.putPrefix(Constants.NS_URI_XMLSOAP,
                Constants.NS_PREFIX_XMLSOAP);
    
protected javax.wsdl.MessagewriteFaultMessage(javax.wsdl.Definition def, org.apache.axis.description.FaultDesc exception)
Create a Fault Message

param
def
param
exception (an ExceptionRep object)
return
throws
WSDLException
throws
AxisFault


        String pkgAndClsName = exception.getClassName();
        String clsName =
                pkgAndClsName.substring(pkgAndClsName.lastIndexOf('.") + 1,
                        pkgAndClsName.length());

        // Do this to cover the complex type case with no meta data
        exception.setName(clsName);

        // The following code uses the class name for both the name= attribute
        // and the message= attribute.
        Message msg = (Message) exceptionMsg.get(pkgAndClsName);

        if (msg == null) {
            msg = def.createMessage();

            QName qName = createMessageName(def, clsName);

            msg.setQName(qName);
            msg.setUndefined(false);

            ArrayList parameters = exception.getParameters();

            if (parameters != null) {
                for (int i = 0; i < parameters.size(); i++) {
                    ParameterDesc parameter = (ParameterDesc) parameters.get(i);

                    writePartToMessage(def, msg, true, parameter);
                }
            }

            exceptionMsg.put(pkgAndClsName, msg);
        }

        return msg;
    
private booleanwriteHeaderParts(javax.wsdl.Definition def, java.util.ArrayList parameters, javax.wsdl.BindingOperation bindop, javax.wsdl.Message msg, boolean request)
Create parts of a Message for header parameters and write then in to the provided Message element. Also create a soap:header element in the binding

param
parameters the list of parameters for the current operation
param
bindop the current bindingOperation
param
msg the message to add the parts to
param
request true if we are do an input message, false if it is output
return
true if we wrote any header parts

        boolean wroteHeaderParts = false;
        String partName;

        // Loop over all the parameters for this operation
        for (int i = 0; i < parameters.size(); i++) {
            ParameterDesc parameter = (ParameterDesc) parameters.get(i);

            // write the input or output header parts in to the Message
            if (request && parameter.isInHeader()) {
                // put part in message
                partName = writePartToMessage(def, msg, request, parameter);
                // Create a soap:header element
                SOAPHeader hdr = writeSOAPHeader(parameter, msg.getQName(), partName);
                // put it in the binding <input> element
                bindop.getBindingInput().addExtensibilityElement(hdr);
                wroteHeaderParts = true;
            }
            else if (!request && parameter.isOutHeader()) {
                // put part in message
                partName = writePartToMessage(def, msg, request, parameter);
                // Create a soap:header element
                SOAPHeader hdr = writeSOAPHeader(parameter, msg.getQName(), partName);
                // put it in the binding <output> element
                bindop.getBindingOutput().addExtensibilityElement(hdr);
                wroteHeaderParts = true;
            }
            else {
                continue;   // body part
            }
        }
        return wroteHeaderParts;
    
protected voidwriteImport(javax.wsdl.Definition def, java.lang.String tns, java.lang.String loc)
Create and add an import

param
def Definition
param
tns target namespace
param
loc target location


        Import imp = def.createImport();

        imp.setNamespaceURI(tns);

        if ((loc != null) && !loc.equals("")) {
            imp.setLocationURI(loc);
        }

        def.addImport(imp);
    
protected voidwriteMessages(javax.wsdl.Definition def, javax.wsdl.Operation oper, org.apache.axis.description.OperationDesc desc, javax.wsdl.BindingOperation bindingOper)
Create a Message

param
def Definition, the WSDL definition
param
oper Operation, the wsdl operation
param
desc OperationDesc, the Operation Description
param
bindingOper BindingOperation, corresponding Binding Operation
throws
WSDLException
throws
AxisFault


        Input input = def.createInput();
        Message msg = writeRequestMessage(def, desc, bindingOper);

        input.setMessage(msg);

        // Give the input element a name that matches the
        // message.  This is necessary for overloading.
        // The msg QName is unique.
        String name = msg.getQName().getLocalPart();

        input.setName(name);
        bindingOper.getBindingInput().setName(name);
        oper.setInput(input);
        def.addMessage(msg);
        
        if (OperationType.REQUEST_RESPONSE.equals(desc.getMep())) {
            msg = writeResponseMessage(def, desc, bindingOper);
            
            Output output = def.createOutput();
            
            output.setMessage(msg);
            
            // Give the output element a name that matches the
            // message.  This is necessary for overloading.
            // The message QName is unique.
            name = msg.getQName().getLocalPart();
            
            output.setName(name);
            bindingOper.getBindingOutput().setName(name);
            oper.setOutput(output);
            def.addMessage(msg);
        }
        
        ArrayList exceptions = desc.getFaults();

        for (int i = 0; (exceptions != null) && (i < exceptions.size()); i++) {
            FaultDesc faultDesc = (FaultDesc) exceptions.get(i);

            msg = writeFaultMessage(def, faultDesc);

            // Add the fault to the portType
            Fault fault = def.createFault();

            fault.setMessage(msg);
            fault.setName(faultDesc.getName());
            oper.addFault(fault);

            // Add the fault to the binding
            BindingFault bFault = def.createBindingFault();

            bFault.setName(faultDesc.getName());

            SOAPFault soapFault = writeSOAPFault(faultDesc);

            bFault.addExtensibilityElement(soapFault);
            bindingOper.addBindingFault(bFault);

            // Add the fault message
            if (def.getMessage(msg.getQName()) == null) {
                def.addMessage(msg);
            }
        }

        // Set the parameter ordering using the parameter names
        ArrayList parameters = desc.getParameters();
        Vector names = new Vector();

        for (int i = 0; i < parameters.size(); i++) {
            ParameterDesc param = (ParameterDesc) parameters.get(i);

            names.add(param.getName());
        }

        if (names.size() > 0) {
            if (style == Style.WRAPPED) {
                names.clear();
            } else {
                oper.setParameterOrdering(names);
            }
        }
    
protected javax.wsdl.BindingOperationwriteOperation(javax.wsdl.Definition def, javax.wsdl.Binding binding, org.apache.axis.description.OperationDesc desc)
Create a Operation

param
def
param
binding
param
desc
return


        Operation oper = def.createOperation();

        QName elementQName = desc.getElementQName();
        if(elementQName != null && elementQName.getLocalPart() != null) {
            oper.setName(elementQName.getLocalPart());
        } else {
            oper.setName(desc.getName());
        }
        oper.setUndefined(false);

        return writeBindingOperation(def, binding, oper, desc);
    
public java.lang.StringwritePartToMessage(javax.wsdl.Definition def, javax.wsdl.Message msg, boolean request, org.apache.axis.description.ParameterDesc param)
Create a Part

param
def
param
msg
param
request message is for a request
param
param ParamRep object
return
The parameter name added or null
throws
WSDLException
throws
AxisFault


        // Return if this is a void type
        if ((param == null) || (param.getJavaType() == java.lang.Void.TYPE)) {
            return null;
        }

        // If Request message, only continue if IN or INOUT
        // If Response message, only continue if OUT or INOUT
        if (request && (param.getMode() == ParameterDesc.OUT)) {
            return null;
        }

        if (!request && (param.getMode() == ParameterDesc.IN)) {
            return null;
        }

        // Create the Part
        Part part = def.createPart();

        if (param.getDocumentation() != null) {
            part.setDocumentationElement(
                    createDocumentationElement(
                            param.getDocumentation()));
        }

        // Get the java type to represent in the wsdl
        // (if the mode is OUT or INOUT and this
        // parameter does not represent the return type,
        // the type held in the Holder is the one that should
        // be written.)
        Class javaType = param.getJavaType();

        if ((param.getMode() != ParameterDesc.IN)
                && (param.getIsReturn() == false)) {
            javaType = JavaUtils.getHolderValueType(javaType);
        }

        if ((use == Use.ENCODED) || (style == Style.RPC)) {

            // Add the type representing the param
            // Write <part name=param_name type=param_type>
            QName typeQName = param.getTypeQName();

            if (javaType != null) {
                typeQName = types.writeTypeAndSubTypeForPart(javaType, typeQName);
            }

            // types.writeElementForPart(javaType, param.getTypeQName());
            if (typeQName != null) {
                part.setName(param.getName());
                part.setTypeName(typeQName);
                msg.addPart(part);
            }
        } else if (use == Use.LITERAL) {

            // This is doc/lit.  So we should write out an element
            // declaration whose name and type may be found in the
            // ParameterDesc.
            QName qname = param.getQName();

            if (param.getTypeQName() == null) {
                log.warn(Messages.getMessage("registerTypeMappingFor01",
                        param.getJavaType().getName()));
                QName qName = types.writeTypeForPart(param.getJavaType(),null);
                if (qName != null) {
                    param.setTypeQName(qName);                    
                } else {
                    param.setTypeQName(Constants.XSD_ANYTYPE);                    
                }                    
            }

            if (param.getTypeQName().getNamespaceURI().equals("")) {
                param.setTypeQName(
                        new QName(intfNS, param.getTypeQName().getLocalPart()));
            }

            if (param.getQName().getNamespaceURI().equals("")) {
                qname = new QName(intfNS, param.getQName().getLocalPart());

                param.setQName(qname);
            }

            // Make sure qname's value is unique.
            ArrayList   names = (ArrayList)
                    usedElementNames.get(qname.getNamespaceURI());
            if (names == null) {
                names = new ArrayList(1);
                usedElementNames.put(qname.getNamespaceURI(), names);
            }
            else if (names.contains(qname.getLocalPart())) {
                qname = new QName(qname.getNamespaceURI(),
                    JavaUtils.getUniqueValue(names, qname.getLocalPart()));
            }
            names.add(qname.getLocalPart());

            types.writeElementDecl(qname,
                                   param.getJavaType(),
                                   param.getTypeQName(),
                                   false,
                                   param.getItemQName());

            part.setName(param.getName());
            part.setElementName(qname);
            msg.addPart(part);
        }

        // return the name of the parameter added
        return param.getName();
    
protected voidwritePortType(javax.wsdl.Definition def, javax.wsdl.Binding binding)
Create a PortType

param
def
param
binding
throws
WSDLException
throws
AxisFault


        QName portTypeQName = new QName(intfNS, getPortTypeName());

        // Get or create a portType
        PortType portType = def.getPortType(portTypeQName);
        boolean newPortType = false;

        if (portType == null) {
            portType = def.createPortType();

            portType.setUndefined(false);
            portType.setQName(portTypeQName);

            newPortType = true;
        } else if (binding.getBindingOperations().size() > 0) {

            // If both portType and binding already exist,
            // no additional processing is needed.
            return;
        }

        // Add the port and binding operations.
        ArrayList operations = serviceDesc.getOperations();

        for (Iterator i = operations.iterator(); i.hasNext();) {
            OperationDesc thisOper = (OperationDesc) i.next();
            BindingOperation bindingOper = writeOperation(def, binding,
                    thisOper);
            Operation oper = bindingOper.getOperation();
            OperationDesc messageOper = thisOper;

            // add the documentation to oper
            if (messageOper.getDocumentation() != null) {
                oper.setDocumentationElement(
                        createDocumentationElement(
                                messageOper.getDocumentation()));
            }

            if (serviceDesc2 != null) {

                // If a serviceDesc containing an impl class is provided,
                // try and locate the corresponding operation
                // (same name, same parm types and modes).  If a
                // corresponding operation is found, it is sent
                // to the writeMessages method so that its parameter
                // names will be used in the wsdl file.
                OperationDesc[] operArray =
                        serviceDesc2.getOperationsByName(thisOper.getName());
                boolean found = false;

                if (operArray != null) {
                    for (int j = 0; (j < operArray.length) && !found; j++) {
                        OperationDesc tryOper = operArray[j];

                        if (tryOper.getParameters().size()
                                == thisOper.getParameters().size()) {
                            boolean parmsMatch = true;

                            for (int k =
                                    0; (k < thisOper.getParameters().size())
                                    && parmsMatch; k++) {
                                if ((tryOper.getParameter(
                                        k).getMode() != thisOper.getParameter(
                                                k).getMode())
                                        || (!tryOper.getParameter(
                                                k).getJavaType().equals(
                                                        thisOper.getParameter(
                                                                k).getJavaType()))) {
                                    parmsMatch = false;
                                }
                            }

                            if (parmsMatch) {
                                messageOper = tryOper;
                                found = true;
                            }
                        }
                    }
                }
            }

            writeMessages(def, oper, messageOper, bindingOper);

            if (newPortType) {
                portType.addOperation(oper);
            }
        }

        if (newPortType) {
            def.addPortType(portType);
        }

        binding.setPortType(portType);
    
protected javax.wsdl.MessagewriteRequestMessage(javax.wsdl.Definition def, org.apache.axis.description.OperationDesc oper, javax.wsdl.BindingOperation bindop)
Create a Request Message

param
def
param
oper
return
throws
WSDLException
throws
AxisFault


        String partName;
        ArrayList bodyParts = new ArrayList();
        ArrayList parameters = oper.getAllInParams();

        Message msg = def.createMessage();
        QName qName = createMessageName(def,
                getRequestQName(oper).getLocalPart() + "Request");

        msg.setQName(qName);
        msg.setUndefined(false);

        // output all the parts for headers
        boolean headers = writeHeaderParts(def, parameters, bindop, msg, true);

        if (oper.getStyle() == Style.MESSAGE) {

            // If this is a MESSAGE-style operation, just write out
            // <xsd:any> for now.
            // TODO: Support custom schema in WSDD for these operations
            QName qname = oper.getElementQName();
            types.writeElementDecl(qname, Object.class,
                                   Constants.XSD_ANYTYPE, false, null);

            Part part = def.createPart();

            part.setName("part");
            part.setElementName(qname);
            msg.addPart(part);
            bodyParts.add(part.getName());

        } else if (oper.getStyle() == Style.WRAPPED) {

            // If we're WRAPPED, write the wrapper element first, and then
            // fill in any params.  If there aren't any params, we'll see
            // an empty <complexType/> for the wrapper element.
            partName = writeWrapperPart(def, msg, oper, true);
            bodyParts.add(partName);

        } else {
        	//Now we're either DOCUMENT or RPC. If we're doing doc/lit, and in the
        	//case of mulitple input params, we would warn user saying request
        	//message's type information is being written out as multiple parts
        	//than one single complexType and to interop with other soap stacks
        	//that do doc/lit by default, user might want to publish his service
        	//as a WRAPPED-LITERAL service instead.
        	//see http://issues.apache.org/jira/browse/AXIS-2017
        	if(oper.getStyle() == Style.DOCUMENT && parameters.size()>1 ) {
         		System.out.println(Messages.getMessage("warnDocLitInteropMultipleInputParts"));
         	}

            // write a part for each non-header parameter
            for (int i = 0; i < parameters.size(); i++) {
                ParameterDesc parameter = (ParameterDesc) parameters.get(i);
                if (!parameter.isInHeader() && !parameter.isOutHeader()) {
                    partName = writePartToMessage(def, msg, true, parameter);
                    bodyParts.add(partName);
                }
            }
        }

        // If we have headers, we must fill in the parts attribute of soap:body
        // if not, we just leave it out (which means all parts)
        if (headers) {
            // Find soap:body in binding
            List extensibilityElements = bindop.getBindingInput().getExtensibilityElements();
            for (int i = 0; i < extensibilityElements.size(); i++)
            {
                Object ele = extensibilityElements.get(i);
                if (ele instanceof SOAPBodyImpl)
                {
                    SOAPBodyImpl soapBody = (SOAPBodyImpl) ele;
                    soapBody.setParts(bodyParts);
                }
            }
        }

        return msg;
    
protected javax.wsdl.MessagewriteResponseMessage(javax.wsdl.Definition def, org.apache.axis.description.OperationDesc desc, javax.wsdl.BindingOperation bindop)
Create a Response Message

param
def
param
desc
return
throws
WSDLException
throws
AxisFault

        String partName;
        ArrayList bodyParts = new ArrayList();
        ArrayList parameters = desc.getAllOutParams();

        Message msg = def.createMessage();
        QName qName =
                createMessageName(def, getResponseQName(desc).getLocalPart());

        msg.setQName(qName);
        msg.setUndefined(false);

        // output all the parts for headers
        boolean headers = writeHeaderParts(def, parameters, bindop, msg, false);

        if (desc.getStyle() == Style.WRAPPED) {
            partName = writeWrapperPart(def, msg, desc, false);
            bodyParts.add(partName);
        } else {

            // Write the return value part
            ParameterDesc retParam = new ParameterDesc();

            if (desc.getReturnQName() == null) {
                String ns = "";

                if (desc.getStyle() != Style.RPC) {
                    ns = getServiceDesc().getDefaultNamespace();

                    if ((ns == null) || "".equals(ns)) {
                        ns = "http://ws.apache.org/axis/defaultNS";
                    }
                }

                retParam.setQName(new QName(ns, desc.getName() + "Return"));
            } else {
                retParam.setQName(desc.getReturnQName());
            }

            retParam.setTypeQName(desc.getReturnType());
            retParam.setMode(ParameterDesc.OUT);
            retParam.setIsReturn(true);
            retParam.setJavaType(desc.getReturnClass());
            String returnPartName = writePartToMessage(def, msg, false, retParam);
            bodyParts.add(returnPartName);

            // write a part for each non-header parameter
            for (int i = 0; i < parameters.size(); i++) {
                ParameterDesc parameter = (ParameterDesc) parameters.get(i);
                if (!parameter.isInHeader() && !parameter.isOutHeader()) {
                    partName = writePartToMessage(def, msg, false, parameter);
                    bodyParts.add(partName);
                }
            }

        }
        // If we have headers, we must fill in the parts attribute of soap:body
        // if not, we just leave it out (which means all parts)
        if (headers) {
            // Find soap:body in binding
            List extensibilityElements = bindop.getBindingOutput().getExtensibilityElements();
            for (int i = 0; i < extensibilityElements.size(); i++)
            {
                Object ele = extensibilityElements.get(i);
                if (ele instanceof SOAPBodyImpl)
                {
                    SOAPBodyImpl soapBody = (SOAPBodyImpl) ele;
                    soapBody.setParts(bodyParts);
                }
            }
        }

        return msg;
    
protected javax.wsdl.extensions.ExtensibilityElementwriteSOAPBody(javax.xml.namespace.QName operQName)
Method writeSOAPBody

param
operQName
return


        SOAPBody soapBody = new SOAPBodyImpl();

        // for now, if its document, it is literal use.
        if (use == Use.ENCODED) {
            soapBody.setUse("encoded");
            soapBody.setEncodingStyles(encodingList);
        } else {
            soapBody.setUse("literal");
        }

        if (style == Style.RPC) {
            if (targetService == null) {
                soapBody.setNamespaceURI(intfNS);
            } else {
                soapBody.setNamespaceURI(targetService);
            }
    
            if ((operQName != null) && !operQName.getNamespaceURI().equals("")) {
                soapBody.setNamespaceURI(operQName.getNamespaceURI());
            }
        }

        // The parts attribute will get set if we have headers.
        // This gets done when the Message & parts are generated
        // soapBody.setParts(...);

        return soapBody;
    
protected javax.wsdl.extensions.soap.SOAPFaultwriteSOAPFault(org.apache.axis.description.FaultDesc faultDesc)
Method writeSOAPFault

param
faultDesc
return


        SOAPFault soapFault = new com.ibm.wsdl.extensions.soap.SOAPFaultImpl();

        soapFault.setName(faultDesc.getName());

        if (use != Use.ENCODED) {
            soapFault.setUse("literal");

            // no namespace for literal, gets it from the element
        } else {
            soapFault.setUse("encoded");
            soapFault.setEncodingStyles(encodingList);

            // Set the namespace from the fault QName if it exists
            // otherwise use the target (or interface) namespace
            QName faultQName = faultDesc.getQName();

            if ((faultQName != null)
                    && !faultQName.getNamespaceURI().equals("")) {
                soapFault.setNamespaceURI(faultQName.getNamespaceURI());
            } else {
                if (targetService == null) {
                    soapFault.setNamespaceURI(intfNS);
                } else {
                    soapFault.setNamespaceURI(targetService);
                }
            }
        }

        return soapFault;
    
protected javax.wsdl.extensions.soap.SOAPHeaderwriteSOAPHeader(org.apache.axis.description.ParameterDesc p, javax.xml.namespace.QName messageQName, java.lang.String partName)
Create a SOAPHeader element

        SOAPHeaderImpl soapHeader = new SOAPHeaderImpl();

        // for now, if its document, it is literal use.
        if (use == Use.ENCODED) {
            soapHeader.setUse("encoded");
            soapHeader.setEncodingStyles(encodingList);
        } else {
            soapHeader.setUse("literal");
        }

        // Set namespace
        if (targetService == null) {
            soapHeader.setNamespaceURI(intfNS);
        } else {
            soapHeader.setNamespaceURI(targetService);
        }
        QName headerQName = p.getQName();
        if ((headerQName != null) && !headerQName.getNamespaceURI().equals("")) {
            soapHeader.setNamespaceURI(headerQName.getNamespaceURI());
        }

        // Set the Message and Part information
         soapHeader.setMessage(messageQName);
         soapHeader.setPart(partName);

        return soapHeader;
    
protected voidwriteService(javax.wsdl.Definition def, javax.wsdl.Binding binding)
Create the service.

param
def
param
binding


        QName serviceElementQName = new QName(implNS, getServiceElementName());

        // Locate an existing service, or get a new service
        Service service = def.getService(serviceElementQName);

        if (service == null) {
            service = def.createService();

            service.setQName(serviceElementQName);
            def.addService(service);
        }

        if (description != null) {
            service.setDocumentationElement(
                    createDocumentationElement(description));
        } else if (serviceDesc.getDocumentation() != null) {
            service.setDocumentationElement(
                    createDocumentationElement(
                            serviceDesc.getDocumentation()));
        }

        // Add the port
        Port port = def.createPort();

        port.setBinding(binding);

        // Probably should use the end of the location Url
        port.setName(getServicePortName());

        SOAPAddress addr = new SOAPAddressImpl();

        addr.setLocationURI(locationUrl);
        port.addExtensibilityElement(addr);
        service.addPort(port);
    
public java.lang.StringwriteWrapperPart(javax.wsdl.Definition def, javax.wsdl.Message msg, org.apache.axis.description.OperationDesc oper, boolean request)
Write out the schema definition for a WRAPPED operation request or response.

param
def
param
msg
param
oper
param
request
return
the name of the part the was written
throws
AxisFault


        QName qname = request
                ? getRequestQName(oper)
                : getResponseQName(oper);

        boolean hasParams;
        if (request) {
            hasParams = (oper.getNumInParams() > 0);
        } else {
            if (oper.getReturnClass() != void.class) {
                hasParams = true;
            } else {
                hasParams = (oper.getNumOutParams() > 0);
            }
        }

        // First write the wrapper element itself.
        Element sequence = types.writeWrapperElement(qname, request, hasParams);

        // If we got anything back above, there must be parameters in the
        // operation, and it's a <sequence> node in which to write them...
        if (sequence != null) {
            ArrayList parameters = request
                    ? oper.getAllInParams()
                    : oper.getAllOutParams();

            if (!request) {
                String retName;
                
                if (oper.getReturnQName() == null) {
                    retName = oper.getName() + "Return";
                } else {
                    retName = oper.getReturnQName().getLocalPart();
                }

                types.writeWrappedParameter(sequence, retName,
                        oper.getReturnType(),
                        oper.getReturnClass());
            }

            for (int i = 0; i < parameters.size(); i++) {
                ParameterDesc parameter = (ParameterDesc) parameters.get(i);

                // avoid headers
                if (!parameter.isInHeader() && !parameter.isOutHeader())
                {
                    types.writeWrappedParameter(sequence,
                                                parameter.getName(),
                                                parameter.getTypeQName(),
                                                parameter.getJavaType());
                }
            }
        }

        // Finally write the part itself
        Part part = def.createPart();

        part.setName("parameters");    // We always use "parameters"
        part.setElementName(qname);
        msg.addPart(part);

        return part.getName();