/**
   * This method scans the supplied wsdl to locate the element definition and return the Java type
   * associated with its type.
   *
   * @param wsdl The WSDL
   * @param element The element
   * @param locator The locator
   * @return The Java type, or null if not found
   */
  protected String getJavaType(javax.wsdl.Definition wsdl, QName element, ResourceLocator locator) {
    return (JavaGeneratorUtil.getJavaPackage(element.getNamespaceURI())
        + "."
        + JavaGeneratorUtil.getJavaClassName(element.getLocalPart()));

    /* Return the Element as the Java type (SAVARA-379)
     *
    java.util.List<?> elems=wsdl.getTypes().getExtensibilityElements();

    if (elems != null) {
    	for (Object obj : elems) {

    		if (obj instanceof javax.wsdl.extensions.schema.Schema) {
    			javax.wsdl.extensions.schema.Schema schema=(javax.wsdl.extensions.schema.Schema)obj;

    			for (Object value : schema.getImports().values()) {
    				if (value instanceof java.util.List<?>) {
    					for (Object si : (java.util.List<?>)value) {
    						if (si instanceof javax.wsdl.extensions.schema.SchemaImport) {
    							String javaType=JavaGeneratorUtil.getElementJavaType(element,
    									((javax.wsdl.extensions.schema.SchemaImport)si).getSchemaLocationURI(), locator);

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

    	logger.warning("Failed to find java type for element '"+element+
    			"' in wsdl: "+wsdl);

    } else {
    	logger.warning("Getting java type for element '"+element+
    			"' failed as unable to find extensibility elements in wsdl: "+wsdl);
    }

    return (null);
    */
  }
  protected void addPortTypeTransformers(
      PortType portType,
      boolean provider,
      StringBuffer transformers,
      javax.wsdl.Definition wsdl,
      ResourceLocator locator,
      String srcFolder) {
    String attr1 = (provider ? "from" : "to");
    String attr2 = (provider ? "to" : "from");

    for (Object opobj : portType.getOperations()) {
      if (opobj instanceof javax.wsdl.Operation) {
        javax.wsdl.Operation op = (javax.wsdl.Operation) opobj;

        String qname = "";
        String javaType = "";
        String javaPackage = "";

        javax.wsdl.Part p =
            (javax.wsdl.Part) op.getInput().getMessage().getParts().values().iterator().next();
        qname = p.getElementName().toString();

        javaType = getJavaType(wsdl, p.getElementName(), locator);

        if (javaType != null) {
          int ind = javaType.lastIndexOf('.');
          if (ind != -1) {
            javaPackage = javaType.substring(0, ind);
          }
        }

        transformers.append("\t\t<xform:transform.jaxb\r\n");
        transformers.append("\t\t\t" + attr1 + "=\"" + qname + "\"\r\n");
        transformers.append("\t\t\t" + attr2 + "=\"java:" + javaType + "\"\r\n");
        transformers.append("\t\t\tcontextPath=\"" + javaPackage + "\"/>\r\n");

        if (op.getOutput() != null) {
          p = (javax.wsdl.Part) op.getOutput().getMessage().getParts().values().iterator().next();
          qname = p.getElementName().toString();

          javaType = getJavaType(wsdl, p.getElementName(), locator);

          if (javaType != null) {
            int ind = javaType.lastIndexOf('.');
            if (ind != -1) {
              javaPackage = javaType.substring(0, ind);
            }
          }

          transformers.append("\t\t<xform:transform.jaxb\r\n");
          transformers.append("\t\t\t" + attr2 + "=\"" + qname + "\"\r\n");
          transformers.append("\t\t\t" + attr1 + "=\"java:" + javaType + "\"\r\n");
          transformers.append("\t\t\tcontextPath=\"" + javaPackage + "\"/>\r\n");
        }

        for (Object faultObj : op.getFaults().values()) {
          if (faultObj instanceof javax.wsdl.Fault) {
            javax.wsdl.Fault fault = (javax.wsdl.Fault) faultObj;

            p = (javax.wsdl.Part) fault.getMessage().getParts().values().iterator().next();
            qname = p.getElementName().toString();

            String javaFaultType = getJavaType(wsdl, p.getElementName(), locator);

            String pack =
                JavaGeneratorUtil.getJavaPackage(fault.getMessage().getQName().getNamespaceURI());

            javaType =
                pack
                    + "."
                    + JavaGeneratorUtil.getJavaClassName(
                        fault.getMessage().getQName().getLocalPart());

            String transformerClassName = getFaultTransformerClassName(javaType, provider);

            String faultTransClass = pack + "." + transformerClassName;

            transformers.append("\t\t<xform:transform.java class=\"" + faultTransClass + "\"\r\n");
            transformers.append("\t\t\t" + attr2 + "=\"" + qname + "\"\r\n");
            transformers.append("\t\t\t" + attr1 + "=\"java:" + javaType + "\"/>\r\n");

            // Create transformer class
            String folder = pack.replace('.', java.io.File.separatorChar);

            String javaFile = folder + java.io.File.separator + transformerClassName;

            java.io.File jFile =
                new java.io.File(srcFolder + java.io.File.separator + javaFile + ".java");

            jFile.getParentFile().mkdirs();

            try {
              java.io.FileOutputStream fos = new java.io.FileOutputStream(jFile);

              generateFaultTransformer(qname, javaType, javaFaultType, provider, fos);

              fos.close();
            } catch (Exception e) {
              logger.log(Level.SEVERE, "Failed to create fault transformer", e);
            }
          }
        }
      }
    }
  }