[jboss-svn-commits] JBossWS SVN: r919 - in branches/jgreene: . trunk trunk/src/main/java/org/jboss/ws trunk/src/main/java/org/jboss/ws/binding trunk/src/main/java/org/jboss/ws/common trunk/src/main/java/org/jboss/ws/deployment trunk/src/main/java/org/jboss/ws/eventing trunk/src/main/java/org/jboss/ws/jaxrpc trunk/src/main/java/org/jboss/ws/jaxws trunk/src/main/java/org/jboss/ws/jaxws/core trunk/src/main/java/org/jboss/ws/jaxws/spi trunk/src/main/java/org/jboss/ws/metadata trunk/src/main/java/org/jboss/ws/metadata/wsdl trunk/src/main/java/org/jboss/ws/server trunk/src/main/java/org/jboss/ws/tools trunk/src/main/java/org/jboss/ws/tools/helpers trunk/src/main/java/org/jboss/ws/tools/jaxws trunk/src/main/java/org/jboss/ws/tools/metadata trunk/src/main/java/org/jboss/ws/utils trunk/src/test/java/org/jboss/test/ws/jbws1125 trunk/src/test/java/org/jboss/test/ws/tools/validation

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 8 18:12:52 EDT 2006


Author: jason.greene at jboss.com
Date: 2006-09-08 18:12:40 -0400 (Fri, 08 Sep 2006)
New Revision: 919

Added:
   branches/jgreene/trunk/
   branches/jgreene/trunk/.classpath
   branches/jgreene/trunk/src/main/java/org/jboss/ws/common/
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/TestMe.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceMessageReference.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java
Removed:
   branches/jgreene/trunk/.classpath
   branches/jgreene/trunk/src/main/java/org/jboss/ws/common/
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java
Modified:
   branches/jgreene/trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/common/CommonClient.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/eventing/EventingEndpointBase.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/core/HTTPBindingImpl.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPBindingImpl.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/server/MessageContextInjector.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/server/ServletHeaderSource.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/IOUtils.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JBossWSEntityResolver.java
   branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java
   branches/jgreene/trunk/src/test/java/org/jboss/test/ws/jbws1125/JBWS1125TestCase.java
   branches/jgreene/trunk/src/test/java/org/jboss/test/ws/tools/validation/WSDL11Validator.java
Log:
Commit JAX-WS changes to date, more descriptive summary will come with a merge


Copied: branches/jgreene/trunk (from rev 801, trunk)

Deleted: branches/jgreene/trunk/.classpath
===================================================================
--- trunk/.classpath	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/.classpath	2006-09-08 22:12:40 UTC (rev 919)
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main/java"/>
-	<classpathentry excluding="org/jboss/test/ws/interop/" kind="src" path="src/test/java"/>
-	<classpathentry kind="lib" path="thirdparty/activation.jar"/>
-	<classpathentry kind="lib" path="thirdparty/mailapi.jar"/>
-	<classpathentry kind="lib" path="thirdparty/qdox.jar"/>
-	<classpathentry kind="lib" path="thirdparty/servlet-api.jar"/>
-	<classpathentry kind="lib" path="thirdparty/wsdl4j.jar"/>
-	<classpathentry kind="lib" path="thirdparty/xercesImpl.jar"/>
-	<classpathentry kind="lib" path="thirdparty/xml-apis.jar"/>
-	<classpathentry kind="lib" path="thirdparty/xmlsec.jar"/>
-	<classpathentry kind="lib" path="thirdparty/xmlunit1.0.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="thirdparty/xalan.jar"/>
-	<classpathentry kind="lib" path="thirdparty/junit.jar"/>
-	<classpathentry kind="lib" path="thirdparty/concurrent.jar"/>
-	<classpathentry kind="lib" path="thirdparty/javassist.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.x"/>
-	<classpathentry kind="lib" path="thirdparty/jboss-xml-binding.jar"/>
-	<classpathentry kind="lib" path="thirdparty/policy-1.0.jar"/>
-	<classpathentry kind="lib" path="thirdparty/stax-api-1.0.jar"/>
-	<classpathentry kind="lib" path="thirdparty/wstx-lgpl-2.0.6.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jaxb-api.jar"/>
-	<classpathentry kind="lib" path="thirdparty/ant.jar"/>
-	<classpathentry sourcepath="/home/tdiesler/svn/jboss/common/tags/JBossCommon-1.0.2/src/main" kind="lib" path="thirdparty/jboss-common.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jboss-container.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jboss-microcontainer.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jboss-remoting.jar"/>
-	<classpathentry kind="output" path="output-eclipse"/>
-</classpath>

Copied: branches/jgreene/trunk/.classpath (from rev 802, trunk/.classpath)

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -25,7 +25,7 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -43,6 +43,7 @@
 import org.jboss.ws.jaxrpc.ParameterWrapping;
 import org.jboss.ws.metadata.OperationMetaData;
 import org.jboss.ws.metadata.ParameterMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.soap.SOAPContentElement;
 import org.jboss.ws.utils.HolderUtils;
 import org.jboss.ws.utils.JavaUtils;
@@ -66,6 +67,8 @@
    private Map<QName, Object> resPayload = new LinkedHashMap<QName, Object>();
    // The return value
    private Object returnValue;
+   // Map of output parameters, key being the parameter index in the method signature
+   private Map<Integer, Object> outParameters = new HashMap<Integer, Object>();
 
    public EndpointInvocation(OperationMetaData opMetaData)
    {
@@ -82,6 +85,11 @@
       return opMetaData.getJavaMethod();
    }
 
+   public Map<Integer, Object> getOutParameters()
+   {
+      return outParameters;
+   }
+
    public List<QName> getRequestParamNames()
    {
       List<QName> xmlNames = new ArrayList<QName>();
@@ -104,31 +112,24 @@
       return paramValue;
    }
 
-   /** Returns the payload that can be passed on to the endpoint implementation 
+   /** Returns the payload that can be passed on to the endpoint implementation
     */
    public Object[] getRequestPayload() throws SOAPException
    {
       log.debug("getRequestPayload");
       List<QName> xmlNames = getRequestParamNames();
-      ArrayList<Object> objPayload = new ArrayList<Object>(); 
+
+      Object[] payload = new Object[opMetaData.getJavaMethod().getParameterTypes().length];
       for (int i = 0; i < xmlNames.size(); i++)
       {
          QName xmlName = xmlNames.get(i);
          Object paramValue = getRequestParamValue(xmlName);
 
          ParameterMetaData paramMetaData = opMetaData.getParameter(xmlName);
-         paramValue = syncEndpointInputParam(paramMetaData, paramValue);
-         if(opMetaData.isDocumentWrapped() && paramMetaData.isInHeader() == false)
-         {
-            List<Object> objList = Arrays.asList((Object[])paramValue);
-            objPayload.addAll(objList);
-         }
-         else
-         {
-            objPayload.add(paramValue);
-         }
+         syncEndpointInputParam(paramMetaData, paramValue, payload);
       }
-      return objPayload.toArray();
+
+      return payload;
    }
 
    public List<QName> getResponseParamNames()
@@ -243,61 +244,19 @@
     */
    public void initInputParams(Object[] inputParams)
    {
-      List<ParameterMetaData> paramMetaDataList = opMetaData.getParameters();
-      if (opMetaData.isDocumentWrapped() && paramMetaDataList.size() != 0)
+      for (ParameterMetaData paramMetaData : opMetaData.getParameters())
       {
-         Object value = ParameterWrapping.wrapRequestParameters(opMetaData, inputParams);
-         ParameterMetaData paramMetaData = paramMetaDataList.get(0);
          QName xmlName = paramMetaData.getXmlName();
-         setRequestParamValue(xmlName, value);
-         
-         if (inputParams != null)
-         {
-            int wrappedParamsCount = paramMetaData.getWrappedVariables().size();
-            int lastParam = Math.min(paramMetaDataList.size() - 1, inputParams.length - wrappedParamsCount);
+         Class javaType = paramMetaData.getJavaType();
 
-            // document/literal wrapped with bound headers
-            for (int i = 0; i < lastParam - 1; i++)
-            {
-               paramMetaData = paramMetaDataList.get(i + 1);
-               if (paramMetaData.isInHeader())
-               {
-                  xmlName = paramMetaData.getXmlName();
-                  Class javaType = paramMetaData.getJavaType();
-
-                  value = inputParams[i + wrappedParamsCount];
-                  if (value != null)
-                  {
-                     Class inputType = value.getClass();
-
-                     if (HolderUtils.isHolderType(inputType))
-                     {
-                        inputType = HolderUtils.getValueType(inputType);
-                        value = HolderUtils.getHolderValue(value);
-                     }
-
-                     // Verify that the java type matches a registered xmlType
-                     // Attachments are skipped because they don't use type mapping
-                     if (!paramMetaData.isSwA() && !paramMetaData.isXOP())
-                     {
-                        if (JavaUtils.isAssignableFrom(javaType, inputType) == false)
-                           throw new WSException("Parameter '" + javaType + "' not assignable from: " + inputType);
-                     }
-                  }
-                  setRequestParamValue(xmlName, value);
-               }
-            }
+         Object value;
+         if (opMetaData.isDocumentWrapped() && paramMetaData.isInHeader() == false)
+         {
+            value = ParameterWrapping.wrapRequestParameters(paramMetaData, inputParams);
          }
-      }
-      else
-      {
-         for (int i = 0; i < paramMetaDataList.size(); i++)
+         else
          {
-            ParameterMetaData paramMetaData = paramMetaDataList.get(i);
-            QName xmlName = paramMetaData.getXmlName();
-            Class javaType = paramMetaData.getJavaType();
-
-            Object value = inputParams[i];
+            value = inputParams[paramMetaData.getIndex()];
             if (value != null)
             {
                Class inputType = value.getClass();
@@ -316,56 +275,31 @@
                      throw new WSException("Parameter '" + javaType + "' not assignable from: " + inputType);
                }
             }
-            setRequestParamValue(xmlName, value);
          }
+
+         setRequestParamValue(xmlName, value);
       }
    }
 
-   /** Synchronize the operation paramters with the endpoint method parameters
+   /**
+    * Synchronize the operation paramters with the endpoint method parameters
     */
-   private Object syncEndpointInputParam(ParameterMetaData paramMetaData, final Object paramValue)
+   private void syncEndpointInputParam(ParameterMetaData paramMetaData, final Object paramValue, Object[] payload)
    {
       Object retValue = paramValue;
       Method method = opMetaData.getJavaMethod();
       Class[] targetParameterTypes = method.getParameterTypes();
 
-      if (opMetaData.isDocumentWrapped())
+      if (opMetaData.isDocumentWrapped() && paramMetaData.isInHeader() == false)
       {
-         // Unwrap the request parameters
-         if (paramMetaData.isInHeader() == false)
-         {
-            retValue = ParameterWrapping.unwrapRequestParameters(opMetaData, paramValue);
-         }
-         else
-         {
-            if (paramMetaData.getMode() == ParameterMode.INOUT || paramMetaData.getMode() == ParameterMode.OUT)
-            {
-               Class javaType = paramMetaData.getJavaType();
-               for (int i=0; i < targetParameterTypes.length; i++)
-               {
-                  Class targetType = targetParameterTypes[i];
-                  if (HolderUtils.isHolderType(targetType))
-                  {
-                     Class valueType = HolderUtils.getValueType(targetType);
-                     if (JavaUtils.isAssignableFrom(valueType, javaType))
-                     {
-                        Holder holder = HolderUtils.getHolderInstance(targetType);
-                        HolderUtils.setHolderValue(holder, paramValue);
-                        retValue = holder;
-                        
-                        QName xmlName = paramMetaData.getXmlName();
-                        setResponseParamValue(xmlName, holder);
-                     }
-                  }
-               }
-            }
-         }
+         outParameters = ParameterWrapping.unwrapRequestParameters(paramMetaData, paramValue, payload);
+         syncOutWrappedParameters(targetParameterTypes);
       }
       else
       {
          // Replace INOUT and OUT parameters by their respective holder values
-         int paramTypeIndex = opMetaData.getParameters().indexOf(paramMetaData);
-         Class targetParameterType = targetParameterTypes[paramTypeIndex];
+         int index = paramMetaData.getIndex();
+         Class targetParameterType = targetParameterTypes[index];
 
          if (paramMetaData.getMode() == ParameterMode.INOUT || paramMetaData.getMode() == ParameterMode.OUT)
          {
@@ -377,21 +311,37 @@
             setResponseParamValue(xmlName, holder);
          }
 
-         if (JavaUtils.isPrimitive(targetParameterType))
-         {
-            retValue = JavaUtils.getPrimitiveValue(paramValue);
-         }
-
          if (retValue != null)
          {
             Class valueType = retValue.getClass();
             if (JavaUtils.isAssignableFrom(targetParameterType, valueType) == false)
                throw new WSException("Parameter " + targetParameterType.getName() + " is not assignable from: " + getTypeName(retValue));
          }
+
+         log.debug("syncEndpointInputParam: " + getTypeName(paramValue) + " -> " + getTypeName(retValue) + "(" + index + ")");
+         payload[index] = retValue;
       }
+   }
 
-      log.debug("syncEndpointInputParam: " + getTypeName(paramValue) + " -> " + getTypeName(retValue));
-      return retValue;
+   private void syncOutWrappedParameters(Class[] targetParameterTypes)
+   {
+      ParameterMetaData returnMetaData = opMetaData.getReturnParameter();
+      if (returnMetaData != null)
+      {
+         for (WrappedParameter param : returnMetaData.getWrappedParameters())
+         {
+            try
+            {
+               if (param.index >= 0)
+                  outParameters.put(param.index, targetParameterTypes[param.index].newInstance());
+            }
+            catch (Exception e)
+            {
+               throw new WSException("Could not add output param: " + param.name, e);
+
+            }
+         }
+      }
    }
 
    private String getTypeName(Object value)
@@ -399,4 +349,4 @@
       String valueType = (value != null ? value.getClass().getName() : null);
       return valueType;
    }
-}
+}
\ No newline at end of file

Copied: branches/jgreene/trunk/src/main/java/org/jboss/ws/common (from rev 802, trunk/src/main/java/org/jboss/ws/common)

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/common/CommonClient.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/common/CommonClient.java	2006-08-22 01:42:58 UTC (rev 802)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/common/CommonClient.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -62,13 +62,13 @@
 import org.jboss.ws.utils.HolderUtils;
 import org.jboss.ws.utils.JavaUtils;
 
-/** 
+/**
  * Provides support for the dynamic invocation of a service endpoint.
  *
  * @author Thomas.Diesler at jboss.org
  * @since 10-Oct-2004
  */
-public abstract class CommonClient 
+public abstract class CommonClient
 {
    // provide logging
    private static Logger log = Logger.getLogger(CommonClient.class);
@@ -79,7 +79,7 @@
    protected QName operationName;
    // Output parameters
    protected EndpointInvocation epInv;
-   
+
    // The binding provider
    private BindingProvider bindingProvider;
 
@@ -103,7 +103,7 @@
 
    /** Create a call for a known WSDL endpoint.
     */
-   protected CommonClient(ServiceMetaData serviceMetaData, QName portName, QName opName) 
+   protected CommonClient(ServiceMetaData serviceMetaData, QName portName, QName opName)
    {
       if (serviceMetaData != null)
       {
@@ -131,7 +131,7 @@
     */
    public abstract String getTargetEndpointAddress();
 
-   /** Sets the address of the target service endpoint. 
+   /** Sets the address of the target service endpoint.
     */
    public abstract void setTargetEndpointAddress(String address);
 
@@ -191,7 +191,7 @@
          ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousService"));
          wsMetaData.addService(serviceMetaData);
 
-         epMetaData = new ClientEndpointMetaData(serviceMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousPort"), Type.JAXRPC);
+         epMetaData = new ClientEndpointMetaData(serviceMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousPort"), new QName(Constants.NS_JBOSSWS_URI, "Anonymous"), Type.JAXRPC);
          epMetaData.setStyle(Style.RPC);
 
          serviceMetaData.addEndpoint(epMetaData);
@@ -248,14 +248,14 @@
          SOAPMessage reqMessage = (SOAPMessage)binding.bindRequestMessage(opMetaData, epInv, unboundHeaders);
 
          setOutboundContextProperties();
-         
+
          // Call the request handlers
          QName portName = epMetaData.getQName();
 
          if (callRequestHandlerChain(portName))
          {
             String targetAddress = getTargetEndpointAddress();
-            
+
             // Fall back to wsa:To
             AddressingProperties addrProps = (AddressingProperties)msgContext.getProperty(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
             if (targetAddress == null && addrProps != null && addrProps.getTo() != null)
@@ -288,7 +288,7 @@
             syncMessageProperties(callProps, msgContext);
 
             EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
-            
+
             SOAPMessage resMessage;
             if (oneway)
             {
@@ -304,7 +304,7 @@
          }
 
          setInboundContextProperties();
-         
+
          // Get the return object
          Object retObj = null;
          if (oneway == false)
@@ -378,14 +378,10 @@
       {
          retValue = epInv.getReturnValue();
          if (opMetaData.isDocumentWrapped())
-            retValue = ParameterWrapping.unwrapResponseParameter(opMetaData, retValue);
-
-         if (JavaUtils.isPrimitive(retMetaData.getJavaType()))
-            retValue = JavaUtils.getPrimitiveValue(retValue);
+            retValue = ParameterWrapping.unwrapResponseParameters(retMetaData, retValue, inParams);
       }
 
       // Set the holder values for INOUT parameters
-      int index = 0;
       for (ParameterMetaData paramMetaData : opMetaData.getParameters())
       {
          ParameterMode paramMode = paramMetaData.getMode();
@@ -394,14 +390,10 @@
          {
             QName xmlName = paramMetaData.getXmlName();
             Object value = epInv.getResponseParamValue(xmlName);
+            int index = paramMetaData.getIndex();
             log.debug("holder [" + index + "] " + xmlName);
             HolderUtils.setHolderValue(inParams[index], value);
          }
-
-         if (index == 0 && opMetaData.isDocumentWrapped())
-            index = paramMetaData.getWrappedVariables().size() - 1;
-
-         index++;
       }
 
       return retValue;

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,416 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.deployment;
+
+// $Id$
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.ObjectName;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingProperties;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.addressing.AddressingPropertiesImpl;
+import org.jboss.ws.addressing.metadata.AddressingOpMetaExt;
+import org.jboss.ws.eventing.EventingConstants;
+import org.jboss.ws.eventing.deployment.EventingEndpoint;
+import org.jboss.ws.eventing.metadata.EventingEpMetaExt;
+import org.jboss.ws.jaxrpc.UnqualifiedFaultException;
+import org.jboss.ws.jaxrpc.Use;
+import org.jboss.ws.metadata.EndpointMetaData;
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.metadata.ServerEndpointMetaData;
+import org.jboss.ws.metadata.TypesMetaData;
+import org.jboss.ws.metadata.j2ee.UnifiedApplicationMetaData;
+import org.jboss.ws.metadata.j2ee.UnifiedBeanMetaData;
+import org.jboss.ws.metadata.j2ee.UnifiedMessageDrivenMetaData;
+import org.jboss.ws.metadata.wsdl.NCName;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
+import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLInterface;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceFault;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutfault;
+import org.jboss.ws.metadata.wsdl.WSDLProperty;
+import org.jboss.ws.metadata.wsdl.WSDLService;
+import org.jboss.ws.server.ServiceEndpointManager;
+import org.jboss.ws.server.ServiceEndpointManagerFactory;
+import org.jboss.ws.utils.ObjectNameFactory;
+
+/** An abstract meta data builder.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 19-May-2005
+ */
+public abstract class AbstractMetaDataBuilder
+{
+   // provide logging
+   private final static Logger log = Logger.getLogger(AbstractMetaDataBuilder.class);
+
+   protected ClassLoader classLoader;
+   protected URLClassLoader resourceLoader;
+
+   public void setClassLoader(ClassLoader classLoader)
+   {
+      this.classLoader = classLoader;
+   }
+
+   public void setResourceLoader(URLClassLoader resourceLoader)
+   {
+      this.resourceLoader = resourceLoader;
+   }
+
+   /** Initialize the endpoint encoding style from the binding operations
+    */
+   protected void initEndpointEncodingStyle(EndpointMetaData epMetaData)
+   {
+      WSDLDefinitions wsdlDefinitions = epMetaData.getServiceMetaData().getWsdlDefinitions();
+      for (WSDLService wsdlService : wsdlDefinitions.getServices())
+      {
+         for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints())
+         {
+            if (epMetaData.getQName().equals(wsdlEndpoint.getQName()))
+            {
+               QName bindQName = wsdlEndpoint.getBinding();
+               NCName ncName = new NCName(bindQName.getLocalPart());
+               WSDLBinding wsdlBinding = wsdlDefinitions.getBinding(ncName);
+               if (wsdlBinding == null)
+                  throw new WSException("Cannot obtain binding: " + ncName);
+
+               for (WSDLBindingOperation wsdlBindingOperation : wsdlBinding.getOperations())
+               {
+                  String encStyle = wsdlBindingOperation.getEncodingStyle();
+                  epMetaData.setEncodingStyle(Use.valueOf(encStyle));
+               }
+            }
+         }
+      }
+   }
+
+   protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions)
+   {
+      for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces())
+      {
+         WSDLProperty eventSourceProp = wsdlInterface.getProperty(Constants.WSDL_PROPERTY_EVENTSOURCE);
+         if (eventSourceProp != null && epMetaData instanceof ServerEndpointMetaData)
+         {
+            ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+            String eventSourceNS = wsdlInterface.getQName().getNamespaceURI() + "/" + wsdlInterface.getQName().getLocalPart();
+            Object notificationSchema = null; // todo: resolve schema from operation message
+
+            EventingEpMetaExt ext = new EventingEpMetaExt(EventingConstants.NS_EVENTING);
+            ext.setEventSourceNS(eventSourceNS);
+            ext.setNotificationSchema(notificationSchema);
+
+            sepMetaData.addExtension(ext);
+            sepMetaData.setManagedEndpointBean(EventingEndpoint.class.getName());
+         }
+      }
+   }
+
+   protected ObjectName getServiceEndpointID(UnifiedDeploymentInfo udi, ServerEndpointMetaData sepMetaData)
+   {
+      String endpoint = sepMetaData.getLinkName();
+      String context = sepMetaData.getContextRoot();
+      if (context.startsWith("/"))
+         context = context.substring(1);
+
+      StringBuilder idstr = new StringBuilder(ServerEndpointMetaData.SEPID_DOMAIN + ":");
+      idstr.append(ServerEndpointMetaData.SEPID_PROPERTY_CONTEXT + "=" + context);
+      idstr.append("," + ServerEndpointMetaData.SEPID_PROPERTY_ENDPOINT + "=" + endpoint);
+
+      // Add JMS destination JNDI name for MDB endpoints
+      if (udi.metaData instanceof UnifiedApplicationMetaData)
+      {
+         String ejbName = sepMetaData.getLinkName();
+         if (ejbName == null)
+            throw new WSException("Cannot obtain ejb-link from port component");
+
+         UnifiedApplicationMetaData applMetaData = (UnifiedApplicationMetaData)udi.metaData;
+         UnifiedBeanMetaData beanMetaData = (UnifiedBeanMetaData)applMetaData.getBeanByEjbName(ejbName);
+         if (beanMetaData == null)
+            throw new WSException("Cannot obtain ejb meta data for: " + ejbName);
+
+         if (beanMetaData instanceof UnifiedMessageDrivenMetaData)
+         {
+            UnifiedMessageDrivenMetaData mdMetaData = (UnifiedMessageDrivenMetaData)beanMetaData;
+            String jndiName = mdMetaData.getDestinationJndiName();
+            idstr.append(",jms=" + jndiName);
+         }
+      }
+
+      return ObjectNameFactory.create(idstr.toString());
+   }
+
+   protected void buildFaultMetaData(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation)
+   {
+      TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
+
+      WSDLInterface wsdlInterface = wsdlOperation.getWsdlInterface();
+      for (WSDLInterfaceOperationOutfault outFault : wsdlOperation.getOutfaults())
+      {
+         QName ref = outFault.getRef();
+
+         WSDLInterfaceFault wsdlFault = wsdlInterface.getFault(new NCName(ref.getLocalPart()));
+         QName xmlName = wsdlFault.getElement();
+         QName xmlType = wsdlFault.getXmlType();
+         String javaTypeName = null;
+
+         if (typesMetaData.getTypeMappingByXMLType(xmlType) != null)
+            javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName();
+
+         if (javaTypeName == null)
+         {
+            log.warn("Cannot obtain java type mapping for: " + xmlType);
+            javaTypeName = new UnqualifiedFaultException(xmlType).getClass().getName();
+         }
+
+         FaultMetaData faultMetaData = new FaultMetaData(opMetaData, xmlName, xmlType, javaTypeName);
+         opMetaData.addFault(faultMetaData);
+      }
+   }
+
+   /** Process operation meta data extensions. */
+   protected void processOpMetaExtensions(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation)
+   {
+
+      String tns = wsdlOperation.getQName().getNamespaceURI();
+      String portTypeName = wsdlOperation.getQName().getLocalPart();
+
+      AddressingProperties ADDR = new AddressingPropertiesImpl();
+      AddressingOpMetaExt addrExt = new AddressingOpMetaExt(ADDR.getNamespaceURI());
+
+      // inbound action
+      WSDLProperty wsaInAction = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_ACTION_IN);
+      if (wsaInAction != null)
+      {
+         addrExt.setInboundAction(wsaInAction.getValue());
+      }
+      else
+      {
+         WSDLProperty messageName = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_IN);
+         addrExt.setInboundAction(tns + "/" + portTypeName + "/" + messageName);
+      }
+
+      // outbound action
+      WSDLProperty wsaOutAction = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_ACTION_OUT);
+      if (wsaOutAction != null)
+      {
+         addrExt.setOutboundAction(wsaOutAction.getValue());
+      }
+      else
+      {
+         WSDLProperty messageName = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_OUT);
+         addrExt.setOutboundAction(tns + "/" + portTypeName + "/" + messageName);
+      }
+
+      opMetaData.addExtension(addrExt);
+   }
+
+   /** Get the web service address for a given path
+    */
+   public String getServiceEndpointAddress(String uriScheme, String servicePath)
+   {
+      if (servicePath == null || servicePath.length() == 0)
+         throw new WSException("Service path cannot be null");
+
+      if (servicePath.endsWith("/*"))
+         servicePath = servicePath.substring(0, servicePath.length() - 2);
+
+      if (uriScheme == null)
+         uriScheme = "http";
+
+      ServiceEndpointManagerFactory factory = ServiceEndpointManagerFactory.getInstance();
+      ServiceEndpointManager epManager = factory.getServiceEndpointManager();
+      String host = epManager.getWebServiceHost();
+      int port = epManager.getWebServicePort();
+      if ("https".equals(uriScheme))
+         port = epManager.getWebServiceSecurePort();
+
+      String urlStr = uriScheme + "://" + host + ":" + port + servicePath;
+      try
+      {
+         return new URL(urlStr).toExternalForm();
+      }
+      catch (MalformedURLException e)
+      {
+         throw new WSException("Malformed URL: " + urlStr);
+      }
+   }
+
+   /** Replace the address locations for a given port component.
+    */
+   protected void replaceAddressLocation(ServerEndpointMetaData epMetaData)
+   {
+      WSDLDefinitions wsdlDefinitions = epMetaData.getServiceMetaData().getWsdlDefinitions();
+      QName portName = epMetaData.getQName();
+
+      boolean endpointFound = false;
+      for (WSDLService wsdlService : wsdlDefinitions.getServices())
+      {
+         for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints())
+         {
+            QName wsdlPortName = wsdlEndpoint.getQName();
+            if (wsdlPortName.equals(portName))
+            {
+               endpointFound = true;
+
+               String orgAddress = wsdlEndpoint.getAddress();
+               String uriScheme = getUriScheme(orgAddress);
+
+               String transportGuarantee = epMetaData.getTransportGuarantee();
+               if ("CONFIDENTIAL".equals(transportGuarantee))
+                  uriScheme = "https";
+
+               String servicePath = epMetaData.getContextRoot() + epMetaData.getURLPattern();
+               String serviceEndpointURL = getServiceEndpointAddress(uriScheme, servicePath);
+
+               ServiceEndpointManagerFactory factory = ServiceEndpointManagerFactory.getInstance();
+               ServiceEndpointManager epManager = factory.getServiceEndpointManager();
+               boolean alwaysModify = epManager.isAlwaysModifySOAPAddress();
+
+               if (alwaysModify || uriScheme == null || orgAddress.indexOf("REPLACE_WITH_ACTUAL_URL") >= 0)
+               {
+                  log.debug("Replace service endpoint address '" + orgAddress + "' with '" + serviceEndpointURL + "'");
+                  wsdlEndpoint.setAddress(serviceEndpointURL);
+                  epMetaData.setEndpointAddress(serviceEndpointURL);
+
+                  // modify the wsdl-1.1 definition
+                  if (wsdlDefinitions.getWsdlOneOneDefinition() != null)
+                     replaceWSDL11SOAPAddress(wsdlDefinitions, portName, serviceEndpointURL);
+               }
+               else
+               {
+                  log.debug("Don't replace service endpoint address '" + orgAddress + "'");
+                  try
+                  {
+                     epMetaData.setEndpointAddress(new URL(orgAddress).toExternalForm());
+                  }
+                  catch (MalformedURLException e)
+                  {
+                     throw new WSException("Malformed URL: " + orgAddress);
+                  }
+               }
+            }
+         }
+      }
+
+      if (endpointFound == false)
+         throw new WSException("Cannot find service endpoint '" + portName + "' in wsdl document");
+   }
+
+   private void replaceWSDL11SOAPAddress(WSDLDefinitions wsdlDefinitions, QName portQName, String serviceEndpointURL)
+   {
+      Definition wsdlOneOneDefinition = wsdlDefinitions.getWsdlOneOneDefinition();
+      String tnsURI = wsdlOneOneDefinition.getTargetNamespace();
+
+      // search for matching portElement and replace the address URI
+      Port wsdlOneOnePort = modifyPortAddress(tnsURI, portQName, serviceEndpointURL, wsdlOneOneDefinition.getServices());
+
+      // recursivly process imports if none can be found
+      if (wsdlOneOnePort == null && !wsdlOneOneDefinition.getImports().isEmpty())
+      {
+
+         Iterator imports = wsdlOneOneDefinition.getImports().values().iterator();
+         while (imports.hasNext())
+         {
+            List l = (List)imports.next();
+            Iterator importsByNS = l.iterator();
+            while (importsByNS.hasNext())
+            {
+               Import anImport = (Import)importsByNS.next();
+
+               wsdlOneOnePort = modifyPortAddress(anImport.getNamespaceURI(), portQName, serviceEndpointURL, anImport.getDefinition().getServices());
+            }
+         }
+      }
+
+      // if it still doesn't exist something is wrong
+      if (wsdlOneOnePort == null)
+         throw new IllegalArgumentException("Cannot find port with name '" + portQName + "' in wsdl document");
+   }
+
+   private Port modifyPortAddress(String tnsURI, QName portQName, String serviceEndpointURL, Map services)
+   {
+
+      Port wsdlOneOnePort = null;
+      Iterator itServices = services.values().iterator();
+      while (itServices.hasNext())
+      {
+         Service wsdlOneOneService = (Service)itServices.next();
+         Map wsdlOneOnePorts = wsdlOneOneService.getPorts();
+         Iterator itPorts = wsdlOneOnePorts.keySet().iterator();
+         while (itPorts.hasNext())
+         {
+            String portLocalName = (String)itPorts.next();
+            if (portQName.equals(new QName(tnsURI, portLocalName)))
+            {
+               wsdlOneOnePort = (Port)wsdlOneOnePorts.get(portLocalName);
+               Iterator itElements = wsdlOneOnePort.getExtensibilityElements().iterator();
+               while (itElements.hasNext())
+               {
+                  Object obj = itElements.next();
+                  if (obj instanceof SOAPAddress)
+                  {
+                     SOAPAddress address = (SOAPAddress)obj;
+                     address.setLocationURI(serviceEndpointURL);
+                  }
+               }
+            }
+         }
+      }
+
+      return wsdlOneOnePort;
+   }
+
+   private String getUriScheme(String addrStr)
+   {
+      try
+      {
+         URI addrURI = new URI(addrStr);
+         String scheme = addrURI.getScheme();
+         return scheme;
+      }
+      catch (URISyntaxException e)
+      {
+         return null;
+      }
+   }
+}


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -76,7 +76,7 @@
    {
       if (wsdlURL == null)
          throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);
-      
+
       log.debug("START buildMetaData: [service=" + serviceQName + "]");
       try
       {
@@ -137,7 +137,8 @@
       for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints())
       {
          QName portName = wsdlEndpoint.getQName();
-         ClientEndpointMetaData epMetaData = new ClientEndpointMetaData(serviceMetaData, portName, Type.JAXWS);
+         QName interfaceQName = wsdlEndpoint.getInterface().getQName();
+         ClientEndpointMetaData epMetaData = new ClientEndpointMetaData(serviceMetaData, portName, interfaceQName, Type.JAXWS);
          epMetaData.setEndpointAddress(wsdlEndpoint.getAddress());
          serviceMetaData.addEndpoint(epMetaData);
 

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -43,6 +43,6 @@
    protected void replaceAddressLocation(ServerEndpointMetaData epMetaData)
    {
       // FIXME: JBWS-1026
-      // Remove this method 
+      // Remove this method
    }
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -118,7 +118,7 @@
       WSDLUtils wsdlUtils = WSDLUtils.getInstance();
 
       String name = wsdlUtils.getJustClassName(wsClass);
-      
+
       String serviceName = anWebServiceProvider.serviceName();
       if (serviceName.length() == 0)
          serviceName = name + "Service";
@@ -136,7 +136,8 @@
 
       // Setup the ServerEndpointMetaData
       QName portQName = new QName(targetNS, portName);
-      ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portQName, Type.JAXWS);
+      QName portTypeQName = new QName(targetNS, name);
+      ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portQName, portTypeQName, Type.JAXWS);
       sepMetaData.setLinkName(linkName);
 
       sepMetaData.setStyle(Style.DOCUMENT);

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -171,7 +171,8 @@
       for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints())
       {
          QName portName = wsdlEndpoint.getQName();
-         ClientEndpointMetaData epMetaData = new ClientEndpointMetaData(serviceMetaData, portName, Type.JAXRPC);
+         QName interfaceQName = wsdlEndpoint.getInterface().getQName();
+         ClientEndpointMetaData epMetaData = new ClientEndpointMetaData(serviceMetaData, portName, interfaceQName, Type.JAXRPC);
          epMetaData.setEndpointAddress(wsdlEndpoint.getAddress());
          serviceMetaData.addEndpoint(epMetaData);
 

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -24,11 +24,11 @@
 //$Id$
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.jws.soap.SOAPBinding.ParameterStyle;
-import javax.wsdl.Message;
-import javax.wsdl.Part;
 import javax.xml.namespace.QName;
 import javax.xml.rpc.ParameterMode;
 import javax.xml.rpc.encoding.TypeMappingRegistry;
@@ -50,6 +50,7 @@
 import org.jboss.ws.metadata.ServiceMetaData;
 import org.jboss.ws.metadata.TypeMappingMetaData;
 import org.jboss.ws.metadata.TypesMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.jaxrpcmapping.ExceptionMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaXmlTypeMapping;
@@ -61,16 +62,22 @@
 import org.jboss.ws.metadata.jaxrpcmapping.WsdlReturnValueMapping;
 import org.jboss.ws.metadata.wsdl.WSDLBinding;
 import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
+import org.jboss.ws.metadata.wsdl.WSDLBindingOperationInput;
+import org.jboss.ws.metadata.wsdl.WSDLBindingOperationOutput;
 import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
 import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
 import org.jboss.ws.metadata.wsdl.WSDLInterface;
 import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
 import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput;
 import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
-import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationPart;
+import org.jboss.ws.metadata.wsdl.WSDLMIMEPart;
 import org.jboss.ws.metadata.wsdl.WSDLProperty;
+import org.jboss.ws.metadata.wsdl.WSDLRPCPart;
+import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem;
+import org.jboss.ws.metadata.wsdl.WSDLSOAPHeader;
 import org.jboss.ws.metadata.wsdl.WSDLTypes;
 import org.jboss.ws.metadata.wsdl.WSDLUtils;
+import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem.Direction;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
 import org.jboss.ws.utils.JavaUtils;
 import org.jboss.ws.xop.XOPScanner;
@@ -79,6 +86,7 @@
  * A meta data builder that is based on webservices.xml.
  *
  * @author Thomas.Diesler at jboss.org
+ * @authoer <a href="mailto:jason.greene at jboss.org">Jason T. Greene</a>
  * @since 19-Oct-2005
  */
 public abstract class JSR109MetaDataBuilder extends MetaDataBuilder
@@ -88,6 +96,13 @@
 
    private AddressingConstants ADDR = new AddressingConstantsImpl();
 
+   protected QName lookupSchemaType(WSDLInterfaceOperation operation, QName element)
+   {
+      WSDLDefinitions wsdlDefinitions = operation.getWsdlInterface().getWsdlDefinitions();
+      WSDLTypes wsdlTypes = wsdlDefinitions.getWsdlTypes();
+      return wsdlTypes.getXMLType(element);
+   }
+
    protected void setupTypesMetaData(ServiceMetaData serviceMetaData)
    {
       WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions();
@@ -198,187 +213,208 @@
       }
    }
 
-   private void buildParameterMetaDataRpc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping,
-         TypeMappingImpl typeMapping)
+   private ParameterMetaData buildInputParameter(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping, TypeMappingImpl typeMapping, String partName, QName xmlName, QName xmlType, int pos)
    {
-      log.trace("buildParameterMetaDataRpc: " + opMetaData.getQName());
+      WSDLRPCSignatureItem item = wsdlOperation.getRpcSignatureitem(partName);
+      if (item != null)
+         pos = item.getPosition();
 
-      TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
-
-      for (WSDLInterfaceOperationInput opInput : wsdlOperation.getInputs())
+      String javaTypeName = typeMapping.getJavaTypeName(xmlType);
+      if (seiMethodMapping != null)
       {
-         QName xmlName = opInput.getElement();
-         QName xmlType = opInput.getXMLType();
-         String partName = opInput.getProperty(Constants.WSDL_PROPERTY_PART_NAME).getValue();
-         String javaTypeName = typeMapping.getJavaTypeName(xmlType);
+         MethodParamPartsMapping paramMapping = seiMethodMapping.getMethodParamPartsMappingByPartName(partName);
+         if (paramMapping == null)
+            throw new WSException("Cannot obtain method parameter mapping for message part '" + partName + "' in wsdl operation: "
+                  + seiMethodMapping.getWsdlOperation());
 
-         if (seiMethodMapping != null)
-         {
-            MethodParamPartsMapping paramMapping = seiMethodMapping.getMethodParamPartsMappingByPartName(partName);
-            if (paramMapping == null)
-               throw new WSException("Cannot obtain method parameter mapping for message part '" + partName + "' in wsdl operation: "
-                     + seiMethodMapping.getWsdlOperation());
+         javaTypeName = paramMapping.getParamType();
+         pos = paramMapping.getParamPosition();
+      }
 
-            javaTypeName = paramMapping.getParamType();
-         }
-
-         JavaWsdlMapping javaWsdlMapping = opMetaData.getEndpointMetaData().getServiceMetaData().getJavaWsdlMapping();
-         if (javaTypeName == null && javaWsdlMapping != null)
+      JavaWsdlMapping javaWsdlMapping = opMetaData.getEndpointMetaData().getServiceMetaData().getJavaWsdlMapping();
+      if (javaTypeName == null && javaWsdlMapping != null)
+      {
+         String packageName = javaWsdlMapping.getPackageNameForNamespaceURI(xmlType.getNamespaceURI());
+         if (packageName != null)
          {
-            String packageName = javaWsdlMapping.getPackageNameForNamespaceURI(xmlType.getNamespaceURI());
-            if (packageName != null)
-            {
-               javaTypeName = packageName + "." + xmlType.getLocalPart();
-               log.warn("Guess java type from package mapping: [xmlType=" + xmlType + ",javaType=" + javaTypeName + "]");
-            }
+            javaTypeName = packageName + "." + xmlType.getLocalPart();
+            log.warn("Guess java type from package mapping: [xmlType=" + xmlType + ",javaType=" + javaTypeName + "]");
          }
+      }
 
-         if (javaTypeName == null)
-            throw new WSException("Cannot obtain java type mapping for: " + xmlType);
+      if (javaTypeName == null)
+         throw new WSException("Cannot obtain java type mapping for: " + xmlType);
 
-         ParameterMetaData inMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-         opMetaData.addParameter(inMetaData);
+      ParameterMetaData inMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
+      inMetaData.setIndex(pos);
+      opMetaData.addParameter(inMetaData);
 
-         // In arrays of user types, wscompile does not generate a mapping in jaxrpc-mapping.xml
-         if (typesMetaData.getTypeMappingByXMLType(xmlType) == null)
+      TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
+      // In arrays of user types, wscompile does not generate a mapping in jaxrpc-mapping.xml
+      if (typesMetaData.getTypeMappingByXMLType(xmlType) == null)
+      {
+         String nsURI = xmlType.getNamespaceURI();
+         if (Constants.NS_SCHEMA_XSD.equals(nsURI) == false && Constants.URI_SOAP11_ENC.equals(nsURI) == false)
          {
-            String nsURI = xmlType.getNamespaceURI();
-            if (Constants.NS_SCHEMA_XSD.equals(nsURI) == false && Constants.URI_SOAP11_ENC.equals(nsURI) == false)
-            {
-               TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, javaTypeName);
-               typesMetaData.addTypeMapping(tmMetaData);
-            }
+            TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, javaTypeName);
+            typesMetaData.addTypeMapping(tmMetaData);
          }
+      }
 
-         setupAttachmentParameter(opInput, inMetaData);
+      return inMetaData;
+   }
 
-         boolean inHeader = opInput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-         inMetaData.setInHeader(inHeader);
+   private ParameterMetaData buildOutputParameter(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping, int pos, String partName, QName xmlName, QName xmlType, TypeMappingImpl typeMapping)
+   {
+      // Default is first listed output
+      boolean hasReturnMapping = opMetaData.getReturnParameter() == null;
 
-         // SOAPENC:Array
-         setupSOAPArrayParameter(inMetaData, javaTypeName);
+      WSDLRPCSignatureItem item = wsdlOperation.getRpcSignatureitem(partName);
+      if (item != null)
+      {
+         hasReturnMapping = item.getDirection() == Direction.RETURN;
+         pos = item.getPosition();
       }
 
-      for (WSDLInterfaceOperationOutput opOutput : wsdlOperation.getOutputs())
+      String javaTypeName = typeMapping.getJavaTypeName(xmlType);
+      if (seiMethodMapping != null)
       {
-         String partName = opOutput.getProperty(Constants.WSDL_PROPERTY_PART_NAME).getValue();
-         QName xmlName = opOutput.getElement();
-
-         ParameterMetaData outMetaData = opMetaData.getParameter(xmlName);
-         if (outMetaData != null && wsdlOperation.getInputByPartName(partName) != null)
+         MethodParamPartsMapping paramMapping = seiMethodMapping.getMethodParamPartsMappingByPartName(partName);
+         if (paramMapping != null)
          {
-            outMetaData.setMode(ParameterMode.INOUT);
+            javaTypeName = paramMapping.getParamType();
+            pos = paramMapping.getParamPosition();
+            hasReturnMapping = false;
          }
          else
          {
-            QName xmlType = opOutput.getXMLType();
-            String javaTypeName = typeMapping.getJavaTypeName(xmlType);
-
-            boolean inHeader = opOutput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-            boolean hasReturnMapping = (inHeader == false);
-
-            if (seiMethodMapping != null)
+            WsdlReturnValueMapping returnMapping = seiMethodMapping.getWsdlReturnValueMapping();
+            String mappingPart = returnMapping.getWsdlMessagePartName();
+            if (returnMapping != null && mappingPart != null && partName.equals(mappingPart));
             {
-               WsdlReturnValueMapping returnMapping = seiMethodMapping.getWsdlReturnValueMapping();
-               if (returnMapping != null)
-               {
-                  javaTypeName = returnMapping.getMethodReturnValue();
-                  hasReturnMapping = true;
-               }
-               else
-               {
-                  MethodParamPartsMapping paramMapping = seiMethodMapping.getMethodParamPartsMappingByPartName(partName);
-                  if (paramMapping != null)
-                  {
-                     javaTypeName = paramMapping.getParamType();
-                     hasReturnMapping = false;
-                  }
-               }
+               javaTypeName = returnMapping.getMethodReturnValue();
+               hasReturnMapping = true;
             }
+         }
+      }
 
-            JavaWsdlMapping javaWsdlMapping = opMetaData.getEndpointMetaData().getServiceMetaData().getJavaWsdlMapping();
-            if (javaTypeName == null && javaWsdlMapping != null)
-            {
-               String packageName = javaWsdlMapping.getPackageNameForNamespaceURI(xmlType.getNamespaceURI());
-               if (packageName != null)
-               {
-                  javaTypeName = packageName + "." + xmlType.getLocalPart();
-                  log.warn("Guess java type from package mapping: [xmlType=" + xmlType + ",javaType=" + javaTypeName + "]");
-               }
-            }
+      JavaWsdlMapping javaWsdlMapping = opMetaData.getEndpointMetaData().getServiceMetaData().getJavaWsdlMapping();
+      if (javaTypeName == null && javaWsdlMapping != null)
+      {
+         String packageName = javaWsdlMapping.getPackageNameForNamespaceURI(xmlType.getNamespaceURI());
+         if (packageName != null)
+         {
+            javaTypeName = packageName + "." + xmlType.getLocalPart();
+            log.warn("Guess java type from package mapping: [xmlType=" + xmlType + ",javaType=" + javaTypeName + "]");
+         }
+      }
 
-            if (javaTypeName == null)
-               throw new WSException("Cannot obtain java type mapping for: " + xmlType);
+      if (javaTypeName == null)
+         throw new WSException("Cannot obtain java type mapping for: " + xmlType);
 
-            if (hasReturnMapping)
-            {
-               outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-               opMetaData.setReturnParameter(outMetaData);
+      ParameterMetaData outMetaData = new ParameterMetaData(opMetaData, new QName(partName), xmlType, javaTypeName);
+      outMetaData.setIndex(pos);
+      if (hasReturnMapping)
+      {
+         opMetaData.setReturnParameter(outMetaData);
+      }
+      else
+      {
+         outMetaData.setMode(ParameterMode.OUT);
+         opMetaData.addParameter(outMetaData);
+      }
 
-               // In arrays of user types, wscompile does not generate a mapping in jaxrpc-mapping.xml
-               if (typesMetaData.getTypeMappingByXMLType(xmlType) == null)
-               {
-                  String nsURI = xmlType.getNamespaceURI();
-                  if (Constants.NS_SCHEMA_XSD.equals(nsURI) == false && Constants.URI_SOAP11_ENC.equals(nsURI) == false)
-                  {
-                     TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, javaTypeName);
-                     typesMetaData.addTypeMapping(tmMetaData);
-                  }
-               }
+      TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
+      // In arrays of user types, wscompile does not generate a mapping in jaxrpc-mapping.xml
+      if (typesMetaData.getTypeMappingByXMLType(xmlType) == null)
+      {
+         String nsURI = xmlType.getNamespaceURI();
+         if (Constants.NS_SCHEMA_XSD.equals(nsURI) == false && Constants.URI_SOAP11_ENC.equals(nsURI) == false)
+         {
+            TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, javaTypeName);
+            typesMetaData.addTypeMapping(tmMetaData);
+         }
+      }
 
-               setupAttachmentParameter(opOutput, outMetaData);
-            }
-            else
-            {
-               outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-               outMetaData.setMode(ParameterMode.OUT);
-               opMetaData.addParameter(outMetaData);
+      return outMetaData;
+   }
 
-               setupAttachmentParameter(opOutput, outMetaData);
+   private int processBindingParameters(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping, TypeMappingImpl typeMapping, WSDLBindingOperation bindingOperation, int wsdlPosition)
+   {
+      WSDLBindingOperationInput bindingInput = bindingOperation.getInputs()[0];
+      for (WSDLSOAPHeader header : bindingInput.getSoapHeaders())
+      {
+         QName xmlName = header.getElement();
+         QName xmlType = lookupSchemaType(wsdlOperation, xmlName);
+         String partName = header.getPartName();
 
-               outMetaData.setInHeader(inHeader);
-            }
+         ParameterMetaData pmd = buildInputParameter(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, partName, xmlName, xmlType, wsdlPosition++);
+         pmd.setInHeader(true);
+      }
 
-            // SOAPENC:Array
-            setupSOAPArrayParameter(outMetaData, javaTypeName);
-         }
+      for (WSDLMIMEPart mimePart : bindingInput.getMimeParts())
+      {
+         String partName = mimePart.getPartName();
+         QName xmlName = new QName(partName);
+         QName xmlType = mimePart.getXmlType();
+
+         ParameterMetaData pmd = buildInputParameter(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, partName, xmlName, xmlType, wsdlPosition++);
+         pmd.setSwA(true);
+         pmd.setMimeTypes(mimePart.getMimeTypes());
       }
+
+      return wsdlPosition;
    }
 
-   private void setupAttachmentParameter(WSDLInterfaceOperationPart wsdlOperationPart, ParameterMetaData paramMetaData)
+   private int processBindingOutputParameters(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping, TypeMappingImpl typeMapping, WSDLBindingOperation bindingOperation, int wsdlPosition)
    {
-      QName xmlType = paramMetaData.getXmlType();
-      QName xmlName = paramMetaData.getXmlName();
+      WSDLBindingOperationOutput bindingOutput = bindingOperation.getOutputs()[0];
+      for (WSDLSOAPHeader header : bindingOutput.getSoapHeaders())
+      {
+         String partName = header.getPartName();
+         QName xmlName = header.getElement();
 
-      WSDLProperty mimeTypeProp = wsdlOperationPart.getProperty(Constants.WSDL_PROPERTY_WSDL11_MIME_TYPE);
-      if (mimeTypeProp != null)
-      {
-         String mimeTypes = mimeTypeProp.getValue();
-         paramMetaData.setMimeTypes(mimeTypes);
-         paramMetaData.setSwA(true);
+         ParameterMetaData outMetaData = opMetaData.getParameter(xmlName);
+         if (outMetaData != null)
+         {
+            outMetaData.setMode(ParameterMode.INOUT);
+         }
+         else
+         {
+            QName xmlType = lookupSchemaType(wsdlOperation, xmlName);
+
+            ParameterMetaData pmd = buildOutputParameter(opMetaData, wsdlOperation, seiMethodMapping, wsdlPosition, partName, xmlName, xmlType, typeMapping);
+            pmd.setInHeader(true);
+
+            if (opMetaData.getReturnParameter() != pmd)
+               wsdlPosition++;
+         }
       }
 
-      // An XOP parameter is detected if it is a complex type that derives from xsd:base64Binary
-      WSDLInterfaceOperation wsdlOperation = wsdlOperationPart.getWsdlOperation();
-      WSDLTypes wsdlTypes = wsdlOperation.getWsdlInterface().getWsdlDefinitions().getWsdlTypes();
-      JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlTypes);
-      XSTypeDefinition xsType = schemaModel.getTypeDefinition(xmlType.getLocalPart(), xmlType.getNamespaceURI());
-      XOPScanner scanner = new XOPScanner();
-      if(scanner.findXOPTypeDef(xsType)!=null)
+      for (WSDLMIMEPart mimePart : bindingOutput.getMimeParts())
       {
-         // FIXME: read the xmime:contentType from the element declaration
-         // See SchemaUtils#findXOPTypeDef(XSTypeDefinition typeDef) for details
+         String partName = mimePart.getPartName();
+         QName xmlName = new QName(partName);
 
-         /*
-         FIXME: the classloader is not set yet
-         paramMetaData.setXopContentType(
-             MimeUtils.resolveMimeType(paramMetaData.getJavaType())
-         );
-         */
+         ParameterMetaData outMetaData = opMetaData.getParameter(xmlName);
+         if (outMetaData != null)
+         {
+            outMetaData.setMode(ParameterMode.INOUT);
+         }
+         else
+         {
+            QName xmlType = mimePart.getXmlType();
 
-         paramMetaData.setXOP(true);
+            ParameterMetaData pmd = buildOutputParameter(opMetaData, wsdlOperation, seiMethodMapping, wsdlPosition, partName, xmlName, xmlType, typeMapping);
+            pmd.setSwA(true);
+            pmd.setMimeTypes(mimePart.getMimeTypes());
 
+            if (opMetaData.getReturnParameter() != pmd)
+               wsdlPosition++;
+         }
       }
+
+      return wsdlPosition;
    }
 
    /* SOAP-ENC:Array
@@ -386,7 +422,7 @@
     * FIXME: This hack should be removed as soon as we can reliably get the
     * soapenc:arrayType from wsdl + schema.
     */
-   private void setupSOAPArrayParameter(ParameterMetaData paramMetaData, String javaTypeName)
+   private void setupSOAPArrayParameter(ParameterMetaData paramMetaData)
    {
       Use use = paramMetaData.getOperationMetaData().getUse();
       String xmlTypeLocalPart = paramMetaData.getXmlType().getLocalPart();
@@ -395,6 +431,7 @@
          paramMetaData.setSOAPArrayParam(true);
          try
          {
+            String javaTypeName = paramMetaData.getJavaTypeName();
             // This approach determins the array component type from the javaTypeName.
             // It will not work for user defined types, nor will the array dimension be
             // initialized properly. Ideally the array parameter meta data should be initialized
@@ -415,211 +452,359 @@
       }
    }
 
-   private void buildParameterMetaDataDoc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping,
+   private void setupXOPAttachmentParameter(WSDLInterfaceOperation operation, ParameterMetaData paramMetaData)
+   {
+      QName xmlType = paramMetaData.getXmlType();
+
+      // An XOP parameter is detected if it is a complex type that derives from xsd:base64Binary
+      WSDLTypes wsdlTypes = operation.getWsdlInterface().getWsdlDefinitions().getWsdlTypes();
+      JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlTypes);
+      XSTypeDefinition xsType = schemaModel.getTypeDefinition(xmlType.getLocalPart(), xmlType.getNamespaceURI());
+      XOPScanner scanner = new XOPScanner();
+      if(scanner.findXOPTypeDef(xsType)!=null)
+      {
+         // FIXME: read the xmime:contentType from the element declaration
+         // See SchemaUtils#findXOPTypeDef(XSTypeDefinition typeDef) for details
+
+         /*
+         FIXME: the classloader is not set yet
+         paramMetaData.setXopContentType(
+             MimeUtils.resolveMimeType(paramMetaData.getJavaType())
+         );
+         */
+
+         paramMetaData.setXOP(true);
+
+      }
+   }
+
+   /*
+    * Perhaps the JAX-RPC mapping model should be hash based. For now we optimize just this case.
+    */
+   private Map<String, String> createVariableMappingMap(VariableMapping[] mappings)
+   {
+      HashMap<String, String> map = new HashMap<String, String>();
+      if (mappings != null)
+         for (VariableMapping mapping : mappings)
+            map.put(mapping.getXmlElementName(), mapping.getJavaVariableName());
+
+      return map;
+   }
+
+   private void buildParameterMetaDataRpc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping,
          TypeMappingImpl typeMapping)
    {
-      log.trace("buildParameterMetaDataDoc: " + opMetaData.getQName());
+      log.trace("buildParameterMetaDataRpc: " + opMetaData.getQName());
 
-      EndpointMetaData epMetaData = opMetaData.getEndpointMetaData();
-      ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData();
-      TypesMetaData typesMetaData = serviceMetaData.getTypesMetaData();
+      WSDLBindingOperation bindingOperation = wsdlOperation.getBindingOperation();
+      if (bindingOperation != null)
+         throw new WSException("Could not locate binding operation for:" + bindingOperation);
 
-      WSDLDefinitions wsdlDefinitions = wsdlOperation.getWsdlInterface().getWsdlDefinitions();
-      WSDLTypes wsdlTypes = wsdlDefinitions.getWsdlTypes();
-
-      for (WSDLInterfaceOperationInput opInput : wsdlOperation.getInputs())
+      // RPC has one input
+      WSDLInterfaceOperationInput input = wsdlOperation.getInputs()[0];
+      int wsdlPosition = 0;
+      for (WSDLRPCPart part : input.getChildParts())
       {
-         QName xmlName = opInput.getElement();
-         QName xmlType = opInput.getXMLType();
-         String javaTypeName = typeMapping.getJavaTypeName(xmlType);
+         QName xmlType = part.getType();
+         String partName = part.getName();
+         QName xmlName = new QName(partName);
 
-         TypeMappingMetaData typeMetaData = typesMetaData.getTypeMappingByXMLType(xmlType);
-         if (typeMetaData != null)
-            javaTypeName = typeMetaData.getJavaTypeName();
+         ParameterMetaData pmd = buildInputParameter(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, partName, xmlName, xmlType, wsdlPosition++);
 
-         if (javaTypeName == null)
-            throw new WSException("Cannot obtain java type mapping for: " + xmlType);
+         setupXOPAttachmentParameter(wsdlOperation, pmd);
+         setupSOAPArrayParameter(pmd);
+      }
 
-         // Check if we need to wrap the parameters
-         boolean isWrapParameters = (seiMethodMapping != null ? seiMethodMapping.isWrappedElement() : false);
-         log.trace("isWrapParameters based on wrapped-element: " + isWrapParameters);
-         if (isWrapParameters == false && seiMethodMapping != null)
+      wsdlPosition = processBindingParameters(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, bindingOperation, wsdlPosition);
+
+      WSDLInterfaceOperationOutput[] outputs = wsdlOperation.getOutputs();
+      if (outputs.length > 0)
+      {
+         WSDLInterfaceOperationOutput output = outputs[0];
+         for (WSDLRPCPart part : output.getChildParts())
          {
-            MethodParamPartsMapping[] partsMappings = seiMethodMapping.getMethodParamPartsMappings();
-            if (partsMappings.length > 0)
+            String partName = part.getName();
+
+            ParameterMetaData outMetaData = opMetaData.getParameter(new QName(partName));
+            if (outMetaData != null)
             {
-               boolean matchingPartFound = false;
-               for (MethodParamPartsMapping partsMapping : partsMappings)
-               {
-                  String paramTypeName = partsMapping.getParamType();
-                  if (paramTypeName.equals(javaTypeName))
-                  {
-                     matchingPartFound = true;
-                     break;
-                  }
-                  else
-                  {
-                     // Check assignability, JavaUtils.isAssignableFrom("org.w3c.dom.Element", "javax.xml.soap.SOAPElement")
-                     try
-                     {
-                        Class paramType = JavaUtils.loadJavaType(paramTypeName);
-                        Class javaType = JavaUtils.loadJavaType(javaTypeName);
+               outMetaData.setMode(ParameterMode.INOUT);
+            }
+            else
+            {
+               QName xmlName = new QName(partName);
+               QName xmlType = part.getType();
 
-                        // If it is assignable the explict mapping takes presedence and we don't wrap
-                        if (JavaUtils.isAssignableFrom(javaType, paramType))
-                        {
-                           javaTypeName = paramTypeName;
-                           matchingPartFound = true;
-                           break;
-                        }
-                     }
-                     catch (ClassNotFoundException e)
-                     {
-                        // Ignore. For simple types this should work, others should be lexically equal
-                        // if it is not wrapped.
-                     }
-                  }
-               }
-               isWrapParameters = (matchingPartFound == false);
-               log.trace("isWrapParameters based on matching parts: " + isWrapParameters);
+               ParameterMetaData pmd = buildOutputParameter(opMetaData, wsdlOperation, seiMethodMapping, wsdlPosition, partName, xmlName, xmlType, typeMapping);
+               if (opMetaData.getReturnParameter() != pmd)
+                  wsdlPosition++;
             }
          }
 
-         ParameterMetaData inMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-         setupAttachmentParameter(opInput, inMetaData);
-         epMetaData.setParameterStyle(isWrapParameters ? ParameterStyle.WRAPPED : ParameterStyle.BARE);
-         inMetaData.setInHeader(opInput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null);
-         opMetaData.addParameter(inMetaData);
+         processBindingOutputParameters(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, bindingOperation, wsdlPosition);
+      }
+      else if (wsdlOperation.getPattern() != Constants.WSDL20_PATTERN_IN_ONLY)
+      {
+         throw new WSException("RPC style was missing an output, and was not an IN-ONLY MEP.");
+      }
+   }
 
-         // Set the variable names
-         if (opMetaData.isDocumentWrapped())
+   private int processDocElement(WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping, ParameterMetaData inMetaData, List<WrappedParameter> wrappedParameters, List<WrappedParameter> wrappedResponseParameters)
+   {
+      QName xmlType = inMetaData.getXmlType();
+      int wsdlPosition;
+
+      // Set the variable names
+      if (inMetaData.getOperationMetaData().isDocumentWrapped())
+      {
+         if (seiMethodMapping == null)
+            throw new IllegalArgumentException("Cannot wrap parameters without SEI method mapping");
+
+         ServiceEndpointInterfaceMapping seiMapping = seiMethodMapping.getServiceEndpointInterfaceMapping();
+         JavaXmlTypeMapping javaXmlTypeMapping = seiMapping.getJavaWsdlMapping().getTypeMappingForQName(xmlType);
+         if (javaXmlTypeMapping == null)
+            throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
+
+
+         Map<String, String> variableMap = createVariableMappingMap(javaXmlTypeMapping.getVariableMappings());
+         for (MethodParamPartsMapping partMapping : seiMethodMapping.getMethodParamPartsMappings())
          {
-            if (seiMethodMapping == null)
-               throw new IllegalArgumentException("Cannot wrap parameters without SEI method mapping");
+            WsdlMessageMapping wsdlMessageMapping = partMapping.getWsdlMessageMapping();
+            if (wsdlMessageMapping != null)
+               throw new IllegalArgumentException("wsdl-message-message mapping required for document/literal wrapped");
 
-            ServiceEndpointInterfaceMapping seiMapping = seiMethodMapping.getServiceEndpointInterfaceMapping();
-            JavaXmlTypeMapping javaXmlTypeMapping = seiMapping.getJavaWsdlMapping().getTypeMappingForQName(xmlType);
-            if (javaXmlTypeMapping == null)
-               throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
+            String elementName = wsdlMessageMapping.getWsdlMessagePartName();
+            String variable = variableMap.get(wsdlMessageMapping.getWsdlMessagePartName());
+            if (variable == null)
+               throw new IllegalArgumentException("Could not determine variable name for element: " + elementName);
 
-            List<String> variableNames = new ArrayList<String>();
-            for (VariableMapping varMapping : javaXmlTypeMapping.getVariableMappings())
-            {
-               variableNames.add(varMapping.getJavaVariableName());
-            }
-            inMetaData.setWrappedVariables(variableNames);
+            WrappedParameter wrapped = new WrappedParameter(new QName(elementName), partMapping.getParamType(), variable,
+                  partMapping.getParamPosition());
+
+
+            String parameterMode = wsdlMessageMapping.getParameterMode();
+            if (parameterMode == null || parameterMode.length() < 2)
+               throw new IllegalArgumentException("Invalid parameter mode for element: " + elementName);
+
+            if (! "OUT".equals(parameterMode))
+               wrappedParameters.add(wrapped);
+            if (! "IN".equals(parameterMode));
+               wrappedResponseParameters.add(wrapped);
          }
+         inMetaData.setWrappedParameters(wrappedParameters);
+         wsdlPosition = wrappedParameters.size();
       }
+      else
+      {
+         setupXOPAttachmentParameter(wsdlOperation, inMetaData);
+         wsdlPosition = 1;
+      }
 
-      for (WSDLInterfaceOperationOutput opOutput : wsdlOperation.getOutputs())
+      return wsdlPosition;
+   }
+
+   private boolean isWrapped(ServiceEndpointMethodMapping seiMethodMapping, String javaTypeName)
+   {
+      boolean isWrapParameters = (seiMethodMapping != null ? seiMethodMapping.isWrappedElement() : false);
+      log.trace("isWrapParameters based on wrapped-element: " + isWrapParameters);
+      if (isWrapParameters == false && seiMethodMapping != null)
       {
-         String partName = opOutput.getProperty(Constants.WSDL_PROPERTY_PART_NAME).getValue();
-         QName xmlName = opOutput.getElement();
 
-         ParameterMetaData paramMetaData = opMetaData.getParameter(xmlName);
-         if (paramMetaData != null && wsdlOperation.getInputByPartName(partName) != null)
+         MethodParamPartsMapping[] partsMappings = seiMethodMapping.getMethodParamPartsMappings();
+         if (partsMappings.length > 0)
          {
-            paramMetaData.setMode(ParameterMode.INOUT);
-         }
-         else
-         {
-            QName xmlType = opOutput.getXMLType();
-            String javaTypeName = typeMapping.getJavaTypeName(xmlType);
-
-            boolean inHeader = opOutput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-            boolean hasReturnMapping = (inHeader == false);
-
-            if (typesMetaData.getTypeMappingByXMLType(xmlType) != null)
-               javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName();
-
-            if (javaTypeName == null)
-               throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
-
-            if (hasReturnMapping)
+            boolean matchingPartFound = false;
+            for (MethodParamPartsMapping partsMapping : partsMappings)
             {
-               if (seiMethodMapping != null)
+               String paramTypeName = partsMapping.getParamType();
+               if (paramTypeName.equals(javaTypeName))
                {
-                  WsdlReturnValueMapping returnValueMapping = seiMethodMapping.getWsdlReturnValueMapping();
-                  if ((returnValueMapping != null && returnValueMapping.getMethodReturnValue().equals(javaTypeName)) == false)
+                  matchingPartFound = true;
+                  break;
+               }
+               else
+               {
+                  // Check assignability,
+                  // JavaUtils.isAssignableFrom("org.w3c.dom.Element",
+                  // "javax.xml.soap.SOAPElement")
+                  try
                   {
-                     if (xmlType.equals(Constants.TYPE_LITERAL_ANYTYPE))
+                     Class paramType = JavaUtils.loadJavaType(paramTypeName);
+                     Class javaType = JavaUtils.loadJavaType(javaTypeName);
+
+                     // If it is assignable the explict mapping takes presedence
+                     // and we don't wrap
+                     if (JavaUtils.isAssignableFrom(javaType, paramType))
                      {
-                        javaTypeName = returnValueMapping.getMethodReturnValue();
+                        // javaTypeName = paramTypeName;
+                        matchingPartFound = true;
+                        break;
                      }
                   }
+                  catch (ClassNotFoundException e)
+                  {
+                     // Ignore. For simple types this should work, others should
+                     // be lexically equal
+                     // if it is not wrapped.
+                  }
                }
+            }
+            // Do we really want to continue to handle invalid mappings?
+            isWrapParameters = (matchingPartFound == false);
+            log.trace("isWrapParameters based on matching parts: " + isWrapParameters);
+         }
+      }
+      return isWrapParameters;
+   }
 
-               ParameterMetaData retMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-               opMetaData.setReturnParameter(retMetaData);
+   private int processOutputDocElement(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation,
+         ServiceEndpointMethodMapping seiMethodMapping, TypeMappingImpl typeMapping, List<WrappedParameter> wrappedParameters,
+         List<WrappedParameter> wrappedResponseParameters, int wsdlPosition)
+   {
+      WSDLInterfaceOperationOutput opOutput = wsdlOperation.getOutputs()[0];
+      QName xmlName = opOutput.getElement();
+      QName xmlType = opOutput.getXMLType();
 
-               setupAttachmentParameter(opOutput, retMetaData);
+      ParameterMetaData paramMetaData = opMetaData.getParameter(xmlName);
+      if (paramMetaData != null)
+      {
+         paramMetaData.setMode(ParameterMode.INOUT);
+         return wsdlPosition;
+      }
 
-               // Set the variable names
-               if (opMetaData.getParameterStyle() == ParameterStyle.WRAPPED)
-               {
-                  if (seiMethodMapping == null)
-                     throw new IllegalArgumentException("Cannot wrap parameters without SEI method mapping");
+      String javaTypeName = typeMapping.getJavaTypeName(xmlType);
 
-                  ServiceEndpointInterfaceMapping seiMapping = seiMethodMapping.getServiceEndpointInterfaceMapping();
-                  JavaWsdlMapping javaWsdlMapping = seiMapping.getJavaWsdlMapping();
-                  JavaXmlTypeMapping javaXmlTypeMapping = javaWsdlMapping.getTypeMappingForQName(xmlType);
-                  if (typeMapping == null)
-                     throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
+      TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
+      if (typesMetaData.getTypeMappingByXMLType(xmlType) != null)
+         javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName();
 
-                  List<String> variableNames = new ArrayList<String>();
-                  for (VariableMapping varMapping : javaXmlTypeMapping.getVariableMappings())
-                  {
-                     variableNames.add(varMapping.getJavaVariableName());
-                  }
-                  retMetaData.setWrappedVariables(variableNames);
-               }
-            }
-            else
-            {
-               ParameterMetaData outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-               opMetaData.addParameter(outMetaData);
-               outMetaData.setMode(ParameterMode.OUT);
+      if (javaTypeName == null)
+         throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
 
-               setupAttachmentParameter(opOutput, outMetaData);
+      ParameterMetaData outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
 
-               outMetaData.setInHeader(inHeader);
-            }
+      boolean hasReturnMapping = true;
+      if (opMetaData.isDocumentWrapped())
+      {
+         if (seiMethodMapping == null)
+            throw new IllegalArgumentException("Cannot wrap parameters without SEI method mapping");
+
+         WsdlReturnValueMapping returnValueMapping = seiMethodMapping.getWsdlReturnValueMapping();
+         if (returnValueMapping != null)
+         {
+            ServiceEndpointInterfaceMapping seiMapping = seiMethodMapping.getServiceEndpointInterfaceMapping();
+            JavaWsdlMapping javaWsdlMapping = seiMapping.getJavaWsdlMapping();
+            JavaXmlTypeMapping javaXmlTypeMapping = javaWsdlMapping.getTypeMappingForQName(xmlType);
+            if (typeMapping == null)
+               throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
+
+            Map<String, String> map = createVariableMappingMap(javaXmlTypeMapping.getVariableMappings());
+            String elementName = returnValueMapping.getWsdlMessagePartName();
+            String variable = map.get(elementName);
+            if (variable == null)
+               throw new IllegalArgumentException("Could not determine variable name for element: " + elementName);
+
+            String wrappedType = returnValueMapping.getMethodReturnValue();
+            QName element = new QName(elementName);
+            WrappedParameter wrappedParameter = new WrappedParameter(element, wrappedType, variable, WrappedParameter.RETURN);
+            wrappedResponseParameters.add(0, wrappedParameter);
          }
+
+         outMetaData.setWrappedParameters(wrappedParameters);
       }
-
-      // Add header parameters that are defined in jaxrpc-mapping but are not part of the wsdl message parts
-      // http://jira.jboss.org/jira/browse/JBWS-663
-      if (seiMethodMapping != null && wsdlDefinitions.getWsdlOneOneDefinition() != null)
+      else
       {
-         MethodParamPartsMapping[] mppMappings = seiMethodMapping.getMethodParamPartsMappings();
-         for (int i = 0; i < mppMappings.length; i++)
+         if (seiMethodMapping != null)
          {
-            MethodParamPartsMapping mppMapping = mppMappings[i];
-            String javaTypeName = mppMapping.getParamType();
-
-            WsdlMessageMapping wmMapping = mppMapping.getWsdlMessageMapping();
-            if (wmMapping.isSoapHeader())
+            MethodParamPartsMapping part = seiMethodMapping.getMethodParamPartsMappingByPartName(opOutput.getPartName());
+            if (part != null)
             {
-               QName wsdlMessageName = wmMapping.getWsdlMessage();
-               String partName = wmMapping.getWsdlMessagePartName();
-               Message wsdl11Message = wsdlDefinitions.getWsdlOneOneDefinition().getMessage(wsdlMessageName);
-               Part wsdl11Part = wsdl11Message.getPart(partName);
-               QName xmlName = wsdl11Part.getElementName();
-               if (opMetaData.getParameter(xmlName) == null)
+               hasReturnMapping = false;
+               outMetaData.setIndex(part.getParamPosition());
+            }
+            else
+            {
+               WsdlReturnValueMapping returnValueMapping = seiMethodMapping.getWsdlReturnValueMapping();
+               if (returnValueMapping != null)
                {
-                  String mode = wmMapping.getParameterMode();
-                  QName xmlType = wsdlTypes.getXMLType(xmlName);
-
-                  ParameterMetaData headerMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-                  opMetaData.addParameter(headerMetaData);
-                  headerMetaData.setInHeader(true);
-                  headerMetaData.setMode(mode);
+                  javaTypeName = returnValueMapping.getMethodReturnValue();
+                  outMetaData.setJavaTypeName(javaTypeName);
                }
             }
          }
+
+         setupXOPAttachmentParameter(wsdlOperation, outMetaData);
       }
+
+      if (hasReturnMapping)
+      {
+         opMetaData.setReturnParameter(outMetaData);
+      }
+      else
+      {
+         opMetaData.addParameter(outMetaData);
+         outMetaData.setMode(ParameterMode.OUT);
+         wsdlPosition++;
+      }
+
+      return wsdlPosition;
    }
 
+   private void buildParameterMetaDataDoc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping,
+         TypeMappingImpl typeMapping)
+   {
+      log.trace("buildParameterMetaDataDoc: " + opMetaData.getQName());
+
+      EndpointMetaData epMetaData = opMetaData.getEndpointMetaData();
+      ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData();
+      TypesMetaData typesMetaData = serviceMetaData.getTypesMetaData();
+
+      WSDLBindingOperation bindingOperation = wsdlOperation.getBindingOperation();
+      if (bindingOperation != null)
+         throw new WSException("Could not locate binding operation for:" + bindingOperation);
+
+      if (wsdlOperation.getInputs().length < 1)
+         throw new IllegalArgumentException("Input expected, none found");
+
+      WSDLInterfaceOperationInput opInput = wsdlOperation.getInputs()[0];
+      QName xmlName = opInput.getElement();
+      QName xmlType = opInput.getXMLType();
+      String javaTypeName = typeMapping.getJavaTypeName(xmlType);
+
+      TypeMappingMetaData typeMetaData = typesMetaData.getTypeMappingByXMLType(xmlType);
+      if (typeMetaData != null)
+         javaTypeName = typeMetaData.getJavaTypeName();
+
+      if (javaTypeName == null)
+         throw new WSException("Cannot obtain java type mapping for: " + xmlType);
+
+      // Check if we need to wrap the parameters
+
+      boolean isWrapped = isWrapped(seiMethodMapping, javaTypeName);
+      epMetaData.setParameterStyle(isWrapped ? ParameterStyle.WRAPPED : ParameterStyle.BARE);
+
+      ParameterMetaData inMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
+      opMetaData.addParameter(inMetaData);
+
+      List<WrappedParameter> wrappedParameters = new ArrayList<WrappedParameter>();
+      List<WrappedParameter> wrappedResponseParameters = new ArrayList<WrappedParameter>();
+
+      int wsdlPosition = processDocElement(wsdlOperation, seiMethodMapping, inMetaData, wrappedParameters, wrappedResponseParameters);
+
+      processBindingParameters(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, bindingOperation, wsdlPosition);
+
+      if (wsdlOperation.getOutputs().length > 0)
+      {
+         wsdlPosition = processOutputDocElement(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, wrappedParameters,
+               wrappedResponseParameters, wsdlPosition);
+         processBindingOutputParameters(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, bindingOperation, wsdlPosition);
+      }
+      else if (wsdlOperation.getPattern() != Constants.WSDL20_PATTERN_IN_ONLY)
+      {
+         throw new WSException("RPC style was missing an output, and was not an IN-ONLY MEP.");
+      }
+   }
+
    /**
     * Build default action according to the pattern described in
     * http://www.w3.org/Submission/2004/SUBM-ws-addressing-20040810/
@@ -650,5 +835,4 @@
 
       return actionValue;
    }
-
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -110,7 +110,7 @@
             {
                QName portName = pcMetaData.getWsdlPort();
 
-               // JBWS-722 
+               // JBWS-722
                // <wsdl-port> in webservices.xml should be qualified
                if (portName.getNamespaceURI().length() == 0)
                {
@@ -126,8 +126,9 @@
 
                // set service name
                serviceMetaData.setQName(wsdlEndpoint.getWsdlService().getQName());
+               QName interfaceQName = wsdlEndpoint.getInterface().getQName();
 
-               ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portName, Type.JAXRPC);
+               ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portName, interfaceQName, Type.JAXRPC);
                sepMetaData.setPortComponentName(pcMetaData.getPortComponentName());
                String ejbLink = pcMetaData.getEjbLink();
                String servletLink = pcMetaData.getServletLink();
@@ -186,7 +187,7 @@
 
                   String targetBean = webMetaData.getServletClassMap().get(servletLink);
                   sepMetaData.setServiceEndpointImplName(targetBean);
-                  
+
                   // Copy the wsdl publish location from jboss-web.xml
                   String wsdName = serviceMetaData.getWebserviceDescriptionName();
                   String wsdlPublishLocation = webMetaData.getWsdlPublishLocationByName(wsdName);
@@ -207,7 +208,7 @@
                // init service endpoint id
                ObjectName sepID = getServiceEndpointID(udi, sepMetaData);
                sepMetaData.setServiceEndpointID(sepID);
-               
+
                replaceAddressLocation(sepMetaData);
 
                String seiName = pcMetaData.getServiceEndpointInterface();

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -24,14 +24,18 @@
 // $Id$
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.Writer;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.rmi.RemoteException;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -45,13 +49,13 @@
 import javax.jws.soap.SOAPMessageHandlers;
 import javax.jws.soap.SOAPBinding.ParameterStyle;
 import javax.management.ObjectName;
+import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 import javax.xml.rpc.ParameterMode;
-import javax.xml.rpc.encoding.TypeMappingRegistry;
-import javax.xml.rpc.holders.Holder;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.RequestWrapper;
 import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.WebFault;
 import javax.xml.ws.addressing.AddressingProperties;
 
 import org.jboss.logging.Logger;
@@ -59,11 +63,10 @@
 import org.jboss.ws.WSException;
 import org.jboss.ws.addressing.AddressingPropertiesImpl;
 import org.jboss.ws.addressing.metadata.AddressingOpMetaExt;
-import org.jboss.ws.jaxrpc.ParameterWrapping;
 import org.jboss.ws.jaxrpc.Style;
-import org.jboss.ws.jaxrpc.TypeMappingImpl;
-import org.jboss.ws.jaxrpc.TypeMappingRegistryImpl;
 import org.jboss.ws.jaxrpc.Use;
+import org.jboss.ws.jaxws.DynamicWrapperGenerator;
+import org.jboss.ws.jaxws.WrapperGenerator;
 import org.jboss.ws.metadata.EndpointMetaData;
 import org.jboss.ws.metadata.FaultMetaData;
 import org.jboss.ws.metadata.OperationMetaData;
@@ -73,7 +76,7 @@
 import org.jboss.ws.metadata.TypeMappingMetaData;
 import org.jboss.ws.metadata.TypesMetaData;
 import org.jboss.ws.metadata.UnifiedMetaData;
-import org.jboss.ws.metadata.EndpointMetaData.Type;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.j2ee.UnifiedHandlerMetaData;
 import org.jboss.ws.metadata.jsr181.HandlerChainFactory;
 import org.jboss.ws.metadata.jsr181.HandlerChainMetaData;
@@ -81,12 +84,19 @@
 import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
 import org.jboss.ws.metadata.wsdl.WSDLUtils;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
-import org.jboss.ws.tools.ToolsUtils;
+import org.jboss.ws.server.ServerConfig;
+import org.jboss.ws.server.ServerConfigFactory;
+import org.jboss.ws.tools.jaxws.JAXBWSDLGenerator;
 import org.jboss.ws.utils.HolderUtils;
+import org.jboss.ws.utils.IOUtils;
+import org.jboss.ws.utils.JavaUtils;
 import org.jboss.xb.binding.ObjectModelFactory;
 import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
 
+import com.sun.xml.bind.api.JAXBRIContext;
+import com.sun.xml.bind.api.TypeReference;
+
 /** An abstract annotation meta data builder.
  *
  * @author Thomas.Diesler at jboss.org
@@ -96,20 +106,25 @@
 public abstract class JSR181MetaDataBuilder extends AnnotationsMetaDataBuilder
 {
    // provide logging
-   private final Logger log = Logger.getLogger(JSR181MetaDataBuilder.class);
+   private static final Logger log = Logger.getLogger(JSR181MetaDataBuilder.class);
 
+   private WrapperGenerator wrapperGenerator;
+   private List<Class> javaTypes = new ArrayList<Class>();
+   private List<TypeReference> typeRefs = new ArrayList<TypeReference>();
+   private JAXBRIContext jaxbCtx;
+
    public JSR181MetaDataBuilder()
    {
    }
 
-   protected ServerEndpointMetaData setupEndpointFromAnnotations(UnifiedMetaData wsMetaData, UnifiedDeploymentInfo udi, Class sepClass, String linkName)
+   protected ServerEndpointMetaData setupEndpointFromAnnotations(UnifiedMetaData wsMetaData, UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName)
          throws ClassNotFoundException
    {
       WebService anWebService = (WebService)sepClass.getAnnotation(WebService.class);
       if (anWebService == null)
          throw new WSException("Cannot obtain @WebService annotaion from: " + sepClass.getName());
 
-      Class seiClass = null;
+      Class<?> seiClass = null;
       String seiName = null;
       if (anWebService.endpointInterface().length() > 0)
       {
@@ -120,10 +135,12 @@
             throw new WSException("Interface does not have a @WebService annotation: " + seiName);
       }
 
-      Class wsClass = (seiClass != null ? seiClass : sepClass);
+      Class<?> wsClass = (seiClass != null ? seiClass : sepClass);
 
       WSDLUtils wsdlUtils = WSDLUtils.getInstance();
 
+      wrapperGenerator = new DynamicWrapperGenerator(udi.annotationsCl);
+
       String name = anWebService.name();
       if (name.length() == 0)
          name = wsdlUtils.getJustClassName(wsClass);
@@ -145,7 +162,8 @@
 
       // Setup the ServerEndpointMetaData
       QName portQName = new QName(targetNS, portName);
-      ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portQName, Type.JAXWS);
+      QName portTypeQName = new QName(targetNS, name);
+      ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portQName, portTypeQName, EndpointMetaData.Type.JAXWS);
       sepMetaData.setLinkName(linkName);
 
       sepMetaData.setServiceEndpointImplName(sepClass.getName());
@@ -174,6 +192,10 @@
       if (sepClass.isAnnotationPresent(SOAPMessageHandlers.class) || wsClass.isAnnotationPresent(SOAPMessageHandlers.class))
          log.warn("@SOAPMessageHandlers is deprecated as of JSR-181 2.0 with no replacement.");
 
+      // Build JAXB Context
+      createJAXBContext();
+      populateXmlTypes(sepMetaData);
+
       // Process or generate WSDL
       String wsdlLocation = anWebService.wsdlLocation();
       processOrGenerateWSDL(wsClass, serviceMetaData, wsdlLocation, sepMetaData);
@@ -193,6 +215,43 @@
       return sepMetaData;
    }
 
+   private void createJAXBContext()
+   {
+      try
+      {
+         jaxbCtx = JAXBRIContext.newInstance(javaTypes.toArray(new Class[0]), typeRefs, null, false);
+      }
+      catch (JAXBException ex)
+      {
+         throw new WSException("Could not create JAXB Context: e.getMessage()", ex);
+      }
+   }
+
+   private void populateXmlTypes(EndpointMetaData endpoint)
+   {
+      TypesMetaData types = endpoint.getServiceMetaData().getTypesMetaData();
+      for (OperationMetaData operation : endpoint.getOperations())
+      {
+         for (ParameterMetaData parameter : operation.getParameters())
+         {
+            try
+            {
+               QName xmlName = parameter.getXmlName();
+               QName xmlType = jaxbCtx.getTypeName(new TypeReference(xmlName, parameter.getJavaType()));
+               if (xmlType != null)
+               {
+                  parameter.setXmlType(xmlType);
+                  types.addTypeMapping(new TypeMappingMetaData(types, xmlType, parameter.getJavaTypeName()));
+               }
+            }
+            catch (Exception ex)
+            {
+               log.warn("Could not load type: " + parameter.getXmlName());
+            }
+         }
+      }
+   }
+
    protected void processSOAPBinding(EndpointMetaData epMetaData, Class wsClass)
    {
       SOAPBinding anSoapBinding = (SOAPBinding)wsClass.getAnnotation(SOAPBinding.class);
@@ -281,22 +340,12 @@
       opMetaData.setSOAPAction(soapAction);
       epMetaData.addOperation(opMetaData);
 
-      Map<String, Integer> typeIndexes = new HashMap<String, Integer>();
-
-      List<QName> wrappedElementNames = null;
-      List<String> wrappedVariables = null;
-      List<String> wrappedTypes = null;
-      ParameterMetaData wrappedParameter = null;
-
-      // Get the type mapping for the encoding style
-      String encStyle = opMetaData.getUse().toURI();
-      TypeMappingRegistry tmRegistry = new TypeMappingRegistryImpl();
-      TypeMappingImpl typeMapping = (TypeMappingImpl)tmRegistry.getTypeMapping(encStyle);
-
       // Build parameter meta data
-      QName xmlName = null;
-      QName xmlType = null;
       Class[] parameterTypes = method.getParameterTypes();
+      Type[] genericTypes = method.getGenericParameterTypes();
+      Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+      ParameterMetaData wrapperParameter = null, wrapperOutputParameter = null;
+      List<WrappedParameter> wrappedParameters = null, wrappedOutputParameters = null;
 
       // Force paramter style to wrapped
       if (method.isAnnotationPresent(RequestWrapper.class) || method.isAnnotationPresent(ResponseWrapper.class))
@@ -304,176 +353,202 @@
          epMetaData.setParameterStyle(null);
          epMetaData.setParameterStyle(ParameterStyle.WRAPPED);
       }
-      
+
       if (opMetaData.isDocumentWrapped())
       {
-         xmlName = opMetaData.getQName();
-         xmlType = opMetaData.getQName();
+         wrapperParameter = createRequestWrapper(opMetaData, method);
+         wrappedParameters = new ArrayList<WrappedParameter>(parameterTypes.length);
+         wrapperParameter.setWrappedParameters(wrappedParameters);
 
-         String requestWrapperType = null;
-         if (method.isAnnotationPresent(RequestWrapper.class))
-         {
-            RequestWrapper anReqWrapper = method.getAnnotation(RequestWrapper.class);
-
-            String localName = (anReqWrapper.localName().length() > 0 ? anReqWrapper.localName() : operationName);
-            String targetNamespace = (anReqWrapper.targetNamespace().length() > 0 ? anReqWrapper.targetNamespace() : epMetaData.getQName().getNamespaceURI());
-            xmlName = new QName(targetNamespace, localName);
-
-            if (anReqWrapper.className().length() > 0)
-            {
-               requestWrapperType = anReqWrapper.className();
-
-               TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, requestWrapperType);
-               typesMetaData.addTypeMapping(tmMetaData);
-            }
-         }
-
-         wrappedParameter = new ParameterMetaData(opMetaData, xmlName, xmlType, requestWrapperType);
-         wrappedElementNames = new ArrayList<QName>(parameterTypes.length);
-         wrappedVariables = new ArrayList<String>(parameterTypes.length);
-         wrappedTypes = new ArrayList<String>(parameterTypes.length);
-         wrappedParameter.setWrappedElementNames(wrappedElementNames);
-         wrappedParameter.setWrappedVariables(wrappedVariables);
-         wrappedParameter.setWrappedTypes(wrappedTypes);
-         opMetaData.addParameter(wrappedParameter);
-
-         // Generate temporary wrapper types so that tools can generate the correct wsdl
-         if (requestWrapperType == null)
-            ParameterWrapping.generateWrapper(wrappedParameter, false);
-
          if (!opMetaData.isOneWayOperation())
          {
-            xmlName = new QName(targetNS, operationName + "Response");
-            xmlType = new QName(targetNS, operationName + "Response");
-
-            String responseWrapperType = null;
-            if (method.isAnnotationPresent(ResponseWrapper.class))
-            {
-               ResponseWrapper anResWrapper = method.getAnnotation(ResponseWrapper.class);
-
-               String localName = (anResWrapper.localName().length() > 0 ? anResWrapper.localName() : operationName + "Response");
-               String targetNamespace = (anResWrapper.targetNamespace().length() > 0 ? anResWrapper.targetNamespace() : epMetaData.getQName().getNamespaceURI());
-               xmlName = new QName(targetNamespace, localName);
-
-               if (anResWrapper.className().length() > 0)
-               {
-                  responseWrapperType = anResWrapper.className();
-
-                  TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, responseWrapperType);
-                  typesMetaData.addTypeMapping(tmMetaData);
-               }
-            }
-
-            ParameterMetaData retMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, responseWrapperType);
-            retMetaData.setWrappedVariables(new ArrayList<String>(1));
-            retMetaData.setWrappedElementNames(new ArrayList<QName>(1));
-            retMetaData.setWrappedTypes(new ArrayList<String>(1));
-            opMetaData.setReturnParameter(retMetaData);
-
-            // Generate temporary wrapper types so that tools can generate the correct wsdl
-            if (responseWrapperType == null)
-               ParameterWrapping.generateWrapper(retMetaData, false);
+            wrapperOutputParameter = createResponseWrapper(opMetaData, method);
+            wrappedOutputParameters = new ArrayList<WrappedParameter>(parameterTypes.length + 1);
+            wrapperOutputParameter.setWrappedParameters(wrappedOutputParameters);
          }
       }
 
       for (int i = 0; i < parameterTypes.length; i++)
       {
          Class javaType = parameterTypes[i];
+         Type genericType = genericTypes[i];
          String javaTypeName = javaType.getName();
          WebParam anWebParam = getWebParamAnnotation(method, i);
-         boolean isWrapped = opMetaData.isDocumentWrapped() && (anWebParam == null || !anWebParam.header());
+         boolean isHeader = anWebParam != null && anWebParam.header();
+         boolean isWrapped = opMetaData.isDocumentWrapped() && !isHeader;
+         ParameterMode mode = getParameterMode(anWebParam, javaType);
 
-         if (Holder.class.isAssignableFrom(javaType))
+         // Assert one-way
+         if (opMetaData.isOneWayOperation() && mode != ParameterMode.IN)
+            throw new IllegalArgumentException("A one-way operation can not have output parameters [" + "method = "
+                  + method.getName() + ", parameter = " + i + "]");
+
+         // FIXME - Improve JAX-RPC and JAX-WS Holder unification
+         if (HolderUtils.isHolderType(javaType))
          {
             javaType = HolderUtils.getValueType(javaType);
+            genericType = HolderUtils.getGenericValueType(genericType);
             javaTypeName = javaType.getName();
          }
 
-         xmlType = typeMapping.getXMLType(javaType);
-         if (xmlType == null)
-            xmlType = getWebParamType(opMetaData, javaType);
-
          if (isWrapped)
          {
-            QName wrappedElementName = getWebParamName(opMetaData, typeIndexes, javaType, anWebParam);
-            wrappedElementNames.add(wrappedElementName);
-            String variable = wrappedElementName.getLocalPart();
-            if (variable.length() == 0)
-               throw new WSException("A web parameter had a name with 0 length");
+            QName wrappedElementName = getWebParamName(opMetaData, i, javaType, anWebParam);
+            String variable = convertToProperty(wrappedElementName.getLocalPart());
 
-            variable = convertToProperty(variable);
+            WrappedParameter wrappedParameter = new WrappedParameter(wrappedElementName, javaTypeName, variable, i);
+            wrappedParameter.typeArguments = convertTypeArguments(javaType, genericType);
 
-            wrappedVariables.add(variable);
-            wrappedTypes.add(javaTypeName);
+            if (mode != ParameterMode.OUT)
+               wrappedParameters.add(wrappedParameter);
+            if (mode != ParameterMode.IN)
+               wrappedOutputParameters.add(wrappedParameter);
          }
          else
          {
-            TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, javaTypeName);
-            typesMetaData.addTypeMapping(tmMetaData);
+            QName xmlName = getWebParamName(opMetaData, i, javaType, anWebParam);
 
-            xmlName = getWebParamName(opMetaData, typeIndexes, javaType, anWebParam);
-            xmlType = typeMapping.getXMLType(javaType);
-            if (xmlType == null)
-               xmlType = getWebParamType(opMetaData, javaType);
+            ParameterMetaData paramMetaData = new ParameterMetaData(opMetaData, xmlName, javaTypeName);
+            paramMetaData.setInHeader(isHeader);
+            paramMetaData.setIndex(i);
+            paramMetaData.setMode(mode);
 
-            ParameterMetaData paramMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-            if (anWebParam != null)
-            {
-               if (anWebParam.mode() == WebParam.Mode.INOUT)
-                  paramMetaData.setMode(ParameterMode.INOUT);
-               if (anWebParam.mode() == WebParam.Mode.OUT)
-                  paramMetaData.setMode(ParameterMode.OUT);
-
-               if (anWebParam.header())
-                  paramMetaData.setInHeader(true);
-            }
-
             opMetaData.addParameter(paramMetaData);
+            javaTypes.add(javaType);
+            typeRefs.add(new TypeReference(xmlName, genericType, parameterAnnotations[i]));
          }
       }
 
       // Build result meta data
       Class returnType = method.getReturnType();
+      Type genericReturnType = method.getGenericReturnType();
       String returnTypeName = returnType.getName();
       if ((returnType == void.class) == false)
       {
          if (opMetaData.isOneWayOperation())
             throw new IllegalArgumentException("[JSR-181 2.5.1] The method '" + method.getName() + "' can not have a return value if it is marked OneWay");
 
-         xmlType = typeMapping.getXMLType(returnType);
-         if (xmlType == null)
-            xmlType = getWebResultType(targetNS, returnType);
+         WebResult anWebResult = method.getAnnotation(WebResult.class);
+         boolean isHeader = anWebResult != null && anWebResult.header();
+         boolean isWrapped = opMetaData.isDocumentWrapped() && !isHeader;
+         QName xmlName = getWebResultName(opMetaData, returnType, anWebResult);
 
-         if (opMetaData.isDocumentWrapped())
+         if (isWrapped)
          {
-            QName elementName = getWebResultName(opMetaData, returnType, method.getAnnotation(WebResult.class));
+            WrappedParameter wrapped = new WrappedParameter(xmlName, convertToProperty(xmlName.getLocalPart()), returnTypeName, -1);
+            wrapped.typeArguments = convertTypeArguments(returnType, genericReturnType);
 
-            ParameterMetaData retMetaData = opMetaData.getReturnParameter();
-            retMetaData.getWrappedElementNames().add(elementName);
-            retMetaData.getWrappedVariables().add(convertToProperty(elementName.getLocalPart()));
-            retMetaData.getWrappedTypes().add(returnTypeName);
+            // insert at the beginning just for prettiness
+            wrappedOutputParameters.add(0, wrapped);
          }
          else
          {
-            TypeMappingMetaData tmMetaData = new TypeMappingMetaData(typesMetaData, xmlType, returnTypeName);
-            typesMetaData.addTypeMapping(tmMetaData);
+            ParameterMetaData retMetaData = new ParameterMetaData(opMetaData, xmlName, returnTypeName);
+            retMetaData.setInHeader(isHeader);
+            opMetaData.setReturnParameter(retMetaData);
 
-            xmlName = getWebResultName(opMetaData, returnType, method.getAnnotation(WebResult.class));
-            ParameterMetaData retMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, returnTypeName);
-            opMetaData.setReturnParameter(retMetaData);
+            javaTypes.add(returnType);
+            typeRefs.add(new TypeReference(xmlName, genericReturnType, method.getAnnotations()));
          }
       }
 
+      // Generate wrapper beans
+      if (opMetaData.isDocumentWrapped())
+      {
+         wrapperGenerator.generate(wrapperParameter);
+         Class wrapperClass = wrapperParameter.getJavaType();
+         javaTypes.add(wrapperClass);
+         typeRefs.add(new TypeReference(wrapperParameter.getXmlName(), wrapperClass));
+         if (!opMetaData.isOneWayOperation())
+         {
+            wrapperGenerator.generate(wrapperOutputParameter);
+            wrapperClass = wrapperOutputParameter.getJavaType();
+            javaTypes.add(wrapperParameter.getJavaType());
+            typeRefs.add(new TypeReference(wrapperOutputParameter.getXmlName(), wrapperClass));
+         }
+      }
+
+
       // Add faults
       for (Class exClass : method.getExceptionTypes())
          if (!RemoteException.class.isAssignableFrom(exClass))
-            addFault(opMetaData, typesMetaData, exClass);
+            addFault(opMetaData, exClass);
 
       // process op meta data extension
       processMetaExtensions(epMetaData, opMetaData);
+   }
 
+   private ParameterMode getParameterMode(WebParam anWebParam, Class javaType)
+   {
+      if (anWebParam != null)
+      {
+         if (anWebParam.mode() == WebParam.Mode.INOUT)
+            return ParameterMode.INOUT;
+         if (anWebParam.mode() == WebParam.Mode.OUT)
+            return ParameterMode.OUT;
+      }
+
+      return HolderUtils.isHolderType(javaType) ? ParameterMode.INOUT : ParameterMode.IN;
    }
 
+   private ParameterMetaData createResponseWrapper(OperationMetaData operation, Method method)
+   {
+      QName operationQName = operation.getQName();
+      QName xmlName = new QName(operationQName.getNamespaceURI(), operationQName.getLocalPart() + "Response");
+
+      String responseWrapperType = null;
+      if (method.isAnnotationPresent(ResponseWrapper.class))
+      {
+         ResponseWrapper anResWrapper = method.getAnnotation(ResponseWrapper.class);
+
+         String localName = anResWrapper.localName().length() > 0 ? anResWrapper.localName() : xmlName.getLocalPart();
+         String targetNamespace = anResWrapper.targetNamespace().length() > 0 ? anResWrapper.targetNamespace() : xmlName.getNamespaceURI();
+         xmlName = new QName(targetNamespace, localName);
+
+         if (anResWrapper.className().length() > 0)
+            responseWrapperType = anResWrapper.className();
+      }
+
+      if (responseWrapperType == null)
+         responseWrapperType = JavaUtils.capitalize(method.getName() + "Response");
+
+      ParameterMetaData retMetaData = new ParameterMetaData(operation, xmlName, operationQName, responseWrapperType);
+      operation.setReturnParameter(retMetaData);
+
+      wrapperGenerator.generate(retMetaData);
+      javaTypes.add(retMetaData.getJavaType());
+
+      return retMetaData;
+   }
+
+   private ParameterMetaData createRequestWrapper(OperationMetaData operation, Method method)
+   {
+      String requestWrapperType = null;
+      QName xmlName = operation.getQName();
+      if (method.isAnnotationPresent(RequestWrapper.class))
+      {
+         RequestWrapper anReqWrapper = method.getAnnotation(RequestWrapper.class);
+
+         String localName = anReqWrapper.localName().length() > 0 ? anReqWrapper.localName() : xmlName.getLocalPart();
+         String targetNamespace = anReqWrapper.targetNamespace().length() > 0 ? anReqWrapper.targetNamespace()
+               : xmlName.getNamespaceURI();
+         xmlName = new QName(targetNamespace, localName);
+
+         if (anReqWrapper.className().length() > 0)
+            requestWrapperType = anReqWrapper.className();
+      }
+
+      // Conformance 3.18, the default value must be the same as the method name
+      if (requestWrapperType == null)
+         requestWrapperType = JavaUtils.capitalize(method.getName());
+
+      // JAX-WS p.37 pg.1, the annotation only affects the element name, not the type name
+      ParameterMetaData wrapperParameter = new ParameterMetaData(operation, xmlName, operation.getQName(), requestWrapperType);
+      operation.addParameter(wrapperParameter);
+
+      return wrapperParameter;
+   }
+
    private String convertToProperty(String variable)
    {
       if (Character.isUpperCase(variable.charAt(0)))
@@ -567,7 +642,7 @@
       }
    }
 
-   private QName getWebParamName(OperationMetaData opMetaData, Map<String, Integer> typeIndexes, Class javaType, WebParam webParam)
+   private QName getWebParamName(OperationMetaData opMetaData, int index, Class javaType, WebParam webParam)
    {
       QName xmlName = null;
       String namespaceURI = opMetaData.getQName().getNamespaceURI();
@@ -588,27 +663,11 @@
          xmlName = new QName(namespaceURI, opMetaData.getQName().getLocalPart());
 
       if (xmlName == null)
-      {
-         WSDLUtils wsdlUtils = WSDLUtils.getInstance();
-         String shortName = wsdlUtils.getJustClassName(javaType);
-         Integer index = (Integer)typeIndexes.get(shortName);
-         index = (index != null ? new Integer(index.intValue() + 1) : new Integer(1));
-         typeIndexes.put(shortName, index);
+         xmlName = (opMetaData.isDocumentWrapped()) ? new QName(namespaceURI, "arg" + index) : new QName("arg" + index);
 
-         if (opMetaData.isDocumentWrapped())
-            xmlName = new QName(namespaceURI, shortName + "_" + index);
-         else xmlName = new QName(shortName + "_" + index);
-      }
-
       return xmlName;
    }
 
-   private QName getWebParamType(OperationMetaData opMetaData, Class javaType)
-   {
-      String namespaceURI = opMetaData.getQName().getNamespaceURI();
-      return ToolsUtils.getXMLType(javaType, namespaceURI);
-   }
-
    private QName getWebResultName(OperationMetaData opMetaData, Class javaType, WebResult anWebResult)
    {
       QName xmlName = null;
@@ -619,43 +678,114 @@
          if (anWebResult.targetNamespace().length() > 0)
             namespaceURI = anWebResult.targetNamespace();
 
-         // Unlike WebParam.name, the default of WebResult.name is "return", so this condition will always be met.
          if (anWebResult.name().length() > 0)
          {
-            if (opMetaData.getStyle() != Style.RPC)
+            if (opMetaData.getStyle() != Style.RPC || anWebResult.header())
                xmlName = new QName(namespaceURI, anWebResult.name());
-            else xmlName = new QName(anWebResult.name());
+            else
+               xmlName = new QName(anWebResult.name());
          }
       }
       if (xmlName == null && opMetaData.isDocumentBare())
          xmlName = new QName(namespaceURI, opMetaData.getResponseName().getLocalPart());
 
       if (xmlName == null)
-      {
-         xmlName = new QName(Constants.DEFAULT_RPC_RETURN_NAME);
-      }
+         xmlName = (opMetaData.isDocumentWrapped() ? new QName(namespaceURI, "return") : new QName("return"));
+
       return xmlName;
    }
 
-   private void addFault(OperationMetaData omd, TypesMetaData tmd, Class<?> exception)
+   private void addFault(OperationMetaData omd, Class<?> exception)
    {
       if (omd.isOneWayOperation())
          throw new IllegalStateException("JSR-181 4.3.1 - A JSR-181 processor is REQUIRED to report an error if an operation marked "
                + "@Oneway has a return value, declares any checked exceptions or has any INOUT or OUT parameters.");
 
-      String name = WSDLUtils.getInstance().getJustClassName(exception);
+      WebFault annotation = exception.getAnnotation(WebFault.class);
+
+      String name;
+      String namespace;
+      String faultBeanName = null;
+
+      /*
+       * If @WebFault is present, and the exception contains getFaultInfo, the
+       * return value should be used. Otherwise we need to generate the bean.
+       */
+      boolean generate = true;
+      if (annotation != null)
+      {
+         name = annotation.name();
+         namespace = annotation.targetNamespace();
+         if (namespace.length() == 0)
+            namespace = omd.getQName().getNamespaceURI();
+
+         Class<?> faultBean = getFaultInfo(exception);
+         if (faultBean != null)
+         {
+            generate = false;
+            faultBeanName = faultBean.getName();
+         }
+      }
+      else
+      {
+         name = exception.getSimpleName();
+         namespace = omd.getQName().getNamespaceURI();
+      }
+
+      if (faultBeanName == null)
+         faultBeanName = JavaUtils.getPackageName(omd.getEndpointMetaData().getServiceEndpointInterface())
+            + ".jaxws." + exception.getSimpleName() + "Bean";
+
       QName xmlName = new QName(omd.getQName().getNamespaceURI(), name);
 
-      FaultMetaData fmd = new FaultMetaData(omd, xmlName, xmlName, exception.getName());
+      FaultMetaData fmd = new FaultMetaData(omd, xmlName, exception.getName());
+      fmd.setFaultBeanName(faultBeanName);
+
+      if (generate)
+         wrapperGenerator.generate(fmd);
+
+      javaTypes.add(fmd.getFaultBean());
+      typeRefs.add(new TypeReference(fmd.getXmlName(), fmd.getFaultBean()));
+
       omd.addFault(fmd);
+   }
 
-      TypeMappingMetaData mapping = new TypeMappingMetaData(tmd, xmlName, exception.getName());
-      tmd.addTypeMapping(mapping);
+   private Class<?> getFaultInfo(Class<?> exception)
+   {
+      try
+      {
+         Method method = exception.getMethod("getFaultInfo");
+         Class<?> returnType = method.getReturnType();
+         if (returnType == void.class)
+            return null;
+
+         return returnType;
+      }
+      catch (SecurityException e)
+      {
+         throw new WSException("Unexpected security exception: " + e.getMessage(), e);
+      }
+      catch (NoSuchMethodException e)
+      {
+         return null;
+      }
    }
 
-   private QName getWebResultType(String defaultNS, Class javaType)
+   private String[] convertTypeArguments(Class rawType, Type type)
    {
-      return ToolsUtils.getXMLType(javaType, defaultNS);
+      if (!Collection.class.isAssignableFrom(rawType) && !Map.class.isAssignableFrom(rawType))
+         return null;
+
+      if (!(type instanceof ParameterizedType))
+         return null;
+
+      ParameterizedType paramType = (ParameterizedType) type;
+      Type[] arguments = paramType.getActualTypeArguments();
+      String[] ret = new String[arguments.length];
+      for (int i = 0; i < arguments.length; i++)
+         ret[i] = JavaUtils.erasure(arguments[i]).getName();
+
+      return ret;
    }
 
    /**
@@ -677,4 +807,48 @@
 
       opMetaData.addExtension(addrExt);
    }
+
+   protected void processOrGenerateWSDL(Class wsClass, ServiceMetaData serviceMetaData, String wsdlLocation, EndpointMetaData endpointMetaData)
+   {
+      if (wsdlLocation.length() > 0)
+      {
+         serviceMetaData.setWsdlFile(wsdlLocation);
+      }
+      else
+      {
+         try
+         {
+            UnifiedMetaData wsMetaData = serviceMetaData.getUnifiedMetaData();
+            String serviceName = serviceMetaData.getQName().getLocalPart();
+
+            JAXBWSDLGenerator generator = new JAXBWSDLGenerator();
+            WSDLDefinitions wsdlDefinitions = generator.generate(serviceMetaData, jaxbCtx);
+
+            ServerConfigFactory factory = ServerConfigFactory.getInstance();
+            ServerConfig config = factory.getServerConfig();
+            File tmpdir = new File(config.getServerTempDir().getCanonicalPath() + "/jbossws");
+            tmpdir.mkdirs();
+
+            File wsdlTmpFile = File.createTempFile(serviceName, ".wsdl", tmpdir);
+            wsdlTmpFile.deleteOnExit();
+
+            Writer writer = IOUtils.getCharsetFileWriter(wsdlTmpFile, Constants.DEFAULT_XML_CHARSET);
+            wsdlDefinitions.write(writer, Constants.DEFAULT_XML_CHARSET);
+            writer.close();
+
+            serviceMetaData.setWsdlFile(wsdlTmpFile.toURL().toExternalForm());
+         }
+         catch (RuntimeException rte)
+         {
+            throw rte;
+         }
+         catch (IOException e)
+         {
+            throw new WSException("Cannot write generated wsdl", e);
+         }
+      }
+   }
+
+
+
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -102,7 +102,7 @@
       this.resourceLoader = resourceLoader;
    }
 
-   /** Inititialize the endpoint binding 
+   /** Inititialize the endpoint binding
     */
    protected void initEndpointBinding(WSDLEndpoint wsdlEndpoint, ClientEndpointMetaData epMetaData)
    {
@@ -208,7 +208,7 @@
          QName ref = outFault.getRef();
 
          WSDLInterfaceFault wsdlFault = wsdlInterface.getFault(new NCName(ref.getLocalPart()));
-         QName xmlName = wsdlFault.getXmlName();
+         QName xmlName = wsdlFault.getElement();
          QName xmlType = wsdlFault.getXmlType();
          String javaTypeName = null;
 

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/TestMe.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/TestMe.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/TestMe.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,166 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ws.deployment;
+
+import java.awt.Image;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+
+import org.jboss.util.xml.DOMWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.sun.xml.bind.api.JAXBRIContext;
+import com.sun.xml.bind.api.TypeReference;
+
+
+public class TestMe
+{
+   public static class Foo
+   {
+      @XmlElement(name="fred")
+      public int bar1;
+
+      public int bar2;
+
+      public String[] test;
+
+      public Map<String, Integer> test2;
+
+      @XmlAttachmentRef
+      public Image testanother;
+
+      public void setTest2(Map<String, Integer> test2){}
+
+      public void test()
+      {
+
+      }
+   }
+
+   public static void main(String[] args) throws Exception
+   {
+      TypeReference typeReference = new TypeReference(new QName("http://blahblah", "DoesThisWork"), Image.class, new Annotation[] {Foo.class.getField("testanother").getAnnotation(XmlAttachmentRef.class)} );
+      List<TypeReference> list = new ArrayList<TypeReference>();
+      list.add(typeReference);
+
+      JAXBContext newInstance = JAXBRIContext.newInstance(new Class[] {Foo.class}, list, "http://blah", false);
+      //JAXBContext newInstance = JAXBContext.newInstance(new Class[]{Foo.class});
+      Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+      final Element element = doc.createElement("fake");
+
+
+      newInstance.generateSchema( new SchemaOutputResolver() {
+         public Result createOutput(String arg0, String arg1) throws IOException
+         {
+            System.err.println(arg0 + ":" + arg1);
+            System.err.println("hi");
+//            StreamResult streamResult = new StreamResult(new FilterOutputStream(System.out) {
+//               public void close() throws IOException
+//               {
+//               }
+//            });
+//            streamResult.setSystemId(arg0);
+
+            DOMResult result = new DOMResult(element);
+            result.setSystemId(arg0);
+            return result;
+         }
+      });
+
+      System.out.println(DOMWriter.printNode(element, true));
+
+
+/*
+      JAXBRIContext ctx = (JAXBRIContext) newInstance;
+      System.out.println(ctx.getTypeName(typeReference));
+      Marshaller m = ctx.createMarshaller();
+      */
+
+
+
+//      List<String> value = new ArrayList<String>();
+//      value.add("hi");
+//      m.marshal(new JAXBElement<List<String>>(new QName("test"), (Class<List<String>>)List.class, (Class)null, value), System.out);
+//      //m.marshal(, System.out);
+/*
+      ClassPool pool = new ClassPool();
+      pool.appendSystemPath();
+      CtClass clazz = pool.makeClass("FooMe");
+      CtField field = new CtField(pool.get("java.util.List"), "test", clazz);
+      field.setModifiers(Modifier.PUBLIC);
+
+      clazz.getClassFile().setVersionToJava5();
+      field.getFieldInfo().addAttribute(new SignatureAttribute(field.getFieldInfo().getConstPool(), "Ljava/util/List<Ljava/lang/String;>;;"));
+      clazz.addField(field);
+      Type genericType = clazz.toClass().getField("test").getGenericType();
+      //System.out.println(Foo.class.getField("test2").getGenericType());
+      System.out.println(((ParameterizedType) genericType).getActualTypeArguments()[0]);
+
+      System.out.println(((SignatureAttribute)pool.get(Foo.class.getName()).getField("test2").getFieldInfo().getAttribute("Signature")).getSignature());
+*/
+/*
+      ParameterMetaData pmd = new ParameterMetaData(null, new QName("hello"), new QName("helloType"), "blah.Gen123");
+      WrappedParameter wrapped = new WrappedParameter(new QName("item"), "java.util.Map", "item", 0);
+      wrapped.typeArguments = new String[] {"java.lang.Integer", "java.lang.String"};
+      ArrayList<WrappedParameter> list = new ArrayList<WrappedParameter>();
+      list.add(wrapped);
+      pmd.setWrappedParameters(list);
+
+
+      ClassLoader loader = Thread.currentThread().getContextClassLoader();
+      DynamicWrapperGenerator gen = new DynamicWrapperGenerator(loader);
+      gen.generate(pmd);
+
+
+      Class<?> loadClass = loader.loadClass("blah.Gen123");
+      Field field = loadClass.getDeclaredField("item");
+      System.out.println("name = " + field.getAnnotation(XmlElement.class).name());
+      for (Type t : (((ParameterizedType)field.getGenericType()).getActualTypeArguments()))
+      {
+         System.out.println(t);
+      }
+
+      Method method = loadClass.getDeclaredMethod("setItem", Map.class);
+      System.out.println(method.getGenericParameterTypes().length);
+      for (Type t : (((ParameterizedType)method.getGenericParameterTypes()[0]).getActualTypeArguments()))
+      {
+         System.out.println(t);
+      }
+   }
+   */
+
+
+   }
+}


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/deployment/TestMe.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/eventing/EventingEndpointBase.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/eventing/EventingEndpointBase.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/eventing/EventingEndpointBase.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -22,7 +22,7 @@
 package org.jboss.ws.eventing;
 
 
-// $Id: $ 
+// $Id$ 
 
 import java.net.URI;
 

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -23,10 +23,11 @@
 
 // $Id$
 
-import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Method;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javassist.ClassPool;
 import javassist.CtClass;
@@ -48,6 +49,8 @@
 import org.jboss.ws.metadata.ServiceMetaData;
 import org.jboss.ws.metadata.TypeMappingMetaData;
 import org.jboss.ws.metadata.TypesMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
+import org.jboss.ws.utils.HolderUtils;
 import org.jboss.ws.utils.JavaUtils;
 
 /** A helper class to wrap/unwrap ducument style request/response structures.
@@ -61,164 +64,73 @@
    // provide logging
    private static Logger log = Logger.getLogger(ParameterWrapping.class);
 
+   // This assertion should probably be moved somewhere earlier
    private static void assertOperationMetaData(OperationMetaData opMetaData)
    {
       if (opMetaData.getStyle() != Style.DOCUMENT)
          throw new WSException("Unexpected style: " + opMetaData.getStyle());
 
+      if (opMetaData.getNonHeaderParameters().size() != 1)
+         throw new WSException("Unexpected number of input parameters: " + opMetaData.getParameters().size());
+
+      if (opMetaData.getReturnParameter() == null && opMetaData.isOneWayOperation() == false)
+         throw new WSException("Unexpected null return parameter");
+
       if (opMetaData.getParameterStyle() != ParameterStyle.WRAPPED)
          throw new WSException("Unexpected parameter style: " + opMetaData.getParameterStyle());
    }
 
-   public static boolean matchRequestParameters(OperationMetaData opMetaData, Class[] paramTypes)
+   private static Object holderValue(Object holder)
    {
-      assertOperationMetaData(opMetaData);
+      if (! HolderUtils.isHolderType(holder.getClass()))
+         return holder;
 
-      // [JBWS-1125] Support empty soap body elements
-      if (opMetaData.getParameters().size() == 0)
-      {
-         log.debug("Detected document/literal/wrapped with no parameter part");
-         return true;
-      }
-      
-      ParameterMetaData paramMetaData = opMetaData.getParameters().get(0);
-      List<String> varNames = paramMetaData.getWrappedVariables();
-      Class reqStructType = paramMetaData.getJavaType();
+      return HolderUtils.getHolderValue(holder);
+   }
 
-      log.debug("matchRequestParameters: " + reqStructType.getName());
-      try
-      {
-         boolean pass = true;
-         for (int i = 0; pass && i < varNames.size(); i++)
-         {
-            String varName = varNames.get(i);
-            Method method = null;
-            try
-            {
-               PropertyDescriptor pd = new PropertyDescriptor(varName, reqStructType);
-               method = pd.getWriteMethod();
-            }
-            catch (IntrospectionException ex)
-            {
-               // jaxws-ri wsimport generates setter without the underscore
-               if (varName.indexOf("_") > 0)
-               {
-                  varName = varName.replace("_", "");
-                  PropertyDescriptor pd = new PropertyDescriptor(varName, reqStructType);
-                  method = pd.getWriteMethod();
-               }
-            }
+   private static Object holder(Object value, Class<?> target)
+   {
+      if (! HolderUtils.isHolderType(target))
+         return value;
 
-            if (method == null)
-               throw new NoSuchMethodError("No write method for: " + varName);
+      Object holder = HolderUtils.getHolderInstance(target);
+      HolderUtils.setHolderValue(holder, value);
 
-            Class methodType = method.getParameterTypes()[0];
-            Class paramType = paramTypes[i];
-            pass = JavaUtils.isAssignableFrom(methodType, paramType);
-         }
-         return pass;
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         log.debug("Invalid request wrapper: " + ex);
-         return false;
-      }
+      return holder;
    }
 
-   public static boolean matchResponseParameters(OperationMetaData opMetaData, Class returnType)
+   public static Class getWrappedType(String variable, Class wrapperType)
    {
-      assertOperationMetaData(opMetaData);
-
-      // [JBWS-1125] Support empty soap body elements
-      if (opMetaData.getReturnParameter() == null)
-      {
-         log.debug("Detected document/literal/wrapped with no return part");
-         return true;
-      }
-      
-      ParameterMetaData paramMetaData = opMetaData.getReturnParameter();
-      Class resStructType = paramMetaData.getJavaType();
-
-      log.debug("matchResponseParameters: " + resStructType.getName());
       try
       {
-         boolean pass = (returnType == void.class);
-         if (pass == false)
-         {
-            try
-            {
-               resStructType.getConstructor(new Class[] { returnType });
-               pass = true;
-            }
-            catch (NoSuchMethodException ex)
-            {
-               // jaxws-ri wsimport does not generate a ctor with return param type
-               resStructType.getMethod("setResult", returnType);
-               pass = true;
-            }
-         }
-         return pass;
+         PropertyDescriptor pd = new PropertyDescriptor(variable, wrapperType);
+         Method method = pd.getWriteMethod();
+         return method.getParameterTypes()[0];
       }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
       catch (Exception ex)
       {
-         log.debug("Invalid response wrapper: " + ex);
-         return false;
+         log.debug("Invalid request wrapper: " + ex);
+         return null;
       }
    }
 
-   public static Object wrapRequestParameters(OperationMetaData opMetaData, Object[] inParams)
+   public static Object wrapRequestParameters(ParameterMetaData request, Object[] methodParams)
    {
-      assertOperationMetaData(opMetaData);
+      assertOperationMetaData(request.getOperationMetaData());
 
-      // [JBWS-1125] Support empty soap body elements
-      if (opMetaData.getParameters().size() == 0)
-      {
-         log.debug("Detected document/literal/wrapped with no parameter part");
-         return null;
-      }
-      
-      ParameterMetaData paramMetaData = opMetaData.getParameters().get(0);
-      List<String> varNames = paramMetaData.getWrappedVariables();
-      Class reqStructType = paramMetaData.getJavaType();
-
+      Class reqStructType = request.getJavaType();
       log.debug("wrapRequestParameters: " + reqStructType.getName());
+      List<WrappedParameter> wrappedParameters = request.getWrappedParameters();
       try
       {
          Object reqStruct = reqStructType.newInstance();
-         for (int i = 0; i < varNames.size(); i++)
+         for (WrappedParameter param : wrappedParameters)
          {
-            String varName = varNames.get(i);
-            Method method = null;
-            try
-            {
-               PropertyDescriptor pd = new PropertyDescriptor(varName, reqStructType);
-               method = pd.getWriteMethod();
-            }
-            catch (IntrospectionException ex)
-            {
-               // jaxws-ri wsimport generates setter without the underscore
-               if (varName.indexOf("_") > 0)
-               {
-                  varName = varName.replace("_", "");
-                  PropertyDescriptor pd = new PropertyDescriptor(varName, reqStructType);
-                  method = pd.getWriteMethod();
-               }
-            }
-
-            if (method == null)
-               throw new NoSuchMethodError("No write method for: " + varName);
-
-            Object value = inParams[i];
+            PropertyDescriptor pd = new PropertyDescriptor(param.variable, reqStructType);
+            Method method = pd.getWriteMethod();
+            Object value = holderValue(methodParams[param.index]);
             log.debug(" " + method.getName() + ": " + (value != null ? value.getClass().getName() : null));
-            method.invoke(reqStruct, new Object[] { value });
+            method.invoke(reqStruct, value);
          }
 
          return reqStruct;
@@ -233,47 +145,39 @@
       }
    }
 
-   public static Object[] unwrapRequestParameters(OperationMetaData opMetaData, Object reqStruct)
+   public static Map<Integer, Object> unwrapRequestParameters(ParameterMetaData request, Object reqStruct, Object[] methodParams)
    {
+      OperationMetaData opMetaData = request.getOperationMetaData();
       assertOperationMetaData(opMetaData);
 
       if (reqStruct == null)
          throw new IllegalArgumentException("Request struct cannot be null");
 
-      ParameterMetaData paramMetaData = opMetaData.getParameters().get(0);
-      List<String> varNames = paramMetaData.getWrappedVariables();
+      Class[] targetParameterTypes = opMetaData.getJavaMethod().getParameterTypes();
+      Map<Integer, Object> outParameters = new HashMap<Integer, Object>(targetParameterTypes.length);
+      List<WrappedParameter> wrappedParameters = request.getWrappedParameters();
       Class reqStructType = reqStruct.getClass();
 
       log.debug("unwrapRequestParameters: " + reqStructType.getName());
-      Object[] inParams = new Object[varNames.size()];
       try
       {
-         for (int i = 0; i < varNames.size(); i++)
+         for (ParameterMetaData.WrappedParameter param : wrappedParameters)
          {
-            String varName = varNames.get(i);
-            Method method = null;
-            try
+            PropertyDescriptor pd = new PropertyDescriptor(param.variable, reqStructType);
+            Method method = pd.getReadMethod();
+            Class targetType = targetParameterTypes[param.index];
+
+            Object value = method.invoke(reqStruct);
+
+            // INOUT Parameter
+            if (HolderUtils.isHolderType(targetType))
             {
-               PropertyDescriptor pd = new PropertyDescriptor(varName, reqStructType);
-               method = pd.getReadMethod();
+               value = holder(value, targetType);
+               outParameters.put(param.index, value);
             }
-            catch (IntrospectionException ex)
-            {
-               // jaxws-ri wsimport generates getter without the underscore
-               if (varName.indexOf("_") > 0)
-               {
-                  varName = varName.replace("_", "");
-                  PropertyDescriptor pd = new PropertyDescriptor(varName, reqStructType);
-                  method = pd.getReadMethod();
-               }
-            }
 
-            if (method == null)
-               throw new NoSuchMethodError("No read method for: " + varName);
-
-            Object value = method.invoke(reqStruct, new Object[] {});
             log.debug(" " + method.getName() + ": " + (value != null ? value.getClass().getName() : null));
-            inParams[i] = value;
+            methodParams[param.index] = value;
          }
       }
       catch (RuntimeException rte)
@@ -285,60 +189,33 @@
          throw new IllegalArgumentException("Cannot unwrap request structure: " + e);
       }
 
-      return inParams;
+      return outParameters;
    }
 
-   public static Object wrapResponseParameter(OperationMetaData opMetaData, Object outParam)
+   public static Object wrapResponseParameters(ParameterMetaData returnMetaData, Object returnValue, Map<Integer, Object> outParameters)
    {
-      assertOperationMetaData(opMetaData);
+      assertOperationMetaData(returnMetaData.getOperationMetaData());
 
-      // [JBWS-1125] Support empty soap body elements
-      if (opMetaData.getReturnParameter() == null)
+      Class resStructType = returnMetaData.getJavaType();
+      if (returnValue != null && returnValue.getClass() == resStructType)
       {
-         log.debug("Detected document/literal/wrapped with no return part");
-         return null;
-      }
-      
-      ParameterMetaData paramMetaData = opMetaData.getReturnParameter();
-      List<String> varNames = paramMetaData.getWrappedVariables();
-      Class resStructType = paramMetaData.getJavaType();
-
-      if (outParam != null && outParam.getClass() == resStructType)
-      {
          log.debug("Response parameter already wrapped" + resStructType.getName());
-         return outParam;
+         return returnValue;
       }
 
       log.debug("wrapResponseParameter: " + resStructType.getName());
+      List<ParameterMetaData.WrappedParameter> wrappedParameters = returnMetaData.getWrappedParameters();
       try
       {
          Object resStruct = resStructType.newInstance();
-         if (varNames.size() > 0)
-         {
-            String varName = varNames.get(0);
-            Method method = null;
-            try
-            {
-               PropertyDescriptor pd = new PropertyDescriptor(varName, resStructType);
-               method = pd.getWriteMethod();
-            }
-            catch (IntrospectionException ex)
-            {
-               // jaxws-ri wsimport generates setter without the underscore
-               if (varName.indexOf("_") > 0)
-               {
-                  varName = varName.replace("_", "");
-                  PropertyDescriptor pd = new PropertyDescriptor(varName, resStructType);
-                  method = pd.getWriteMethod();
-               }
-            }
 
-            if (method == null)
-               throw new NoSuchMethodError("No write method for: " + varName);
-
-            Object value = outParam;
+         for (ParameterMetaData.WrappedParameter param : wrappedParameters)
+         {
+            PropertyDescriptor pd = new PropertyDescriptor(param.variable, resStructType);
+            Method method = pd.getWriteMethod();
+            Object value = (param.index < 0) ? returnValue : holderValue(outParameters.get(param.index));
             log.debug(" " + method.getName() + ": " + (value != null ? value.getClass().getName() : null));
-            method.invoke(resStruct, new Object[] { value });
+            method.invoke(resStruct, value);
          }
          return resStruct;
       }
@@ -352,46 +229,31 @@
       }
    }
 
-   public static Object unwrapResponseParameter(OperationMetaData opMetaData, Object resStruct)
+   public static Object unwrapResponseParameters(ParameterMetaData retMetaData, Object resStruct, Object methodParams[])
    {
-      assertOperationMetaData(opMetaData);
+      OperationMetaData operationMetaData = retMetaData.getOperationMetaData();
+      assertOperationMetaData(operationMetaData);
 
       Object retValue = null;
       if (resStruct != null)
       {
-         ParameterMetaData paramMetaData = opMetaData.getReturnParameter();
-         List<String> varNames = paramMetaData.getWrappedVariables();
          Class resStructType = resStruct.getClass();
 
          log.debug("unwrapResponseParameter: " + resStructType.getName());
+         List<WrappedParameter> wrappedParameters = retMetaData.getWrappedParameters();
+         Class[] targetTypes = operationMetaData.getJavaMethod().getParameterTypes();
          try
          {
-            if (varNames.size() > 0)
+            for (WrappedParameter param : wrappedParameters)
             {
-               String varName = varNames.get(0);
-               Method method = null;
-               try
-               {
-                  PropertyDescriptor pd = new PropertyDescriptor(varName, resStructType);
-                  method = pd.getReadMethod();
-               }
-               catch (IntrospectionException ex)
-               {
-                  // jaxws-ri wsimport generates getter without the underscore
-                  if (varName.indexOf("_") > 0)
-                  {
-                     varName = varName.replace("_", "");
-                     PropertyDescriptor pd = new PropertyDescriptor(varName, resStructType);
-                     method = pd.getReadMethod();
-                  }
-               }
-
-               if (method == null)
-                  throw new NoSuchMethodError("No read method for: " + varName);
-
+               PropertyDescriptor pd = new PropertyDescriptor(param.variable, resStructType);
+               Method method = pd.getReadMethod();
                Object value = method.invoke(resStruct, new Object[] {});
                log.debug(" " + method.getName() + ": " + (value != null ? value.getClass().getName() : null));
-               retValue = value;
+               if (param.index < 0)
+                  retValue = value;
+               else
+                  methodParams[param.index] = holder(value, targetTypes[param.index]);
             }
          }
          catch (RuntimeException rte)
@@ -426,8 +288,7 @@
     */
    public static void generateWrapper(ParameterMetaData pmd, boolean addTypeMapping)
    {
-      List<String> wrappedTypes = pmd.getWrappedTypes();
-      List<String> wrappedVariables = pmd.getWrappedVariables();
+      List<WrappedParameter> wrappedParameters = pmd.getWrappedParameters();
       OperationMetaData operationMetaData = pmd.getOperationMetaData();
       EndpointMetaData endpointMetaData = operationMetaData.getEndpointMetaData();
       ServiceMetaData serviceMetaData = endpointMetaData.getServiceMetaData();
@@ -436,8 +297,8 @@
       if (operationMetaData.isDocumentWrapped() == false)
          throw new WSException("Operation is not document/literal (wrapped)");
 
-      if (wrappedTypes == null)
-         throw new WSException("Cannot generate a type when their is no type information");
+      if (wrappedParameters == null)
+         throw new WSException("Cannot generate a type when their is no wrapped parameters");
 
       String serviceName = serviceMetaData.getQName().getLocalPart();
       String parameterName = pmd.getXmlName().getLocalPart();
@@ -456,16 +317,13 @@
          CtClass clazz = pool.makeClass(wrapperName);
          clazz.setSuperclass(pool.get(WrapperType.class.getName()));
 
-         for (int i = 0; i < wrappedTypes.size(); i++)
+         for (WrappedParameter param : wrappedParameters)
          {
-            String typeName = wrappedTypes.get(i);
-            String name = wrappedVariables.get(i);
-
-            CtField field = new CtField(pool.get(typeName), name, clazz);
+            CtField field = new CtField(pool.get(param.type), param.variable, clazz);
             field.setModifiers(Modifier.PRIVATE);
             clazz.addField(field);
-            clazz.addMethod(CtNewMethod.getter("get" + capitalize(name), field));
-            clazz.addMethod(CtNewMethod.setter("set" + capitalize(name), field));
+            clazz.addMethod(CtNewMethod.getter("get" + JavaUtils.capitalize(param.variable), field));
+            clazz.addMethod(CtNewMethod.setter("set" + JavaUtils.capitalize(param.variable), field));
          }
 
          wrapperType = (Class)pool.toClass(clazz, loader);
@@ -490,17 +348,4 @@
 
       pmd.setJavaTypeName(wrapperName);
    }
-
-   private static String capitalize(String source)
-   {
-      if (source == null)
-         return null;
-
-      if (source.length() == 0)
-         return source;
-
-      char c = Character.toUpperCase(source.charAt(0));
-
-      return c + source.substring(1);
-   }
 }
\ No newline at end of file

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,226 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.jaxws;
+
+import java.util.List;
+import java.util.SortedMap;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.LoaderClassPath;
+import javassist.Modifier;
+import javassist.NotFoundException;
+import javassist.bytecode.ConstPool;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.metadata.ParameterMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
+import org.jboss.ws.utils.JavaUtils;
+import org.jboss.ws.utils.JavassistUtils;
+
+public class DynamicWrapperGenerator extends WrapperGenerator
+{
+   private static Logger log = Logger.getLogger(DynamicWrapperGenerator.class);
+
+   private ClassPool pool;
+
+   public DynamicWrapperGenerator(ClassLoader loader)
+   {
+      super(loader);
+      pool = new ClassPool(true);
+      pool.appendClassPath(new LoaderClassPath(loader));
+   }
+
+   /**
+    * Generates a wrapper type and assigns it to the passed ParameterMetaData
+    * object. This routine requires the pmd to contain completed wrappedTypes
+    * and wrappedVariables properties of the passed ParameterMetaData object.
+    *
+    * @param pmd a document/literal wrapped parameter
+    */
+   public void generate(ParameterMetaData pmd)
+   {
+      // If a wrapper already present, no need to generate one
+      String wrapperName = pmd.getJavaTypeName();
+      if (JavaUtils.isLoaded(wrapperName, loader))
+         return;
+
+      List<WrappedParameter> wrappedParameters = pmd.getWrappedParameters();
+      OperationMetaData operationMetaData = pmd.getOperationMetaData();
+
+      if (operationMetaData.isDocumentWrapped() == false)
+         throw new WSException("Operation is not document/literal (wrapped)");
+
+      if (wrappedParameters == null)
+         throw new WSException("Cannot generate a type when their is no wrapper parameters");
+
+      if (log.isDebugEnabled())
+         log.debug("Generating wrapper: " + wrapperName);
+
+      try
+      {
+         CtClass clazz = pool.makeClass(wrapperName);
+         clazz.getClassFile().setVersionToJava5();
+         addClassAnnotations(clazz, pmd.getXmlName(), pmd.getXmlType(), null);
+
+         for (WrappedParameter parameter : wrappedParameters)
+         {
+            addProperty(clazz, parameter.type, parameter.name, parameter.variable, parameter.typeArguments);
+         }
+         pool.toClass(clazz, loader);
+      }
+      catch (Exception e)
+      {
+         throw new WSException("Could not generate wrapper type: " + wrapperName, e);
+      }
+   }
+
+   public void generate(FaultMetaData fmd)
+   {
+      String faultBeanName = fmd.getFaultBeanName();
+      if (JavaUtils.isLoaded(faultBeanName, loader))
+         return;
+
+      Class exception = fmd.getJavaType();
+
+      try
+      {
+         SortedMap<String, Class<?>> properties = getExceptionProperties(exception);
+         String[] propertyOrder = properties.keySet().toArray(new String[0]);
+
+         CtClass clazz = pool.makeClass(faultBeanName);
+         clazz.getClassFile().setVersionToJava5();
+         addClassAnnotations(clazz, fmd.getXmlName(), fmd.getXmlType(), propertyOrder);
+
+         for (String property : propertyOrder)
+            addProperty(clazz, properties.get(property).getName(), new QName(property), property, null);
+
+         pool.toClass(clazz, loader);
+      }
+      catch (Exception e)
+      {
+         throw new WSException("Could not generate wrapper type: " + faultBeanName, e);
+      }
+   }
+
+   private static String getterPrefix(CtClass type)
+   {
+      return type == CtClass.booleanType || "java.lang.Boolean".equals(type.getName()) ? "is" : "get";
+   }
+
+   private String typeSignature(String type, String[] arguments)
+   {
+      StringBuilder ret = new StringBuilder(JavaUtils.toSignature(type));
+      ret.deleteCharAt(ret.length() - 1).append('<');
+
+      for (String arg : arguments)
+         ret.append(JavaUtils.toSignature(arg));
+
+      return ret.append(">;").toString();
+   }
+
+   private String getterSignature(String type)
+   {
+      return "()" + type;
+   }
+
+   private String setterSignature(String type)
+   {
+      return "(" + type + ")V";
+   }
+
+   private void addProperty(CtClass clazz, String typeName, QName name, String variable, String[] typeArguments)
+         throws CannotCompileException, NotFoundException
+   {
+      ConstPool constPool = clazz.getClassFile().getConstPool();
+      String fieldName = JavaUtils.isReservedKeyword(variable) ?  "_" + variable : variable;
+      CtField field = new CtField(pool.get(typeName), fieldName, clazz);
+      field.setModifiers(Modifier.PRIVATE);
+
+      // Add generics attributes
+      String typeSignature = null;
+      if (typeArguments != null)
+      {
+         typeSignature = typeSignature(typeName, typeArguments);
+         JavassistUtils.addSignature(field, typeSignature);
+      }
+
+      // Add @XmlElement
+      JavassistUtils.Annotation annotation = JavassistUtils.createAnnotation(XmlElement.class, constPool);
+      if (name.getNamespaceURI() != null)
+         annotation.addParameter("namespace", name.getNamespaceURI());
+      annotation.addParameter("name", name.getLocalPart());
+      annotation.markField(field);
+      clazz.addField(field);
+
+      // Add accessor methods
+      CtMethod getter = CtNewMethod.getter(getterPrefix(field.getType()) + JavaUtils.capitalize(variable), field);
+      CtMethod setter = CtNewMethod.setter("set" + JavaUtils.capitalize(variable), field);
+      if (typeSignature != null)
+      {
+         JavassistUtils.addSignature(getter, getterSignature(typeSignature));
+         JavassistUtils.addSignature(setter, setterSignature(typeSignature));
+      }
+      clazz.addMethod(getter);
+      clazz.addMethod(setter);
+   }
+
+   private static void addClassAnnotations(CtClass clazz, QName xmlName, QName xmlType, String[] propertyOrder)
+   {
+      ConstPool constPool = clazz.getClassFile().getConstPool();
+
+      // Add @XmlRootElement
+      JavassistUtils.Annotation annotation = JavassistUtils.createAnnotation(XmlRootElement.class, constPool);
+      if (xmlName.getNamespaceURI() != null && xmlName.getNamespaceURI().length() > 0)
+         annotation.addParameter("namespace", xmlName.getNamespaceURI());
+      annotation.addParameter("name", xmlName.getLocalPart());
+      annotation.markClass(clazz);
+
+      // Add @XmlType;
+      annotation = JavassistUtils.createAnnotation(XmlType.class, constPool);
+      if (xmlType.getNamespaceURI() != null & xmlType.getNamespaceURI().length() > 0)
+         annotation.addParameter("namespace", xmlType.getNamespaceURI());
+      annotation.addParameter("name", xmlType.getLocalPart());
+      if (propertyOrder != null)
+         annotation.addParameter("propOrder", propertyOrder);
+      annotation.markClass(clazz);
+
+      // Add @XmlAccessorType
+      annotation = JavassistUtils.createAnnotation(XmlAccessorType.class, constPool);
+      annotation.addParameter("value",  XmlAccessType.FIELD);
+      annotation.markClass(clazz);
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,99 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ws.jaxws;
+
+import java.beans.Introspector;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.ParameterMetaData;
+
+
+/**
+ * Base class for JAX-WS wrapper generation.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public abstract class WrapperGenerator
+{
+   private static Set<String> excludedGetters;
+   protected ClassLoader loader;
+
+   public WrapperGenerator(ClassLoader loader)
+   {
+      this.loader = loader;
+   }
+
+   static
+   {
+      excludedGetters = new HashSet<String>(4);
+      excludedGetters.add("getCause");
+      excludedGetters.add("getClass");
+      excludedGetters.add("getLocalizedMessage");
+      excludedGetters.add("getStackTrace");
+   }
+
+   protected SortedMap<String, Class<?>> getExceptionProperties(Class<?> exception)
+   {
+      if (! Exception.class.isAssignableFrom(exception))
+         throw new IllegalArgumentException("Not an exception");
+
+      TreeMap<String, Class<?>> sortedGetters = new TreeMap<String, Class<?>>();
+
+      for (Method method : exception.getMethods())
+      {
+         if (java.lang.reflect.Modifier.isStatic(method.getModifiers()))
+            continue;
+
+         Class<?> returnType = method.getReturnType();
+         if (returnType == void.class)
+            continue;
+
+         String name = method.getName();
+         if (excludedGetters.contains(name))
+            continue;
+
+         int offset;
+         if (name.startsWith("get"))
+            offset = 3;
+         else if (name.startsWith("is"))
+            offset = 2;
+         else
+            continue;
+
+         name = Introspector.decapitalize(name.substring(offset));
+         sortedGetters.put(name, returnType);
+      }
+
+      return sortedGetters;
+   }
+
+
+
+   public abstract void generate(ParameterMetaData pmd);
+   public abstract void generate(FaultMetaData fmd);
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/core/HTTPBindingImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/core/HTTPBindingImpl.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/core/HTTPBindingImpl.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -21,7 +21,7 @@
  */
 package org.jboss.ws.jaxws.core;
 
-// $Id: $
+// $Id$
 
 import java.util.Map;
 

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPBindingImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPBindingImpl.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPBindingImpl.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -83,8 +83,8 @@
 import org.w3c.dom.Element;
 
 /**
- * The SOAPBinding interface is an abstraction for the SOAP binding. 
- * 
+ * The SOAPBinding interface is an abstraction for the SOAP binding.
+ *
  * @author Thomas.Diesler at jboss.com
  * @since 04-Jul-2006
  */
@@ -92,10 +92,10 @@
 {
 	// provide logging
    private static Logger log = Logger.getLogger(SOAPBindingImpl.class);
-   
+
    private boolean mtomEnabled;
    private Set<URI> roles = new HashSet<URI>();
-   
+
    public MessageFactory getMessageFactory()
    {
       return new MessageFactoryImpl();
@@ -110,7 +110,7 @@
    {
       this.roles = roles;
    }
-   
+
    public SOAPFactory getSOAPFactory()
    {
       return new SOAPFactoryImpl();
@@ -128,7 +128,7 @@
 
    /** Create the SOAP-1.1 message */
    protected abstract SOAPMessage createMessage(OperationMetaData opMetaData) throws SOAPException;
-   
+
    /** On the client side, generate the payload from IN parameters. */
    public Object bindRequestMessage(OperationMetaData opMetaData, EndpointInvocation epInv, Map<QName, UnboundHeader> unboundHeaders) throws BindingException
    {
@@ -252,7 +252,7 @@
          SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
          SOAPHeader soapHeader = soapEnvelope.getHeader();
          SOAPBody soapBody = soapEnvelope.getBody();
-         
+
          // Verify the SOAP version
          verifySOAPVersion(opMetaData, soapEnvelope);
 
@@ -455,7 +455,7 @@
             {
                Object value = epInv.getReturnValue();
                if (opMetaData.isDocumentWrapped())
-                  value = ParameterWrapping.wrapResponseParameter(opMetaData, value);
+                  value = ParameterWrapping.wrapResponseParameters(retMetaData, value, epInv.getOutParameters());
 
                if (retMetaData.isSwA())
                {

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -59,10 +59,10 @@
 
 /**
  * Service delegates are used internally by Service objects to allow pluggability of JAX-WS implementations.
- * 
- * Every Service object has its own delegate, created using the javax.xml.ws.Provider#createServiceDelegate method. 
- * A Service object delegates all of its instance methods to its delegate. 
- *  
+ *
+ * Every Service object has its own delegate, created using the javax.xml.ws.Provider#createServiceDelegate method.
+ * A Service object delegates all of its instance methods to its delegate.
+ *
  * @author Thomas.Diesler at jboss.com
  * @since 03-May-2006
  */
@@ -90,7 +90,7 @@
       builder.setClassLoader(ctxClassLoader);
 
       serviceMetaData = builder.buildMetaData(serviceName, wsdlURL);
-      
+
       for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
       {
          QName portName = epMetaData.getQName();
@@ -101,8 +101,8 @@
       }
    }
 
-   /** 
-    * The getPort method returns a stub. A service client uses this stub to invoke operations on the target service endpoint. 
+   /**
+    * The getPort method returns a stub. A service client uses this stub to invoke operations on the target service endpoint.
     * The serviceEndpointInterface specifies the service endpoint interface that is supported by the created dynamic proxy or stub instance.
     */
    @Override
@@ -110,20 +110,20 @@
    {
       if (serviceMetaData == null)
          throw new WebServiceException("Service meta data not available");
-      
+
       EndpointMetaData epMetaData = serviceMetaData.getEndpoint(portName);
       if (epMetaData == null)
          throw new WebServiceException("Cannot get port meta data for: " + portName);
-      
+
       String seiClassName = seiClass.getName();
       epMetaData.setServiceEndpointInterfaceName(seiClassName);
-      
+
       return getPortInternal(epMetaData, seiClass);
    }
 
    @Override
    /**
-    * The getPort method returns a stub. A service client uses this stub to invoke operations on the target service endpoint. 
+    * The getPort method returns a stub. A service client uses this stub to invoke operations on the target service endpoint.
     * The serviceEndpointInterface specifies the service endpoint interface that is supported by the created dynamic proxy or stub instance.
     */
    public <T> T getPort(Class<T> seiClass)
@@ -136,7 +136,7 @@
 
       String seiClassName = seiClass.getName();
       EndpointMetaData epMetaData = serviceMetaData.getEndpointByServiceEndpointInterface(seiClassName);
-      
+
       if (epMetaData == null && serviceMetaData.getEndpoints().size() == 1)
       {
          epMetaData = serviceMetaData.getEndpoints().get(0);
@@ -145,7 +145,7 @@
 
       if (epMetaData == null)
          throw new WebServiceException("Cannot get port meta data for: " + seiClassName);
-      
+
       return getPortInternal(epMetaData, seiClass);
    }
 
@@ -166,9 +166,9 @@
    }
 
    @Override
-   /** 
-    * Creates a new port for the service. 
-    * Ports created in this way contain no WSDL port type information 
+   /**
+    * Creates a new port for the service.
+    * Ports created in this way contain no WSDL port type information
     * and can only be used for creating Dispatchinstances.
     */
 
@@ -199,12 +199,12 @@
       Port port = ports.get(portName);
       if (port == null)
          throw new WebServiceException("Cannot find port: " + portName);
-      
+
       // Create an anonymous endpoint
       EndpointMetaData epMetaData = serviceMetaData.getEndpoint(portName);
       if (epMetaData == null)
       {
-         epMetaData = new ClientEndpointMetaData(serviceMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousPort"), Type.JAXWS);
+         epMetaData = new ClientEndpointMetaData(serviceMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousPort"), new QName(Constants.NS_JBOSSWS_URI, "Anonymous"), Type.JAXWS);
          epMetaData.setEndpointAddress(port.getEndpointAddress());
          epMetaData.setBindingId(port.getBindingId());
       }
@@ -273,7 +273,7 @@
             impl.initHandlerChain(epMetaData, HandlerType.ENDPOINT);
             impl.initHandlerChain(epMetaData, HandlerType.POST);
          }
-         
+
          PortProxy handler = new PortProxy(new ClientImpl(epMetaData, handlerResolver));
          ClassLoader cl = epMetaData.getClassLoader();
          T proxy = (T)Proxy.newProxyInstance(cl, new Class[] { seiClass, BindingProvider.class }, handler);
@@ -288,13 +288,13 @@
          throw new WebServiceException("Cannot create proxy", ex);
       }
    }
-   
+
    private static class Port
    {
       private QName qname;
       private String bindingId;
       private String endpointAddress;
-      
+
       public Port(QName qname, String bindingId, String endpointAddress)
       {
          this.qname = qname;

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -56,9 +56,9 @@
    // The REWQUIRED client config
    private Object clientConfig;
 
-   public ClientEndpointMetaData(ServiceMetaData service, QName portName, Type type)
+   public ClientEndpointMetaData(ServiceMetaData service, QName qname, QName interfaceQName, Type type)
    {
-      super(service, portName, type);
+      super(service, qname, interfaceQName, type);
    }
 
    public void setConfigName(String configName)

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -74,6 +74,8 @@
    private QName portName;
    // The REQUIRED binding id
    private String bindingId;
+   // The REQUIRED name of the WSDL interface/portType
+   private QName interfaceQName;
    // The REQUIRED config-name
    private String configName;
    // The REQUIRED config-file
@@ -105,10 +107,11 @@
    // True if the handlers are initialized
    private boolean handlersInitialized;
 
-   public EndpointMetaData(ServiceMetaData service, QName portName, Type type)
+   public EndpointMetaData(ServiceMetaData service, QName qname, QName interfaceQName, Type type)
    {
       this.service = service;
-      this.portName = portName;
+      this.portName = qname;
+      this.interfaceQName = interfaceQName;
       this.type = type;
 
       // The default binding
@@ -125,6 +128,11 @@
       return portName;
    }
 
+   public QName getInterfaceQName()
+   {
+      return interfaceQName;
+   }
+
    public String getConfigFile()
    {
       return configFile;

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -44,20 +44,25 @@
    private QName xmlName;
    private QName xmlType;
    private String javaTypeName;
+   private String faultBeanName;
    private Class javaType;
+   private Class faultBean;
 
    public FaultMetaData(OperationMetaData operation, QName xmlName, QName xmlType, String javaTypeName)
    {
+      this(operation, xmlName, javaTypeName);
+      setXmlType(xmlType);
+   }
+
+   public FaultMetaData(OperationMetaData operation, QName xmlName, String javaTypeName)
+   {
       if (xmlName == null)
          throw new IllegalArgumentException("Invalid null xmlName argument");
-      if (xmlType == null)
-         throw new IllegalArgumentException("Invalid null xmlType argument, for: " + xmlName);
       if (javaTypeName == null)
          throw new IllegalArgumentException("Invalid null javaTypeName argument, for: " + xmlName);
 
       this.operation = operation;
       this.xmlName = xmlName;
-      this.xmlType = xmlType;
       this.javaTypeName = javaTypeName;
    }
 
@@ -76,6 +81,14 @@
       return xmlType;
    }
 
+   public void setXmlType(QName xmlType)
+   {
+      if (xmlType == null)
+         throw new IllegalArgumentException("Invalid null xmlType argument, for: " + xmlName);
+
+      this.xmlType = xmlType;
+   }
+
    public String getJavaTypeName()
    {
       return javaTypeName;
@@ -106,10 +119,42 @@
       return javaType;
    }
 
+   public Class getFaultBean()
+   {
+      if (faultBean == null && faultBeanName != null)
+      {
+         ClassLoader loader = operation.getEndpointMetaData().getServiceMetaData().getUnifiedMetaData().getClassLoader();
+         if (loader == null)
+            throw new WSException("ClassLoader not available");
+
+         try
+         {
+            faultBean = JavaUtils.loadJavaType(faultBeanName);
+         }
+         catch (ClassNotFoundException ex)
+         {
+            throw new WSException("Cannot load java type: " + javaTypeName, ex);
+         }
+      }
+
+      return faultBean;
+   }
+
+   public String getFaultBeanName()
+   {
+      return faultBeanName;
+   }
+
+   public void setFaultBeanName(String faultBeanName)
+   {
+      this.faultBeanName = faultBeanName;
+   }
+
    public void eagerInitialize()
    {
       // Initialize the cache
       getJavaType();
+      getFaultBean();
    }
 
    public String toString()
@@ -118,6 +163,7 @@
       buffer.append("\n xmlName=" + xmlName);
       buffer.append("\n xmlType=" + xmlType);
       buffer.append("\n javaType=" + javaTypeName);
+      buffer.append("\n faultbean=" + faultBeanName);
       return buffer.toString();
    }
 }
\ No newline at end of file

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -25,7 +25,9 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import javax.jws.soap.SOAPBinding.ParameterStyle;
 import javax.xml.namespace.QName;
@@ -73,7 +75,7 @@
    {
       UnifiedMetaData umd = new UnifiedMetaData();
       ServiceMetaData smd = new ServiceMetaData(umd, new QName("mock-service"));
-      ServerEndpointMetaData epmd = new ServerEndpointMetaData(smd, new QName("mock-endpoint"), Type.JAXRPC);
+      ServerEndpointMetaData epmd = new ServerEndpointMetaData(smd, new QName("mock-endpoint"), new QName("mock-interface"), Type.JAXRPC);
       initOperationMetaData(epmd, qname, javaName);
    }
 
@@ -176,59 +178,25 @@
             for (Method method : seiClass.getMethods())
             {
                String methodName = method.getName();
-               Class[] methodTypes = method.getParameterTypes();
-               Class returnType = method.getReturnType();
 
                if (javaName.equals(methodName))
                {
                   log.trace("Found java method: " + method);
 
-                  // match document/literal/wrapped
-                  if (isDocumentWrapped())
+                  // compare params by java type name
+                  if (matchParameters(method, true))
                   {
-                     if (ParameterWrapping.matchRequestParameters(this, methodTypes) && ParameterWrapping.matchResponseParameters(this, returnType))
-                     {
-                        log.debug("Found wrapped java method: " + method);
-                        javaMethod = method;
-                        break;
-                     }
+                     log.debug("Found best matching java method: " + method);
+                     javaMethod = method;
+                     break;
                   }
-                  else
-                  {
-                     // Match the return parameter
-                     ParameterMetaData returnMetaData = getReturnParameter();
-                     if (returnMetaData != null)
-                     {
-                        if (!matchParameter(returnMetaData, returnType, true) && !matchParameter(returnMetaData, returnType, false))
-                        {
-                           log.debug("Unmatched return meta data: " + returnType);
-                           continue;
-                        }
-                     }
-                     else
-                     {
-                        if (returnType != void.class)
-                        {
-                           log.debug("Unmatched return meta data: " + returnType);
-                           continue;
-                        }
-                     }
 
-                     // compare params by java type name
-                     if (compareMethodParams(methodTypes, true))
-                     {
-                        log.debug("Found best matching java method: " + method);
-                        javaMethod = method;
-                        break;
-                     }
-
-                     // compare params by assignability
-                     else if (compareMethodParams(methodTypes, false))
-                     {
-                        log.debug("Found possible matching java method: " + method);
-                        javaMethod = method;
-                        break;
-                     }
+                  // compare params by assignability
+                  if (matchParameters(method, false))
+                  {
+                     log.debug("Found possible matching java method: " + method);
+                     javaMethod = method;
+                     break;
                   }
                }
             }
@@ -315,7 +283,7 @@
                typeMapping.register(methodParam, xmlType, new JAXBSerializerFactory(), new JAXBDeserializerFactory());
             }
          }
-         
+
          if (matchByTypeName)
          {
             pass = methodParam.getName().equals(javaType);
@@ -562,4 +530,24 @@
       }
       return buffer.toString();
    }
+
+   public boolean matchParameters(Method method, boolean exact)
+   {
+      Class[] paramTypes = method.getParameterTypes();
+      Set<Integer> matches = new HashSet<Integer>(paramTypes.length);
+
+      for (ParameterMetaData param : getParameters())
+      {
+         if (! param.matchParameter(method, matches, exact))
+            return false;
+      }
+
+      ParameterMetaData returnMetaData = getReturnParameter();
+      if (returnMetaData != null)
+      {
+         return returnMetaData.matchParameter(method, matches, exact);
+      }
+
+      return true;
+   }
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -23,6 +23,7 @@
 
 // $Id$
 
+import java.lang.reflect.Method;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -31,9 +32,12 @@
 import javax.xml.namespace.QName;
 import javax.xml.rpc.ParameterMode;
 
+import org.jboss.logging.Logger;
 import org.jboss.ws.Constants;
 import org.jboss.ws.WSException;
 import org.jboss.ws.jaxrpc.ParameterWrapping;
+import org.jboss.ws.utils.HolderUtils;
+import org.jboss.ws.utils.IOUtils;
 import org.jboss.ws.utils.JavaUtils;
 
 /**
@@ -45,10 +49,13 @@
  */
 public class ParameterMetaData
 {
+   private static Logger log = Logger.getLogger(ParameterMetaData.class);
+
    // The parent operation
    private OperationMetaData opMetaData;
 
    private QName xmlName;
+   private String partName;
    private QName xmlType;
    private String javaTypeName;
    private Class javaType;
@@ -57,9 +64,8 @@
    private boolean inHeader;
    private boolean isSwA;
    private boolean isXOP;
-   private List<String> wrappedVariables;
-   private List<String> wrappedTypes;
-   private List<QName> wrappedElementNames;
+   private List<WrappedParameter> wrappedParameters;
+   private int index;
 
    // SOAP-ENC:Array
    private boolean soapArrayParam;
@@ -67,33 +73,88 @@
 
    public ParameterMetaData(OperationMetaData opMetaData, QName xmlName, QName xmlType, String javaTypeName)
    {
-      this.xmlName = xmlName;
-      this.xmlType = xmlType;
-      this.opMetaData = opMetaData;
-      this.mode = ParameterMode.IN;
-      this.javaTypeName = javaTypeName;
+      this(opMetaData, xmlName, javaTypeName);
+      setXmlType(xmlType);
+   }
 
+   public ParameterMetaData(OperationMetaData opMetaData, QName xmlName, String javaTypeName)
+   {
       if (xmlName == null)
          throw new IllegalArgumentException("Invalid null xmlName argument");
-      if (xmlType == null)
-         throw new IllegalArgumentException("Invalid null xmlType argument, for: " + xmlName);
 
       // Remove the prefixes
       if (xmlName.getNamespaceURI().length() > 0)
-         this.xmlName = new QName(xmlName.getNamespaceURI(), xmlName.getLocalPart());
+         xmlName = new QName(xmlName.getNamespaceURI(), xmlName.getLocalPart());
 
-      if (xmlType.getNamespaceURI().length() > 0)
-         this.xmlType = new QName(xmlType.getNamespaceURI(), xmlType.getLocalPart());
+      this.xmlName = xmlName;
+      this.opMetaData = opMetaData;
+      this.mode = ParameterMode.IN;
+      this.partName = xmlName.getLocalPart();
+      this.javaTypeName = javaTypeName;
+   }
 
-      // Special case to identify attachments
-      if (Constants.NS_ATTACHMENT_MIME_TYPE.equals(xmlType.getNamespaceURI()))
+   public static class WrappedParameter
+   {
+      public static final int RETURN = -1;
+      public QName name;
+      public String type;
+      public String[] typeArguments;
+      public String variable;
+      public int index = -2;
+
+      public WrappedParameter()
       {
-         String mimeType = convertXmlTypeToMimeType(xmlType);
-         setMimeTypes(mimeType);
-         this.isSwA = true;
       }
+
+      public WrappedParameter(QName name, String type, String variable, int index)
+      {
+         this.name = name;
+         this.type = type;
+         this.variable = variable;
+         this.index = index;
+      }
+
+      public String toString()
+      {
+         return "[name = " + name + ", type = " + type + ", typeArgs = " + IOUtils.printArray(typeArguments) + ", variable = " + variable + ", index = " + index + "]";
+      }
    }
 
+   private static boolean matchParameter(Method method, int index, Class expectedType, Set<Integer> matches, boolean exact)
+   {
+      Class returnType = method.getReturnType();
+      Class[] parameters = method.getParameterTypes();
+
+      if (index == -1 && matchTypes(returnType, expectedType, exact))
+         return true;
+
+      if (index < parameters.length && matchTypes(parameters[index], expectedType,  exact))
+      {
+         matches.add(index);
+         return true;
+      }
+
+      return false;
+   }
+
+   private static boolean matchTypes(Class actualType, Class expectedType, boolean exact)
+   {
+      Class valueType = holderValueClass(actualType);
+
+      boolean matched = (exact) ? valueType.getName().equals(expectedType.getName())
+            : JavaUtils.isAssignableFrom(valueType, expectedType);
+
+      return matched;
+   }
+
+   private static Class holderValueClass(Class holder)
+   {
+      if (! HolderUtils.isHolderType(holder))
+         return holder;
+
+      return HolderUtils.getValueType(holder);
+   }
+
    public OperationMetaData getOperationMetaData()
    {
       return opMetaData;
@@ -109,6 +170,25 @@
       return xmlType;
    }
 
+   public void setXmlType(QName xmlType)
+   {
+      if (xmlType == null)
+         throw new IllegalArgumentException("Invalid null xmlType");
+
+      if (xmlType.getNamespaceURI().length() > 0)
+         this.xmlType = new QName(xmlType.getNamespaceURI(), xmlType.getLocalPart());
+      else
+         this.xmlType = xmlType;
+
+      // Special case to identify attachments
+      if (Constants.NS_ATTACHMENT_MIME_TYPE.equals(xmlType.getNamespaceURI()))
+      {
+         String mimeType = convertXmlTypeToMimeType(xmlType);
+         setMimeTypes(mimeType);
+         this.isSwA = true;
+      }
+   }
+
    public String getJavaTypeName()
    {
       return javaTypeName;
@@ -162,7 +242,7 @@
       else
          throw new IllegalArgumentException("Invalid mode: " + mode);
    }
-   
+
    public void setMode(ParameterMode mode)
    {
       this.mode = mode;
@@ -211,27 +291,6 @@
       this.isXOP = isXOP;
    }
 
-   /** Get the list of wrapped variables, if this is a document wrapping parameter */
-   public List<String> getWrappedVariables()
-   {
-      return wrappedVariables;
-   }
-
-   public void setWrappedVariables(List<String> wrappedVariables)
-   {
-      this.wrappedVariables = wrappedVariables;
-   }
-
-   public List<QName> getWrappedElementNames()
-   {
-      return wrappedElementNames;
-   }
-
-   public void setWrappedElementNames(List<QName> wrappedElementNames)
-   {
-      this.wrappedElementNames = wrappedElementNames;
-   }
-
    public boolean isSOAPArrayParam()
    {
       return soapArrayParam;
@@ -265,17 +324,36 @@
       return mimeName.toString();
    }
 
+   public int getIndex()
+   {
+      return index;
+   }
 
-   public List<String> getWrappedTypes()
+   public void setIndex(int index)
    {
-      return wrappedTypes;
+      this.index = index;
    }
 
-   public void setWrappedTypes(List<String> wrappedTypes)
+   public List<WrappedParameter> getWrappedParameters()
    {
-      this.wrappedTypes = wrappedTypes;
+      return wrappedParameters;
    }
 
+   public void setWrappedParameters(List<WrappedParameter> wrappedParameters)
+   {
+      this.wrappedParameters = wrappedParameters;
+   }
+
+   public String getPartName()
+   {
+      return partName;
+   }
+
+   public void setPartName(String partName)
+   {
+      this.partName = partName;
+   }
+
    /**
     * @see UnifiedMetaData#eagerInitialize()
     */
@@ -291,40 +369,69 @@
       getJavaType();
    }
 
+   public boolean matchParameter(Method method, Set<Integer> matches, boolean exact)
+   {
+      ClassLoader loader = getOperationMetaData().getEndpointMetaData().getClassLoader();
+      List<WrappedParameter> wrappedParameters = getWrappedParameters();
+      Class wrapperType = getJavaType();
+
+      // Standard type
+      if (wrappedParameters == null)
+         return matchParameter(method, getIndex(), getJavaType(), matches, exact);
+
+      // Wrapped type
+      for (WrappedParameter wrapped : wrappedParameters)
+      {
+         String typeName = wrapped.type;
+
+         try
+         {
+            Class type = (typeName != null) ? JavaUtils.loadJavaType(typeName, loader)
+                  : ParameterWrapping.getWrappedType(wrapped.variable, wrapperType);
+            if (type == null)
+               return false;
+            if (! matchParameter(method, wrapped.index, type, matches, exact));
+               return false;
+         }
+         catch (Exception ex)
+         {
+            log.debug("Invalid wrapper type:" + typeName, ex);
+            return false;
+         }
+      }
+
+      return true;
+   }
+
    public String toString()
    {
       boolean isReturn = (opMetaData.getReturnParameter() == this);
       StringBuilder buffer = new StringBuilder("\n" + (isReturn ? "ReturnMetaData:" : "ParameterMetaData:"));
       buffer.append("\n xmlName=" + getXmlName());
+      buffer.append("\n partName=" + getPartName());
       buffer.append("\n xmlType=" + getXmlType());
       buffer.append("\n javaType=" + getJavaTypeName());
       buffer.append("\n mode=" + getMode());
       buffer.append("\n inHeader=" + isInHeader());
-      
+
       if (soapArrayParam)
          buffer.append("\n soapArrayCompType=" + soapArrayCompType);
-      
-      if (wrappedVariables != null)
-         buffer.append("\n wrappedVariables=" + wrappedVariables);
-      
-      if (wrappedTypes != null)
-         buffer.append("\n wrappedTypes=" + wrappedTypes);
-      
-      if (wrappedElementNames != null)
-         buffer.append("\n wrappedElementNames=" + wrappedElementNames);
-      
+
       if (isSwA())
       {
          buffer.append("\n isSwA=" + isSwA());
          buffer.append("\n mimeTypes=" + getMimeTypes());
       }
-      
+
+      if (wrappedParameters != null)
+         buffer.append("\n wrappedParameters=" + wrappedParameters);
+
       if (isXOP())
       {
          buffer.append("\n isXOP=" + isXOP());
          buffer.append("\n mimeTypes=" + getMimeTypes());
       }
-      
+
       return buffer.toString();
    }
 }
\ No newline at end of file

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -75,12 +75,12 @@
    private String contextRoot;
    // The HTTP url parttern
    private String urlPattern;
-   // The bean that registers with the ServiceEndpointManager  
+   // The bean that registers with the ServiceEndpointManager
    private String managedEndpointBean = ServiceEndpoint.class.getName();
 
-   public ServerEndpointMetaData(ServiceMetaData service, QName portName, Type type)
+   public ServerEndpointMetaData(ServiceMetaData service, QName qname, QName interfaceQName, Type type)
    {
-      super(service, portName, type);
+      super(service, qname, interfaceQName, type);
    }
 
    public void setConfigName(String configName)
@@ -170,7 +170,7 @@
       ArrayList<UnifiedHandlerMetaData> handlers = new ArrayList<UnifiedHandlerMetaData>();
 
       Object endpointConfig = getEndpointConfig();
-      
+
       // JAXRPC Handlers
       if (endpointConfig instanceof WSEndpointConfigJAXRPC)
       {
@@ -202,7 +202,7 @@
             }
          }
       }
-      
+
       // JAXWS Handlers
       else
       {

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -25,6 +25,7 @@
 
 import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +33,8 @@
 import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
 import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
 
+import edu.emory.mathcs.backport.java.util.Collections;
+
 /**
  * The top level meta data.
  *
@@ -62,6 +65,7 @@
    Map<String, JavaWsdlMapping> jaxrpcMap = new HashMap<String, JavaWsdlMapping>();
    // The list of service meta data
    private List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+
    // Used by eager initialization
    private boolean initialized = false;
 
@@ -100,7 +104,7 @@
       String prefix = "java:/jaas/";
       if (domain != null && domain.startsWith(prefix))
          domain = domain.substring(prefix.length());
-      
+
       this.securityDomain = domain;
    }
 
@@ -157,7 +161,7 @@
       //buffer.append("\n resourceLoader: " + resourceLoader);
       //buffer.append("\n classLoader: " + classLoader);
       buffer.append("\n");
-      
+
       for (ServiceMetaData serviceMetaData : services)
       {
          buffer.append("\n" + serviceMetaData);

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -24,7 +24,7 @@
 import javax.xml.namespace.QName;
 
 import org.jboss.util.NotImplementedException;
-import org.jboss.util.xml.DOMWriter;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
@@ -36,21 +36,27 @@
  */
 public class DOMTypes extends WSDLTypes
 {
+   /*
+    * Perhaps we should consider moving this to JDOM, or some other DOM
+    * framework that supports concurrent readers. For now callers must
+    * synchronize properly.
+    *
+    * Also could use a cached StAX pool.
+    */
    private Element element;
 
-   public DOMTypes(Element element)
+   public DOMTypes(Document doc)
    {
-      this.element = element;
+      this.element = doc.createElementNS(null, "types");
    }
 
-   public String toString()
+   public Element getElement()
    {
-      return DOMWriter.printNode(element, true);
+      return element;
    }
 
-   @Override
    public QName getXMLType(QName name)
    {
       throw new NotImplementedException();
    }
-}
+}
\ No newline at end of file

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -71,6 +71,7 @@
 import org.jboss.ws.Constants;
 import org.jboss.ws.WSException;
 import org.jboss.ws.jaxrpc.Style;
+import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem.Direction;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
 import org.jboss.ws.metadata.wsdl.xsd.SchemaUtils;
 import org.jboss.ws.tools.JavaToXSD;
@@ -84,6 +85,7 @@
  *
  * @author Thomas.Diesler at jboss.org
  * @author Anil.Saldhana at jboss.org
+ * @author <a href="jason.greene at jboss.com">Jason T. Greene</a>
  * @since 10-Oct-2004
  */
 public class WSDL11Reader
@@ -104,6 +106,9 @@
    // Map of <ns,URL> for schemalocation keyed by namespace
    private Map<String, URL> schemaLocationsMap = new HashMap<String, URL>();
 
+   private LinkedHashMap<QName, Binding> allBindings;
+   private LinkedHashMap<QName, Binding> portTypeBindings;
+
    /**
     * Takes a WSDL11 Definition element and converts into
     * our object graph that has been developed for WSDL20
@@ -462,6 +467,7 @@
 
          WSDLInterfaceOperation destOperation = new WSDLInterfaceOperation(destInterface);
          destOperation.setName(new NCName(srcOperation.getName()));
+         destOperation.setStyle(getOperationStyle(srcWsdl, srcPortType, srcOperation));
 
          processOperationInput(srcWsdl, srcOperation, destOperation, srcPortType);
          processOperationOutput(srcWsdl, srcOperation, destOperation, srcPortType);
@@ -483,87 +489,125 @@
          if (wsaAction != null)
             destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_ACTION_IN, wsaAction.getLocalPart()));
 
-         List paramOrder = srcOperation.getParameterOrdering();
-         Iterator itMessageParts = srcMessage.getOrderedParts(paramOrder).iterator();
-         while (itMessageParts.hasNext())
+         List<String> paramOrder = (List<String>) srcOperation.getParameterOrdering();
+         if (paramOrder != null)
          {
-            WSDLInterfaceOperationInput destInput = new WSDLInterfaceOperationInput(destOperation);
+            for (String name : paramOrder)
+            {
+               if (srcMessage.getPart(name) != null)
+                  destOperation.addRpcSignatureItem(new WSDLRPCSignatureItem(name));
+            }
+         }
 
-            Part srcPart = (Part)itMessageParts.next();
-            QName elementName = messagePartToElementName(srcWsdl, srcPortType, srcOperation, srcMessage, srcPart);
-            destInput.setElement(elementName);
+         WSDLInterfaceOperationInput rpcInput = new WSDLInterfaceOperationInput(destOperation);
+         for (Part srcPart : (List<Part>) srcMessage.getOrderedParts(paramOrder))
+         {
+            if (Constants.URI_STYLE_IRI == destOperation.getStyle())
+            {
+               WSDLInterfaceOperationInput destInput = new WSDLInterfaceOperationInput(destOperation);
+               QName elementName = messagePartToElementName(srcWsdl, srcPortType, srcOperation, srcMessage, srcPart);
+               destInput.setElement(elementName);
 
-            //Lets remember the Message name
-            destInput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME, srcMessage.getQName().getLocalPart()));
-            destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_IN, srcMessage.getQName().getLocalPart()));
+               //Lets remember the Message name
+               destInput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME, srcMessage.getQName().getLocalPart()));
+               destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_IN, srcMessage.getQName().getLocalPart()));
 
-            // Remember the original part name
-            WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_PART_NAME, srcPart.getName());
-            destInput.addProperty(wsdlProperty);
+               destInput.setPartName(srcPart.getName());
 
-            // If the Part references a type rather than an element
-            // we transport the xmlType as property
-            QName xmlType = srcPart.getTypeName();
-            if (xmlType != null)
+               destOperation.addInput(destInput);
+            }
+            else
             {
-               xmlType = destWsdl.registerQName(xmlType);
-               String value = xmlType.getPrefix() + ":" + xmlType.getLocalPart();
-               wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_RPC_XMLTYPE, value);
-               destInput.addProperty(wsdlProperty);
+               // If we don't have a type then we aren't a valid RPC parameter
+               // This could happen on a header element, in which case the
+               // binding will pick it up
+               QName xmlType = srcPart.getTypeName();
+               if (xmlType != null)
+                  rpcInput.addChildPart(new WSDLRPCPart(srcPart.getName(), destWsdl.registerQName(xmlType)));
             }
-
-            destOperation.addInput(destInput);
          }
+         if (Constants.URI_STYLE_RPC == destOperation.getStyle())
+         {
+            // This is really a place holder, but also the actual value used in
+            // WSDL 2.0 RPC bindings
+            rpcInput.setElement(destOperation.getQName());
+            destOperation.addInput(rpcInput);
+         }
       }
    }
 
    private void processOperationOutput(Definition srcWsdl, Operation srcOperation, WSDLInterfaceOperation destOperation, PortType srcPortType)
    {
       Output srcOutput = srcOperation.getOutput();
-      if (srcOutput != null)
+      if (srcOutput == null)
       {
-         Message srcMessage = srcOutput.getMessage();
-         log.trace("processOperationOutput: " + srcMessage.getQName());
+         destOperation.setPattern(Constants.WSDL20_PATTERN_IN_ONLY);
+         return;
+      }
 
-         destOperation.setPattern(Constants.WSDL20_PATTERN_IN_OUT);
-         QName wsaAction = (QName)srcOutput.getExtensionAttribute(Constants.WSDL_ATTRIBUTE_WSA_ACTION);
-         if (wsaAction != null)
-            destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_ACTION_OUT, wsaAction.getLocalPart()));
+      Message srcMessage = srcOutput.getMessage();
+      log.trace("processOperationOutput: " + srcMessage.getQName());
 
-         Iterator itMessageParts = srcMessage.getOrderedParts(null).iterator();
-         while (itMessageParts.hasNext())
+      destOperation.setPattern(Constants.WSDL20_PATTERN_IN_OUT);
+      QName wsaAction = (QName) srcOutput.getExtensionAttribute(Constants.WSDL_ATTRIBUTE_WSA_ACTION);
+      if (wsaAction != null)
+         destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_ACTION_OUT, wsaAction.getLocalPart()));
+
+      List<String> paramOrder = (List<String>) srcOperation.getParameterOrdering();
+      if (paramOrder != null)
+      {
+         for (String name : paramOrder)
          {
+            if (srcMessage.getPart(name) != null)
+            {
+               WSDLRPCSignatureItem item = destOperation.getRpcSignatureitem(name);
+               if (item != null)
+                  item.setDirection(Direction.INOUT);
+               else
+                  destOperation.addRpcSignatureItem(new WSDLRPCSignatureItem(name, Direction.OUT));
+            }
+         }
+      }
+
+      WSDLInterfaceOperationOutput rpcOutput = new WSDLInterfaceOperationOutput(destOperation);
+      for (Part srcPart : (List<Part>) srcMessage.getOrderedParts(null))
+      {
+         if (Constants.URI_STYLE_IRI == destOperation.getStyle())
+         {
             WSDLInterfaceOperationOutput destOutput = new WSDLInterfaceOperationOutput(destOperation);
 
-            Part srcPart = (Part)itMessageParts.next();
             QName elementName = messagePartToElementName(srcWsdl, srcPortType, srcOperation, srcMessage, srcPart);
             destOutput.setElement(elementName);
 
-            //Lets remember the Message name
+            // Lets remember the Message name
             destOutput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME, srcMessage.getQName().getLocalPart()));
-            destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_OUT, srcMessage.getQName().getLocalPart()));
+            destOperation.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_OUT, srcMessage.getQName()
+                  .getLocalPart()));
 
             // Remember the original part name
             WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_PART_NAME, srcPart.getName());
             destOutput.addProperty(wsdlProperty);
 
-            // If the Part references a type rather than an element
-            // we transport the xmlType as property
+            destOperation.addOutput(destOutput);
+         }
+         else
+         {
+            // If we don't have a type then we aren't a valid RPC parameter
+            // This could happen on a header element, in which case the
+            // binding will pick it up
             QName xmlType = srcPart.getTypeName();
             if (xmlType != null)
-            {
-               xmlType = destWsdl.registerQName(xmlType);
-               String value = xmlType.getPrefix() + ":" + xmlType.getLocalPart();
-               wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_RPC_XMLTYPE, value);
-               destOutput.addProperty(wsdlProperty);
-            }
-
-            destOperation.addOutput(destOutput);
+               rpcOutput.addChildPart(new WSDLRPCPart(srcPart.getName(), destWsdl.registerQName(xmlType)));
          }
       }
-      else
+
+      if (Constants.URI_STYLE_RPC == destOperation.getStyle())
       {
-         destOperation.setPattern(Constants.WSDL20_PATTERN_IN_ONLY);
+         // This is really a place holder, but also the actual value used in
+         // WSDL 2.0 RPC bindings
+         QName name = destOperation.getQName();
+         rpcOutput.setElement(new QName(name.getNamespaceURI(), name.getLocalPart() + "Response"));
+         destOperation.addOutput(rpcOutput);
       }
    }
 
@@ -597,16 +641,14 @@
 
       Part part = (Part)partsMap.values().iterator().next();
       QName xmlName = part.getElementName();
-      QName xmlType = part.getTypeName();
 
-      destFault.setXmlType(xmlType);
       if (xmlName != null)
       {
-         destFault.setXmlName(xmlName);
+         destFault.setElement(xmlName);
       }
       else
       {
-         destFault.setXmlName(messageName);
+         destFault.setElement(messageName);
          log.warn("Unsupported fault message part in message: " + messageName);
       }
 
@@ -629,94 +671,73 @@
    {
       // <part name="param" element="tns:SomeType" />
       QName xmlName = srcPart.getElementName();
-      if (xmlName != null)
-         xmlName = destWsdl.registerQName(xmlName);
 
       // <part name="param" type="xsd:string" />
       if (xmlName == null)
-      {
-         // Use the part name as fallback
          xmlName = new QName(srcPart.getName());
 
-         // The binding may define a different xmlName for this message part (i.e. in case of header parts)
-         // The rest of this implementation tries to discover that binding.
+      xmlName = destWsdl.registerQName(xmlName);
+      String key = srcMessage.getQName() + "->" + srcPart.getName();
+      messagePartToElementMap.put(key, xmlName);
 
-         // Find the binding for this portType
-         Binding srcBinding = null;
-         Iterator itBindings = getAllDefinedBindings(srcWsdl).values().iterator();
-         while (srcBinding == null && itBindings.hasNext())
-         {
-            Binding binding = (Binding)itBindings.next();
-            if (binding.getPortType().equals(srcPortType))
-               srcBinding = binding;
-         }
+      return xmlName;
+   }
 
-         if (srcBinding == null)
-            throw new WSException("Cannot find binding for: " + srcPortType.getQName());
+   private BindingOperation getBindingOperation(Definition srcWsdl, PortType srcPortType, Operation srcOperation)
+   {
+      Binding srcBinding = getPortTypeBindings(srcWsdl).get(srcPortType.getQName());
 
-         String srcOperationName = srcOperation.getName();
-         BindingOperation srcBindingOperation = srcBinding.getBindingOperation(srcOperationName, null, null);
-         if (srcBindingOperation == null)
-            throw new WSException("Cannot find binding operation for: " + srcOperationName);
+      if (srcBinding == null)
+         throw new WSException("Cannot find binding for: " + srcPortType.getQName());
 
-         // Scan the binding input for a <soap:header> for this message part
-         BindingInput srcBindingInput = srcBindingOperation.getBindingInput();
-         if (srcBindingInput != null)
+      String srcOperationName = srcOperation.getName();
+      BindingOperation srcBindingOperation = srcBinding.getBindingOperation(srcOperationName, null, null);
+      if (srcBindingOperation == null)
+         throw new WSException("Cannot find binding operation for: " + srcOperationName);
+      return srcBindingOperation;
+   }
+
+   private String getOperationStyle(Definition srcWsdl, PortType srcPortType, Operation srcOperation)
+   {
+      Binding srcBinding = getPortTypeBindings(srcWsdl).get(srcPortType.getQName());
+      BindingOperation srcBindingOperation = getBindingOperation(srcWsdl, srcPortType, srcOperation);
+
+      String operationStyle = null;
+      List<ExtensibilityElement> extList = srcBindingOperation.getExtensibilityElements();
+      for (ExtensibilityElement extElement : extList)
+      {
+         QName elementType = extElement.getElementType();
+         if (extElement instanceof SOAPOperation)
          {
-            Iterator itExt = srcBindingInput.getExtensibilityElements().iterator();
-            while (itExt.hasNext())
-            {
-               ExtensibilityElement extEl = (ExtensibilityElement)itExt.next();
-               if (extEl instanceof SOAPHeader)
-               {
-                  SOAPHeader header = (SOAPHeader)extEl;
-                  QName messageQName = header.getMessage();
-                  String partName = header.getPart();
-                  if (messageQName.equals(srcMessage.getQName()) && partName.equals(srcPart.getName()))
-                  {
-                     String namespaceURI = header.getNamespaceURI();
-                     if (namespaceURI != null)
-                     {
-                        xmlName = new QName(namespaceURI, partName);
-                        xmlName = destWsdl.registerQName(xmlName);
-                     }
-                  }
-               }
-            }
+            SOAPOperation soapOp = (SOAPOperation)extElement;
+            operationStyle = soapOp.getStyle();
          }
+         else if (SOAP12_OPERATION.equals(elementType))
+         {
+            Element domElement = ((UnknownExtensibilityElement)extElement).getElement();
+            operationStyle = getOptionalAttribute(domElement, "style");
+         }
+      }
 
-         // Scan the binding output for a <soap:header> for this message part
-         BindingOutput srcBindingOutput = srcBindingOperation.getBindingOutput();
-         if (srcBindingOutput != null)
+      if (operationStyle == null)
+      {
+         for (ExtensibilityElement extElement : (List<ExtensibilityElement>) srcBinding.getExtensibilityElements())
          {
-            Iterator itExt = srcBindingOutput.getExtensibilityElements().iterator();
-            while (itExt.hasNext())
+            QName elementType = extElement.getElementType();
+            if (extElement instanceof SOAPBinding)
             {
-               ExtensibilityElement extEl = (ExtensibilityElement)itExt.next();
-               if (extEl instanceof SOAPHeader)
-               {
-                  SOAPHeader header = (SOAPHeader)extEl;
-                  QName messageQName = header.getMessage();
-                  String partName = header.getPart();
-                  if (messageQName.equals(srcMessage.getQName()) && partName.equals(srcPart.getName()))
-                  {
-                     String namespaceURI = header.getNamespaceURI();
-                     if (namespaceURI != null)
-                     {
-                        xmlName = new QName(namespaceURI, partName);
-                        xmlName = destWsdl.registerQName(xmlName);
-                     }
-                  }
-               }
+               SOAPBinding soapBinding = (SOAPBinding) extElement;
+               operationStyle = soapBinding.getStyle();
             }
+            else if (SOAP12_BINDING.equals(elementType))
+            {
+               Element domElement = ((UnknownExtensibilityElement) extElement).getElement();
+               operationStyle = getOptionalAttribute(domElement, "style");
+            }
          }
       }
 
-      // cache the element name for processing of the bindings
-      String key = srcMessage.getQName() + "->" + srcPart.getName();
-      messagePartToElementMap.put(key, xmlName);
-
-      return xmlName;
+      return  ("rpc".equals(operationStyle)) ? Constants.URI_STYLE_RPC : Constants.URI_STYLE_IRI;
    }
 
    private void processBinding(Definition srcWsdl, Binding srcBinding)
@@ -730,7 +751,7 @@
          PortType srcPortType = srcBinding.getPortType();
          if (srcPortType == null)
             throw new WSException("Cannot find port type for binding: " + ncName);
-         
+
          processPortType(srcWsdl, srcPortType);
 
          WSDLBinding destBinding = new WSDLBinding(destWsdl);
@@ -761,15 +782,26 @@
       }
    }
 
-   private Map getAllDefinedBindings(Definition srcWsdl)
+   private Map<QName, Binding> getPortTypeBindings(Definition srcWsdl)
    {
-      Map<QName, Binding> retMap = new LinkedHashMap<QName, Binding>();
+      getAllDefinedBindings(srcWsdl);
+      return portTypeBindings;
+   }
+
+   private Map<QName, Binding> getAllDefinedBindings(Definition srcWsdl)
+   {
+      if (allBindings != null)
+         return allBindings;
+
+      allBindings = new LinkedHashMap<QName, Binding>();
+      portTypeBindings = new LinkedHashMap<QName, Binding>();
       Map srcBindings = srcWsdl.getBindings();
       Iterator itBinding = srcBindings.values().iterator();
       while (itBinding.hasNext())
       {
          Binding srcBinding = (Binding)itBinding.next();
-         retMap.put(srcBinding.getQName(), srcBinding);
+         allBindings.put(srcBinding.getQName(), srcBinding);
+         portTypeBindings.put(srcBinding.getPortType().getQName(), srcBinding);
       }
 
       // Bindings not available when pulled in through <wsdl:import>
@@ -783,10 +815,12 @@
          {
             Port srcPort = (Port)itPort.next();
             Binding srcBinding = srcPort.getBinding();
-            retMap.put(srcBinding.getQName(), srcBinding);
+            allBindings.put(srcBinding.getQName(), srcBinding);
+            portTypeBindings.put(srcBinding.getPortType().getQName(), srcBinding);
          }
       }
-      return retMap;
+
+      return allBindings;
    }
 
    private void processBindingOperations(WSDLBinding destBinding, Binding srcBinding, String bindingStyle)
@@ -816,7 +850,6 @@
       WSDLInterfaceOperation destIntfOperation = destInterface.getOperation(new NCName(opName));
 
       // Process soap:operation at soapAction, soap:operation at style
-      String operationStyle = null;
       List<ExtensibilityElement> extList = srcBindingOperation.getExtensibilityElements();
       for (ExtensibilityElement extElement : extList)
       {
@@ -825,117 +858,108 @@
          {
             SOAPOperation soapOp = (SOAPOperation)extElement;
             destBindingOperation.setSOAPAction(soapOp.getSoapActionURI());
-            operationStyle = soapOp.getStyle();
          }
          else if (SOAP12_OPERATION.equals(elementType))
          {
             Element domElement = ((UnknownExtensibilityElement)extElement).getElement();
-            operationStyle = getOptionalAttribute(domElement, "style");
          }
-
       }
-      destIntfOperation.setStyle(operationStyle != null ? operationStyle : bindingStyle);
 
       BindingInput srcBindingInput = srcBindingOperation.getBindingInput();
       if (srcBindingInput != null)
       {
-         processBindingInput(destBindingOperation, destIntfOperation, srcBindingInput);
+         processBindingInput(destBindingOperation, destIntfOperation, srcBindingOperation, srcBindingInput);
       }
 
       BindingOutput srcBindingOutput = srcBindingOperation.getBindingOutput();
       if (srcBindingOutput != null)
       {
-         processBindingOutput(destBindingOperation, destIntfOperation, srcBindingOutput);
+         processBindingOutput(destBindingOperation, destIntfOperation, srcBindingOperation, srcBindingOutput);
       }
    }
 
-   private void processBindingInput(WSDLBindingOperation destBindingOperation, WSDLInterfaceOperation destIntfOperation, BindingInput srcBindingInput)
+   interface ReferenceCallback
    {
+      void removeReference(QName element);
+      void removeRPCPart(String partName);
+      QName getXmlType(String partName);
+   }
+
+   private void processBindingInput(WSDLBindingOperation destBindingOperation, final WSDLInterfaceOperation destIntfOperation, final BindingOperation srcBindingOperation, BindingInput srcBindingInput)
+   {
       log.trace("processBindingInput");
 
       QName soap11Body = new QName(Constants.NS_SOAP11, "body");
       List<ExtensibilityElement> extList = srcBindingInput.getExtensibilityElements();
-      for (ExtensibilityElement extElement : extList)
+      WSDLBindingOperationInput input = new WSDLBindingOperationInput(destBindingOperation);
+      destBindingOperation.addInput(input);
+
+      ReferenceCallback cb = new ReferenceCallback()
       {
-         QName elementType = extElement.getElementType();
-         if (soap11Body.equals(elementType) || SOAP12_BODY.equals(elementType))
+         public QName getXmlType(String partName)
          {
-            processEncodingStyle(extElement, destBindingOperation);
+            return srcBindingOperation.getOperation().getInput().getMessage().getPart(partName).getTypeName();
          }
-         else if (extElement instanceof SOAPHeader)
+
+         public void removeReference(QName element)
          {
-            SOAPHeader header = (SOAPHeader)extElement;
-            QName messageQName = header.getMessage();
-            String partName = header.getPart();
+            WSDLInterfaceOperationInput destIntfInput = destIntfOperation.getInput(element);
+            if (destIntfInput == null)
+               destIntfOperation.removeInput(element);
+         }
 
-            // get cached element name for processing of the bindings
-            String key = messageQName + "->" + partName;
-            QName elementName = (QName)messagePartToElementMap.get(key);
-            if (elementName != null)
-            {
-               WSDLInterfaceOperationInput destIntfInput = destIntfOperation.getInput(elementName);
-               if (destIntfInput == null)
-                  throw new WSException("Cannot find interface input for element: " + elementName);
+         public void removeRPCPart(String partName)
+         {
+            WSDLInterfaceOperationInput operationInput = destIntfOperation.getInput(destIntfOperation.getQName());
+            operationInput.removeChildPart(partName);
+         }
+      };
 
-               WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA, false, null, null);
-               destIntfInput.addProperty(wsdlProperty);
-            }
+      processBindingReference(destBindingOperation, destIntfOperation, soap11Body, extList, input, cb);
+   }
+
+   private void processBindingOutput(WSDLBindingOperation destBindingOperation, final WSDLInterfaceOperation destIntfOperation, final BindingOperation srcBindingOperation, BindingOutput srcBindingOutput)
+   {
+      log.trace("processBindingInput");
+
+      QName soap11Body = new QName(Constants.NS_SOAP11, "body");
+      List<ExtensibilityElement> extList = srcBindingOutput.getExtensibilityElements();
+      WSDLBindingOperationOutput output = new WSDLBindingOperationOutput(destBindingOperation);
+      destBindingOperation.addOutput(output);
+
+      ReferenceCallback cb = new ReferenceCallback()
+      {
+         public QName getXmlType(String partName)
+         {
+            return srcBindingOperation.getOperation().getOutput().getMessage().getPart(partName).getTypeName();
          }
-         else if (extElement instanceof MIMEMultipartRelated)
+
+         public void removeReference(QName element)
          {
-            MIMEMultipartRelated related = (MIMEMultipartRelated)extElement;
-            Iterator i = related.getMIMEParts().iterator();
-            while (i.hasNext())
-            {
-               MIMEPart part = (MIMEPart)i.next();
-               Iterator j = part.getExtensibilityElements().iterator();
-               String name = null;
-               String types = null;
+            WSDLInterfaceOperationOutput destIntfOutput = destIntfOperation.getOutput(element);
+            if (destIntfOutput == null)
+               destIntfOperation.removeInput(element);
+         }
 
-               while (j.hasNext())
-               {
-                  ExtensibilityElement inner = (ExtensibilityElement)j.next();
-                  if (inner instanceof MIMEContent)
-                  {
-                     MIMEContent content = (MIMEContent)inner;
-                     name = content.getPart();
-                     if (types == null)
-                     {
-                        types = content.getType();
-                     }
-                     else
-                     {
-                        types += "," + content.getType();
-                     }
-                  }
-               }
+         public void removeRPCPart(String partName)
+         {
+            QName name = destIntfOperation.getQName();
+            WSDLInterfaceOperationOutput operationOutput = destIntfOperation.getOutput(new QName(name.getNamespaceURI(), name.getLocalPart()));
+            operationOutput.removeChildPart(partName);
+         }
+      };
 
-               // Found content types in this part
-               if (name != null)
-               {
-                  // A mime part must be defined as <part type="">
-                  QName elementName = new QName(name);
-                  WSDLInterfaceOperationInput destIntfInput = destIntfOperation.getInput(elementName);
-                  if (destIntfInput == null)
-                     throw new WSException("Cannot find interface input for element: " + elementName);
-
-                  WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_WSDL11_MIME_TYPE, false, types, null);
-                  destIntfInput.addProperty(wsdlProperty);
-               }
-            }
-         }
-      }
+      processBindingReference(destBindingOperation, destIntfOperation, soap11Body, extList, output, cb);
    }
 
-   private void processBindingOutput(WSDLBindingOperation destBindingOperation, WSDLInterfaceOperation destIntfOperation, BindingOutput srcBindingOutput)
+
+   private void processBindingReference(WSDLBindingOperation destBindingOperation, WSDLInterfaceOperation destIntfOperation,
+         QName soap11Body, List<ExtensibilityElement> extList, WSDLBindingMessageReference reference, ReferenceCallback callback)
    {
-      log.trace("processBindingOutput");
-
-      List<ExtensibilityElement> extList = srcBindingOutput.getExtensibilityElements();
       for (ExtensibilityElement extElement : extList)
       {
          QName elementType = extElement.getElementType();
-         if (extElement instanceof SOAPBody || SOAP12_BODY.equals(elementType))
+         if (soap11Body.equals(elementType) || SOAP12_BODY.equals(elementType))
          {
             processEncodingStyle(extElement, destBindingOperation);
          }
@@ -945,18 +969,22 @@
             QName messageQName = header.getMessage();
             String partName = header.getPart();
 
-            // get cached element name for processing of the bindings
-            String key = messageQName + "->" + partName;
-            QName elementName = (QName)messagePartToElementMap.get(key);
-            if (elementName != null)
+            reference.addSoapHeader(new WSDLSOAPHeader(header.getElementType(), partName));
+            if (Constants.URI_STYLE_IRI == destIntfOperation.getStyle())
             {
-               WSDLInterfaceOperationOutput destIntfOutput = destIntfOperation.getOutput(elementName);
-               if (destIntfOutput == null)
-                  throw new WSException("Cannot find interface output for element: " + elementName);
-
-               WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA, false, null, null);
-               destIntfOutput.addProperty(wsdlProperty);
+               String key = messageQName + "->" + partName;
+               QName elementName = (QName)messagePartToElementMap.get(key);
+               if (elementName != null)
+               {
+                  // Remove the extra input that was added in the operation processing phase
+                  callback.removeReference(elementName);
+               }
             }
+            else
+            {
+               // Just in case
+               callback.removeRPCPart(partName);
+            }
          }
          else if (extElement instanceof MIMEMultipartRelated)
          {
@@ -990,20 +1018,24 @@
                // Found content types in this part
                if (name != null)
                {
-                  // A mime part must be defined as <part type="">
-                  QName elementName = new QName(name);
-                  WSDLInterfaceOperationOutput destIntfOutput = destIntfOperation.getOutput(elementName);
-                  if (destIntfOutput == null)
-                     throw new WSException("Cannot find interface output for element: " + elementName);
-
-                  WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_WSDL11_MIME_TYPE, false, types, null);
-                  destIntfOutput.addProperty(wsdlProperty);
+                  QName xmlType  = callback.getXmlType(name);
+                  reference.addMimePart(new WSDLMIMEPart(name, xmlType, types));
+                  if (Constants.URI_STYLE_IRI == destIntfOperation.getStyle())
+                  {
+                     // A mime part must be defined as <part type="">
+                     callback.removeReference(new QName(name));
+                  }
+                  else
+                  {
+                     callback.removeRPCPart(name);
+                  }
                }
             }
          }
       }
    }
 
+
    private void processEncodingStyle(ExtensibilityElement extElement, WSDLBindingOperation destBindingOperation)
    {
       log.trace("processEncodingStyle");

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -36,6 +36,7 @@
 import org.jboss.util.xml.DOMWriter;
 import org.jboss.ws.Constants;
 import org.jboss.ws.WSException;
+import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem.Direction;
 import org.w3c.dom.Element;
 
 /**
@@ -50,7 +51,7 @@
 
    // Used to prevent duplicates
    private HashSet<String> writtenFaultMessages = new HashSet<String>();
-   
+
    /** Use WSDLDefinitions.writeWSDL instead. */
    public WSDL11Writer(WSDLDefinitions wsdl)
    {
@@ -118,8 +119,8 @@
          {
             appendMessage(buffer, operations[j]);
             appendMessagesForExceptions(buffer, operations[j]);
-         }//end for
-      }//end for
+         }
+      }
    }
 
    private void appendMessage(StringBuilder buffer, WSDLInterfaceOperation operation)
@@ -131,39 +132,18 @@
 
       String interfaceName = operation.getWsdlInterface().getName().toString();
       buffer.append("<message name='" + interfaceName + "_" + opname + "' >");
-      WSDLInterfaceOperationInput[] inputs = operation.getInputs();
-      int lenin = inputs.length;
-      for (int i = 0; i < lenin; i++)
-      {
-         WSDLInterfaceOperationInput input = inputs[i];
-         appendInputParts(buffer, input, i);
-      }
-
+      for (WSDLInterfaceOperationInput input : operation.getInputs())
+         appendMessageParts(buffer, input);
       buffer.append("</message>");
 
-      //Now the return type
-      WSDLInterfaceOperationOutput[] outputs = operation.getOutputs();
-      int lenout = outputs != null ? outputs.length : 0;
-
-      if (Constants.WSDL20_PATTERN_IN_ONLY.equals(operation.getPattern()))
-         return;
-
-      buffer.append("<message name='" + interfaceName + "_" + opname + "Response' >");
-      if (lenout > 0)
+      if (! Constants.WSDL20_PATTERN_IN_ONLY.equals(operation.getPattern()))
       {
-         //Since the outputs have been obtained from a linkedhashmap
-         //they will be in the order of insertion i.e. in case of
-         //holders, the holder types will be inserted first. So let
-         //us iterate in the reverse order
-         String str = "";
-         for (int i = 0; i < lenout; i++)
-         {
-            WSDLInterfaceOperationOutput out = outputs[i];
-            str += appendOutputParts(out, i);
-         }
-         buffer.append(str);
-      }//end if
-      buffer.append("</message>");
+         buffer.append("<message name='" + interfaceName + "_" + opname + "Response' >");
+         WSDLInterfaceOperationOutput[] outputs = operation.getOutputs();
+         for (WSDLInterfaceOperationOutput output : outputs)
+            appendMessageParts(buffer, output);
+         buffer.append("</message>");
+      }
    }
 
    private void appendMessagesForExceptions(StringBuilder buffer, WSDLInterfaceOperation operation)
@@ -190,56 +170,64 @@
       }
    }
 
-   private void appendInputParts(StringBuilder buffer, WSDLInterfaceOperationInput input, int index)
+   private void appendMessageParts(StringBuilder buffer, WSDLInterfaceMessageReference reference)
    {
-      boolean header = input.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-      if (wsdlStyle.equals(Constants.RPC_LITERAL) && !header)
+      if (wsdlStyle.equals(Constants.RPC_LITERAL))
       {
-         QName el = input.getElement();
-         QName xmlType = input.getXMLType();
-         String prefix = wsdl.getPrefix(xmlType.getNamespaceURI() );
-         buffer.append("<part name='" + el.getLocalPart() + "'");
-         buffer.append(" type='" + prefix + ":" + xmlType.getLocalPart() + "'>");
-         buffer.append("</part>");
+         for (WSDLRPCPart part : reference.getChildParts())
+         {
+            String prefix = wsdl.getPrefix(part.getType().getNamespaceURI());
+            buffer.append("<part name='" + part.getName());
+            buffer.append(" type='" + prefix + ":" + part.getType());
+            buffer.append("</part>");
+         }
       }
-      //Doc-literal case
       else
       {
-         //TODO:Handle this better later
-         //In the case of doc/lit, the input element will give the partname
-         QName elm = input.getElement();
-         buffer.append("<part name='").append(header ? elm.getLocalPart() : "parameters").append("'");
-         String part = wsdl.getPrefix(elm.getNamespaceURI()) + ":" + elm.getLocalPart();
-         buffer.append(" element='" + part + "'>");
-         buffer.append("</part>");
+         QName element = reference.getElement();
+         String prefix = wsdl.getPrefix(element.getNamespaceURI());
+         buffer.append("<part name='").append(reference.getPartName());
+         buffer.append(" element='").append(prefix).append(":").append(element.getLocalPart());
+         buffer.append("</part");
       }
+
+      WSDLBindingMessageReference bindingReference = getBindingReference(reference);
+      if (bindingReference == null)
+         return;
+
+      for (WSDLSOAPHeader header : bindingReference.getSoapHeaders())
+      {
+         if (header.isIncludeInSignature());
+         {
+            QName element = header.getElement();
+            String prefix = wsdl.getPrefix(element.getNamespaceURI());
+            buffer.append("<part name='").append(header.getPartName());
+            buffer.append(" element='").append(prefix).append(":").append(element.getLocalPart());
+            buffer.append("</part");
+         }
+      }
    }
 
-   private String appendOutputParts(WSDLInterfaceOperationOutput out, int index)
+   private WSDLBindingMessageReference getBindingReference(WSDLInterfaceMessageReference reference)
    {
-      boolean header = out.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-      StringBuilder buf = new StringBuilder("");
-      if (wsdlStyle.equals(Constants.RPC_LITERAL) && !header)
-      {
-         //Get the XMLName
-         QName xmlName = out.getElement();
-         QName xmlType = out.getXMLType();
-         String prefix = wsdl.getPrefix(xmlType.getNamespaceURI() );
+      WSDLInterfaceOperation operation = reference.getWsdlOperation();
+      WSDLInterface wsdlInterface = operation.getWsdlInterface();
+      WSDLBinding binding = wsdlInterface.getWsdlDefinitions().getBindingByInterfaceName(wsdlInterface.getQName());
+      WSDLBindingOperation bindingOperation = binding.getOperationByRef(operation.getQName());
+      WSDLBindingMessageReference[] bindingReferences;
 
-         buf.append("<part name='" + xmlName.getLocalPart() + "'");
-         buf.append(" type='" + prefix + ":" + xmlType.getLocalPart() + "'>");
-         buf.append("</part>");
-      }
+      if (reference instanceof WSDLInterfaceOperationInput)
+         bindingReferences = bindingOperation.getInputs();
       else
-      {
-         QName elm = out.getElement();
-         buf.append("<part name='").append(header ? elm.getLocalPart() : Constants.DEFAULT_RPC_RETURN_NAME).append("'");
-         String value = wsdl.getPrefix(elm.getNamespaceURI()) + ":" + elm.getLocalPart();
-         //String value = this.getXMLTypeFromWSDLProperty(out);
-         buf.append(" element='" + value + "'>");
-         buf.append("</part>");
-      }
-      return buf.toString();
+         bindingReferences = bindingOperation.getOutputs();
+
+      if (bindingReferences.length > 1)
+         throw new IllegalArgumentException("WSDl 1.1 only supports In-Only, and In-Out MEPS, more than reference input found");
+
+      if (bindingReferences.length == 1)
+         return bindingReferences[0];
+
+      return null;
    }
 
    protected void appendInterfaces(StringBuilder buffer)
@@ -259,6 +247,22 @@
       buffer.append("</portType>");
    }
 
+   private String getParameterOrder(WSDLInterfaceOperation operation)
+   {
+      StringBuilder builder = new StringBuilder();
+      for (WSDLRPCSignatureItem item : operation.getRpcSignatureItems())
+      {
+         if (item.getDirection() != Direction.RETURN)
+         {
+            if (builder.length() > 0)
+               builder.append(' ');
+            builder.append(item.getName());
+         }
+      }
+
+      return builder.toString();
+   }
+
    protected void appendPortOperations(StringBuilder buffer, WSDLInterface intf)
    {
       String targetPrefix = wsdl.getTargetPrefix();
@@ -266,47 +270,13 @@
       for (int i = 0; i < operations.length; i++)
       {
          WSDLInterfaceOperation operation = operations[i];
-         WSDLInterfaceOperationInput[] inputs = operation.getInputs();
-         WSDLInterfaceOperationOutput[] outputs = operation.getOutputs();
          buffer.append("<operation name='" + operation.getName().toString() + "'");
 
-         if (wsdlStyle.equals(Constants.RPC_LITERAL))
-         {
-            StringBuilder order = new StringBuilder();
-            Set<QName> inParameters = new HashSet<QName>();
-            for (int j = 0; j < inputs.length; j++)
-            {
-               WSDLInterfaceOperationInput input = inputs[j];
-               if (order.length() > 0)
-                  order.append(" ");
-               QName el = input.getElement();
-               order.append(el.getLocalPart());
-               inParameters.add(el);
-            }
+         String parameterOrder = getParameterOrder(operation);
+         if (parameterOrder.length() > 0)
+            buffer.append(" parameterOrder='").append(parameterOrder).append("'");
+         buffer.append(">");
 
-            for (int j = 0; j < outputs.length; j++)
-            {
-               WSDLInterfaceOperationOutput output = outputs[j];
-               // The return value is ommitted as a hint to other parameter based binding layers.
-               // Also, INOUT parameters need to only appear once
-               if (output.getProperty(Constants.WSDL_PROPERTY_RETURN_PART) == null)
-               {
-                  QName el = output.getElement();
-                  if (! inParameters.contains(el))
-                  {
-                     if (order.length() > 0)
-                        order.append(" ");
-                     order.append(el.getLocalPart());
-                  }
-               }
-            }
-
-            if (order.length() > 0)
-               buffer.append(" parameterOrder='").append(order.toString()).append("'");
-         }
-
-         buffer.append(">"); //End operation element
-
          String opname = operation.getName().toString();
          String interfaceName = operation.getWsdlInterface().getName().toString();
          String msgEl = targetPrefix + ":" + interfaceName + "_" + opname;
@@ -320,26 +290,11 @@
          }
 
          //Append the Faults
-         WSDLInterfaceOperationOutfault[] faults = operation.getOutfaults();
-         //WSDLInterfaceFault[] faults = intf.getFaults();
-         int lenf = faults != null ? faults.length : 0;
-         for (int k = 0; k < lenf; k++)
+         for (WSDLInterfaceOperationOutfault fault : operation.getOutfaults())
          {
-            //WSDLInterfaceFault flt = faults[k];
-            WSDLInterfaceOperationOutfault flt = faults[k];
-            QName elt = flt.getRef();
-
-            String targetNS = wsdl.getTargetNamespace();
-            //Writing the fault, the prefix should always be the one for wsdl target namespace
-            elt = new QName(targetNS, elt.getLocalPart(), wsdl.getPrefix(targetNS));
-            //Remove Fault or Error appended to the name
-            String cleanname = utils.chop(utils.chop(elt.getLocalPart(), "Error"), "Fault");
-
-            String n = "name='" + cleanname + "'";
-
-            String cleanref = utils.chop(utils.getFormattedString(elt), "Error");
-            buffer.append("<fault  message='" + cleanref + "' " + n + ">");
-            buffer.append("</fault>");
+            QName element = fault.getRef();
+            buffer.append("<fault  message='" + utils.getFormattedString(element));
+            buffer.append("' name='" + element.getLocalPart() + "'/>");
          }
 
          buffer.append("</operation>");
@@ -365,151 +320,95 @@
       }
    }
 
-   private boolean isHeaderInput(WSDLBindingOperationInput input)
-   {
-      WSDLBindingOperation operation = input.getWsdlBindingOperation();
-      WSDLBinding binding = operation.getWsdlBinding();
-      WSDLInterface wsdlInterface = binding.getInterface();
-      if (wsdlInterface == null)
-         return false;
-
-      WSDLInterfaceOperation interfaceOperation = wsdlInterface.getOperation(new NCName(operation.getRef().getLocalPart()));
-      if (interfaceOperation == null)
-         return false;
-
-      WSDLInterfaceOperationInput interfaceInput = interfaceOperation.getInputByPartName(input.getMessageLabel().toString());
-      if (interfaceInput == null)
-         return false;
-
-      if (interfaceInput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) == null)
-         return false;
-      else
-         return true;
-   }
-
-   private boolean isHeaderOutput(WSDLBindingOperationOutput output)
-   {
-      WSDLBindingOperation operation = output.getWsdlBindingOperation();
-      WSDLBinding binding = operation.getWsdlBinding();
-      WSDLInterface wsdlInterface = binding.getInterface();
-      if (wsdlInterface == null)
-         return false;
-
-      WSDLInterfaceOperation interfaceOperation = wsdlInterface.getOperation(new NCName(operation.getRef().getLocalPart()));
-      if (interfaceOperation == null)
-         return false;
-
-      WSDLInterfaceOperationOutput interfaceOutput = interfaceOperation.getOutputByPartName(output.getMessageLabel().toString());
-      if (interfaceOutput == null)
-         return false;
-
-      if (interfaceOutput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) == null)
-         return false;
-      else
-         return true;
-   }
-
    protected void appendBindingOperations(StringBuilder buffer, WSDLBinding binding)
    {
       WSDLBindingOperation[] operations = binding.getOperations();
       Arrays.sort(operations);
 
-      String tns = wsdl.getTargetNamespace();
       for (int i = 0; i < operations.length; i++)
       {
          WSDLBindingOperation operation = operations[i];
          String interfaceName = operation.getWsdlBinding().getInterfaceName().getLocalPart();
 
-         buffer.append("<operation name='" + operation.getRef().getLocalPart() + "'>");
+         WSDLInterface wsdlInterface = wsdl.getInterface(new NCName(interfaceName));
+         if (wsdlInterface == null)
+            throw new WSException("WSDL Interface should not be null");
+         WSDLInterfaceOperation interfaceOperation = wsdlInterface.getOperation(new NCName(operation.getRef().getLocalPart()));
+
+         buffer.append("<operation name='" + interfaceOperation.getName() + "'>");
          String soapAction = (operation.getSOAPAction() != null ? operation.getSOAPAction() : "");
          buffer.append("<" + soapPrefix + ":operation soapAction=\"" + soapAction + "\"/>");
-         buffer.append("<input>");
 
-         StringBuilder bodyParts = new StringBuilder();
-         boolean hasHeader = false;
          WSDLBindingOperationInput[] inputs = operation.getInputs();
-         for (int j = 0; j < inputs.length; j++)
-         {
-            WSDLBindingOperationInput input = inputs[j];
-            if (isHeaderInput(input))
-            {
-               String messageName = interfaceName + "_" + input.getWsdlBindingOperation().getRef().getLocalPart();
-               buffer.append("<" + soapPrefix + ":header use='literal' message='tns:" + messageName + "' part='" + input.getMessageLabel() + "'/>");
-               hasHeader = true;
-            }
-            else
-            {
-               if (bodyParts.length() > 0)
-                  bodyParts.append(" ");
-               bodyParts.append(input.getMessageLabel());
-            }
-         }
+         if (inputs.length != 1)
+            throw new WSException("SDl 1.1 only supports In-Only, and In-Out MEPS.");
 
-         buffer.append("<" + soapPrefix + ":body use='literal'");
-         if (hasHeader)
-            buffer.append(" parts='").append(bodyParts.toString()).append("'");
-         if (wsdlStyle != Constants.DOCUMENT_LITERAL)
-            buffer.append(" namespace='" + tns + "'");
-         buffer.append("/>");
-
+         buffer.append("<input>");
+         appendSOAPBinding(buffer, wsdlInterface, operation, inputs);
          buffer.append("</input>");
 
          if (! Constants.WSDL20_PATTERN_IN_ONLY.equals(getBindingOperationPattern(operation)))
          {
             buffer.append("<output>");
-            bodyParts = new StringBuilder();
-            hasHeader = false;
             WSDLBindingOperationOutput[] outputs = operation.getOutputs();
-            for (int j = 0; j < outputs.length; j++)
-            {
-               WSDLBindingOperationOutput output = outputs[j];
-               if (isHeaderOutput(output))
-               {
-                  String messageName = interfaceName + "_" + output.getWsdlBindingOperation().getRef().getLocalPart() + "Response";
+            appendSOAPBinding(buffer, wsdlInterface, operation, outputs);
+         }
 
-                  buffer.append("<" + soapPrefix + ":header use='literal' message='tns:" + messageName + "' part='" + output.getMessageLabel() + "'/>");
-                  hasHeader = true;
-               }
-               else
-               {
-                  if (bodyParts.length() > 0)
-                     bodyParts.append(" ");
-                  bodyParts.append(output.getMessageLabel());
-               }
+         //Append faults
+         WSDLInterfaceOperationOutfault[] faults = interfaceOperation.getOutfaults();
+         if (faults != null)
+         {
+            for (WSDLInterfaceOperationOutfault fault : faults)
+            {
+               String n = "name='" + fault.getRef().getLocalPart() + "'";
+               buffer.append("<fault  " + n + ">");
+               buffer.append("<" + soapPrefix + ":fault  " + n + " use='literal' />");
+               buffer.append("</fault>");
             }
+            buffer.append("</operation>");
+         }
+      }
+   }
 
-            buffer.append("<" + soapPrefix + ":body use='literal'");
-            if (hasHeader)
-               buffer.append(" parts='").append(bodyParts.toString()).append("'");
-            if (wsdlStyle != Constants.DOCUMENT_LITERAL)
-               buffer.append(" namespace='" + tns + "'");
-            buffer.append("/>");
+   private void appendSOAPBinding(StringBuilder buffer, WSDLInterface wsdlInterface, WSDLBindingOperation operation, WSDLBindingMessageReference[] inputs)
+   {
+      String tns = wsdl.getTargetNamespace();
+      WSDLInterfaceOperation interfaceOperation = wsdlInterface.getOperation(new NCName(operation.getRef().getLocalPart()));
+      WSDLInterfaceOperationInput input = interfaceOperation.getInputs()[0];
 
-            buffer.append("</output>");
+      StringBuilder bodyParts = new StringBuilder();
+      if (Constants.DOCUMENT_LITERAL != wsdlStyle)
+      {
+         bodyParts.append(input.getPartName());
+      }
+      else
+      {
+         for (WSDLRPCPart part : input.getChildParts())
+         {
+            if (bodyParts.length() > 0)
+               bodyParts.append(" ");
+            bodyParts.append(part);
          }
+      }
 
-         //Append faults
-         QName intfname = operation.getWsdlBinding().getInterfaceName();
-         WSDLInterface intf = wsdl.getInterface(new NCName(intfname.getLocalPart()));
-         if (intf == null)
-            throw new WSException("WSDL Interface should not be null");
-         WSDLInterfaceOperation interfaceOperation = intf.getOperation(new NCName(operation.getRef().getLocalPart()));
-         WSDLInterfaceOperationOutfault[] faults = interfaceOperation.getOutfaults();
-         int lenf = faults != null ? faults.length : 0;
-         for (int k = 0; k < lenf; k++)
+      StringBuilder soapHeader = new StringBuilder();
+      for (WSDLSOAPHeader header : inputs[0].getSoapHeaders())
+      {
+         if (header.isIncludeInSignature())
          {
-            WSDLInterfaceOperationOutfault flt = faults[k];
-            //Remove Fault or Error appended to the name
-            String cleanname = utils.chop(utils.chop(flt.getRef().getLocalPart(), "Error"), "Fault");
-            String n = "name='" + cleanname + "'";
-
-            //String cleanref = utils.chop(utils.getFormattedString(elt), "Error");
-            buffer.append("<fault  " + n + ">");
-            buffer.append("<" + soapPrefix + ":fault  " + n + " use='literal' />");
-            buffer.append("</fault>");
+            String messageName = wsdlInterface.getName() + "_" + operation.getRef().getLocalPart();
+            soapHeader.append("<").append(soapPrefix).append(":header use='literal' message='tns:").append(messageName);
+            soapHeader.append("' part='").append(header.getElement().getLocalPart()).append("'/>");
          }
+      }
 
-         buffer.append("</operation>");
+      buffer.append("<" + soapPrefix + ":body use='literal'");
+      if (wsdlStyle != Constants.DOCUMENT_LITERAL)
+         buffer.append(" namespace='" + tns + "'");
+      if (soapHeader.length() > 0)
+      {
+         buffer.append(" parts='").append(bodyParts).append("'");
+         buffer.append(soapHeader);
       }
    }
 
@@ -554,5 +453,4 @@
       buffer.append("<" + soapPrefix + ":address location='" + endpoint.getAddress() + "'/>");
       buffer.append("</port>");
    }
-
-}
+}
\ No newline at end of file

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -66,7 +66,7 @@
       {
          WSDLInterfaceFault fault = faults[i];
          buffer.append("<fault name='" + fault.getName() + "'");
-         buffer.append(" element='" + getQNameRef(fault.getXmlName()) + "'>");
+         buffer.append(" element='" + getQNameRef(fault.getElement()) + "'>");
          if (fault.getDocumentation() != null)
          {
             buffer.append(fault.getDocumentation());

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.metadata.wsdl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A Binding Message Reference component describes a concrete binding of a
+ * particular message participating in an operation to a particular concrete
+ * message format.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public abstract class WSDLBindingMessageReference
+{
+   // The parent WSDL binding operation
+   private WSDLBindingOperation wsdlBindingOperation;
+   private NCName messageLabel;
+   private List<WSDLSOAPHeader> soapHeaders = new ArrayList<WSDLSOAPHeader>();
+   private List<WSDLMIMEPart> mimeParts = new ArrayList<WSDLMIMEPart>();
+
+   public WSDLBindingMessageReference(WSDLBindingOperation wsdlBindingOperation)
+   {
+      this.wsdlBindingOperation = wsdlBindingOperation;
+   }
+
+   public WSDLBindingOperation getWsdlBindingOperation()
+   {
+      return wsdlBindingOperation;
+   }
+
+   /**
+    * Gets the property that identifies the role that the message for which
+    * binding details are being specified. The role is part of the {message
+    * exchange pattern} of the Interface Operation component being bound by the
+    * containing Binding Operation component.
+    */
+   public NCName getMessageLabel()
+   {
+      return messageLabel;
+   }
+
+   /**
+    * Sets the property that identifies the role that the message for which
+    * binding details are being specified. The role is part of the {message
+    * exchange pattern} of the Interface Operation component being bound by the
+    * containing Binding Operation component.
+    */
+   public void setMessageLabel(NCName messageLabel)
+   {
+      this.messageLabel = messageLabel;
+   }
+
+   /**
+    * Gets the list of SOAP headers associated with this message reference.
+    *
+    * @return a list of soap headers
+    */
+   public List<WSDLSOAPHeader> getSoapHeaders()
+   {
+      return soapHeaders;
+   }
+
+   /**
+    * Sets the list of SOAP headers associated with this message reference.
+    *
+    * @param soapHeaders The soapHeaders to set.
+    */
+   public void setSoapHeaders(List<WSDLSOAPHeader> soapHeaders)
+   {
+      this.soapHeaders = soapHeaders;
+   }
+
+   /**
+    * Adds a SOAP header to the SOAP header list that is associated with this
+    * message reference.
+    *
+    * @param soapHeader the SOAP header to add
+    */
+   public void addSoapHeader(WSDLSOAPHeader soapHeader)
+   {
+      this.soapHeaders.add(soapHeader);
+   }
+
+   /**
+    * Adds a MIME part to this message reference. This is only used for WSDL 1.1.
+    *
+    * @param mimePart the mime part to add
+    */
+   public void addMimePart(WSDLMIMEPart mimePart)
+   {
+      this.mimeParts.add(mimePart);
+   }
+
+   /**
+    * Returns a list of mime parts on this message
+    *
+    * @return
+    */
+   public Collection<WSDLMIMEPart> getMimeParts()
+   {
+      return mimeParts;
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -23,46 +23,22 @@
 
 import java.io.Serializable;
 
-
 // $Id$
 
-
 /**
  * A Binding Message Reference component describes a concrete binding of a particular message
  * participating in an operation to a particular concrete message format.
  *
  * @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
  * @since 10-Oct-2004
  */
-public class WSDLBindingOperationInput implements Serializable
+public class WSDLBindingOperationInput extends WSDLBindingMessageReference implements Serializable
 {
    private static final long serialVersionUID = -3945310906418557565L;
 
-   // The parent WSDL binding operation
-   private WSDLBindingOperation wsdlBindingOperation;
-
-   /** The OPTIONAL value of this property identifies the role that the message for which
-    * binding details are being specified plays in the {message exchange pattern} of the
-    * Interface Operation component being bound by the containing Binding Operation component.*/
-   private NCName messageLabel;
-
    public WSDLBindingOperationInput(WSDLBindingOperation wsdlBindingOperation)
    {
-      this.wsdlBindingOperation = wsdlBindingOperation;
+      super(wsdlBindingOperation);
    }
-
-   public WSDLBindingOperation getWsdlBindingOperation()
-   {
-      return wsdlBindingOperation;
-   }
-
-   public NCName getMessageLabel()
-   {
-      return messageLabel;
-   }
-
-   public void setMessageLabel(NCName messageLabel)
-   {
-      this.messageLabel = messageLabel;
-   }
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -23,46 +23,22 @@
 
 import java.io.Serializable;
 
-
 // $Id$
 
-
 /**
  * A Binding Message Reference component describes a concrete binding of a particular message
  * participating in an operation to a particular concrete message format.
  *
  * @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
  * @since 10-Oct-2004
  */
-public class WSDLBindingOperationOutput implements Serializable
+public class WSDLBindingOperationOutput extends WSDLBindingMessageReference implements Serializable
 {
-   private static final long serialVersionUID = -988199387765793475L;
+   private static final long serialVersionUID = -999199387765793475L;
 
-   // The parent WSDL binding operation
-   private WSDLBindingOperation wsdlBindingOperation;
-
-   /** The OPTIONAL value of this property identifies the role that the message for which
-    * binding details are being specified plays in the {message exchange pattern} of the
-    * Interface Operation component being bound by the containing Binding Operation component.*/
-   private NCName messageLabel;
-
    public WSDLBindingOperationOutput(WSDLBindingOperation wsdlBindingOperation)
    {
-      this.wsdlBindingOperation = wsdlBindingOperation;
+      super(wsdlBindingOperation);
    }
-
-   public WSDLBindingOperation getWsdlBindingOperation()
-   {
-      return wsdlBindingOperation;
-   }
-
-   public NCName getMessageLabel()
-   {
-      return messageLabel;
-   }
-
-   public void setMessageLabel(NCName messageLabel)
-   {
-      this.messageLabel = messageLabel;
-   }
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -51,12 +51,8 @@
    private NCName name;
    /** The OPTIONAL element attribute information item refers, by QName, to an element declaration component.
     */
-   private QName xmlName;
+   private QName element;
 
-   /** Derived XML type identifier. 
-    */
-   private QName xmlType;
-   
    protected WSDLDocumentation documentationElement = null;
 
    public WSDLInterfaceFault(WSDLInterface wsdlInterface)
@@ -79,14 +75,14 @@
       this.name = name;
    }
 
-   public QName getXmlName()
+   public QName getElement()
    {
-      return xmlName;
+      return element;
    }
 
-   public void setXmlName(QName qname)
+   public void setElement(QName element)
    {
-      this.xmlName = qname;
+      this.element = element;
    }
 
    public WSDLDocumentation getDocumentation()
@@ -103,21 +99,8 @@
     */
    public QName getXmlType()
    {
-      if (xmlType == null && xmlName != null)
-      {
-         WSDLDefinitions wsdlDefinitions = wsdlInterface.getWsdlDefinitions();
-         WSDLTypes wsdlTypes = wsdlDefinitions.getWsdlTypes();
-         xmlType = wsdlTypes.getXMLType(xmlName);
-      }
-
-      if (xmlType == null)
-         throw new WSException("Cannot obtain xmlType for fault: " + xmlName);
-
-      return xmlType;
+      WSDLDefinitions wsdlDefinitions = wsdlInterface.getWsdlDefinitions();
+      WSDLTypes wsdlTypes = wsdlDefinitions.getWsdlTypes();
+      return wsdlTypes.getXMLType(element);
    }
-
-   public void setXmlType(QName xmlType)
-   {
-      this.xmlType = xmlType;
-   }
 }

Copied: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceMessageReference.java (from rev 642, trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java	2006-07-26 17:32:24 UTC (rev 642)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceMessageReference.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.metadata.wsdl;
+
+// $Id: WSDLInterfaceOperationPart.java 275 2006-05-04 21:36:29Z
+// jason.greene at jboss.com $
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+
+/**
+ * A Message Reference component associates a defined type with a message
+ * exchanged in an operation. By default, the type system is based upon the XML
+ * Infoset
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @since 10-Oct-2004
+ */
+public abstract class WSDLInterfaceMessageReference extends Extendable implements Comparable
+{
+   // provide logging
+   protected Logger log = Logger.getLogger(getClass());
+
+   // The parent interface operation
+   private WSDLInterfaceOperation wsdlOperation;
+
+   /**
+    * The OPTIONAL messageLabel attribute information item identifies the role
+    * of this message in the message exchange pattern of the given operation
+    * element information item.
+    */
+   private NCName messageLabel;
+
+   /**
+    * The OPTIONAL element attribute information item is the element declaration
+    * from the {element declarations} property resolved by the value of the
+    * element attribute information item, otherwise empty.
+    */
+   private QName element;
+
+   /**
+    * Used mainly for WSDL 1.1 compatibility, indicates rpc parts.
+    * Although, this could be used to represent WSDL 2.0 RPC style.
+    */
+   private LinkedHashMap<String, WSDLRPCPart> childParts = new LinkedHashMap<String, WSDLRPCPart>();
+
+   /**
+    * Used for WSDL 1.1 style
+    */
+   private String partName;
+
+   public WSDLInterfaceMessageReference(WSDLInterfaceOperation wsdlOperation)
+   {
+      log.trace("New part for wsdlOperation: " + wsdlOperation.getName());
+      this.wsdlOperation = wsdlOperation;
+   }
+
+   public WSDLInterfaceOperation getWsdlOperation()
+   {
+      return wsdlOperation;
+   }
+
+   public NCName getMessageLabel()
+   {
+      return messageLabel;
+   }
+
+   public void setMessageLabel(NCName messageLabel)
+   {
+      log.trace("setMessageLabel: " + messageLabel);
+      this.messageLabel = messageLabel;
+   }
+
+   public QName getElement()
+   {
+      return element;
+   }
+
+   public void setElement(QName element)
+   {
+      log.trace("setElement: " + element);
+      this.element = element;
+   }
+
+   /**
+    * Get the xmlType for this operation part.
+    */
+   public QName getXMLType()
+   {
+      QName xmlType = null;
+
+      // First try to read it from the schema
+      WSDLDefinitions wsdlDefinitions = wsdlOperation.getWsdlInterface().getWsdlDefinitions();
+      WSDLTypes wsdlTypes = wsdlDefinitions.getWsdlTypes();
+      xmlType = wsdlTypes.getXMLType(element);
+
+      // Fall back to the property
+      if (xmlType == null)
+      {
+         WSDLProperty property = getProperty(Constants.WSDL_PROPERTY_RPC_XMLTYPE);
+         if (property != null)
+         {
+            String qnameRef = property.getValue();
+            int colIndex = qnameRef.indexOf(':');
+            String prefix = qnameRef.substring(0, colIndex);
+            String localPart = qnameRef.substring(colIndex + 1);
+            String nsURI = wsdlDefinitions.getNamespaceURI(prefix);
+            xmlType = new QName(nsURI, localPart, prefix);
+         }
+      }
+
+      if (xmlType == null)
+         throw new WSException("Cannot obtain xmlType for element: " + element);
+
+      return xmlType;
+   }
+
+   /**
+    * Gets the child parts associated with this message reference. This is only
+    * used for RPC style, and currently only supported by WSDL 1.1.
+    *
+    * @return the list of rpc parts that make up the message
+    */
+   public Collection<WSDLRPCPart> getChildParts()
+   {
+      return childParts.values();
+   }
+
+   /**
+    * Adds a child part to this mesage reference. This is only used for RPC
+    * style, and currently only supported by WSDL 1.1.
+    *
+    * @param childPart the list of rpc parts that make up the message
+    */
+   public void addChildPart(WSDLRPCPart childPart)
+   {
+      this.childParts.put(childPart.getName(), childPart);
+   }
+
+   /**
+    * Removes a speficied child part. This is This is only used for RPC
+    * style, and currently only supported by WSDL 1.1.
+    *
+    * @param name the name of the part
+    */
+   public void removeChildPart(String name)
+   {
+      this.childParts.remove(name);
+   }
+
+   /**
+    * Gets the WSDL 1.1 part name.
+    *
+    * @return the part name
+    */
+   public String getPartName()
+   {
+      return partName;
+   }
+
+   /**
+    * Sets the WSDL 1.1 part name.
+    *
+    * @param partName The part name
+    */
+   public void setPartName(String partName)
+   {
+      this.partName = partName;
+   }
+
+
+   public int compareTo(Object o)
+   {
+      int c = -1;
+      if (o instanceof WSDLInterfaceMessageReference)
+      {
+         WSDLInterfaceMessageReference w = (WSDLInterfaceMessageReference) o;
+         String oname = w.getElement().getLocalPart();
+         String myname = getElement().getLocalPart();
+         c = myname.compareTo(oname);
+      }
+      return c;
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceMessageReference.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -22,6 +22,7 @@
 package org.jboss.ws.metadata.wsdl;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -76,6 +77,8 @@
    private ArrayList<WSDLInterfaceOperationInfault> infaults = new ArrayList<WSDLInterfaceOperationInfault>();
    /** Zero or more outfault element information items */
    private ArrayList<WSDLInterfaceOperationOutfault> outfaults = new ArrayList<WSDLInterfaceOperationOutfault>();
+   /** Zero or more signature items */
+   private LinkedHashMap<String, WSDLRPCSignatureItem> rpcSignatureItems = new LinkedHashMap<String, WSDLRPCSignatureItem>();
 
    public WSDLInterfaceOperation(WSDLInterface wsdlInterface)
    {
@@ -102,7 +105,7 @@
       String nsURI = wsdlInterface.getQName().getNamespaceURI();
       return new QName(nsURI, name.toString());
    }
-   
+
    public String getPattern()
    {
       return pattern;
@@ -156,6 +159,11 @@
       return opInput;
    }
 
+   public void removeInput(QName element)
+   {
+      inputs.remove(element);
+   }
+
    public WSDLInterfaceOperationInput getInputByPartName(String partName)
    {
       WSDLInterfaceOperationInput opInput = null;
@@ -227,6 +235,42 @@
       outfaults.add(outfault);
    }
 
+   public Collection<WSDLRPCSignatureItem> getRpcSignatureItems()
+   {
+      return rpcSignatureItems.values();
+   }
+
+
+   public void addRpcSignatureItem(WSDLRPCSignatureItem item)
+   {
+      rpcSignatureItems.put(item.getName(), item);
+      item.setPosition(rpcSignatureItems.size());
+   }
+
+   public WSDLRPCSignatureItem getRpcSignatureitem(String name)
+   {
+      return rpcSignatureItems.get(name);
+   }
+
+   /**
+    * Attempts to locate a binding operation for this interface operation.
+    *
+    * @return the binding operation, or null if not found;
+    */
+   public WSDLBindingOperation getBindingOperation()
+   {
+      WSDLInterface wsdlInterface = getWsdlInterface();
+      WSDLBinding binding = wsdlInterface.getWsdlDefinitions().getBindingByInterfaceName(wsdlInterface.getQName());
+      if (binding == null)
+         return null;
+
+      WSDLBindingOperation bindingOperation = binding.getOperationByRef(getQName());
+      if (bindingOperation == null)
+         return null;
+
+      return bindingOperation;
+   }
+
    public int compareTo(Object o)
    {
       int c = -1;

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -30,7 +30,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 10-Oct-2004
  */
-public class WSDLInterfaceOperationInput extends WSDLInterfaceOperationPart
+public class WSDLInterfaceOperationInput extends WSDLInterfaceMessageReference
 {
    private static final long serialVersionUID = -4691488323709300920L;
 

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -30,7 +30,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 10-Oct-2004
  */
-public class WSDLInterfaceOperationOutput extends WSDLInterfaceOperationPart
+public class WSDLInterfaceOperationOutput extends WSDLInterfaceMessageReference
 {
    private static final long serialVersionUID = 5096501821825901473L;
 

Deleted: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -1,134 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.metadata.wsdl;
-
-// $Id$
-
-import javax.xml.namespace.QName;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.Constants;
-import org.jboss.ws.WSException;
-
-/**
- * A Message Reference component associates a defined type with a message exchanged in an operation. By
- * default, the type system is based upon the XML Infoset
- *
- * @author Thomas.Diesler at jboss.org
- * @since 10-Oct-2004
- */
-public abstract class WSDLInterfaceOperationPart extends Extendable implements Comparable
-{
-   // provide logging
-   protected Logger log = Logger.getLogger(getClass());
-
-   // The parent interface operation
-   private WSDLInterfaceOperation wsdlOperation;
-
-   /** The OPTIONAL messageLabel attribute information item identifies the role of this message in the message
-    * exchange pattern of the given operation element information item.
-    */
-   private NCName messageLabel;
-
-   /** The OPTIONAL element attribute information item is the element declaration from the {element declarations}
-    * property resolved by the value of the element attribute information item, otherwise empty.
-    */
-   private QName element;
-
-   public WSDLInterfaceOperationPart(WSDLInterfaceOperation wsdlOperation)
-   {
-      log.trace("New part for wsdlOperation: " + wsdlOperation.getName());
-      this.wsdlOperation = wsdlOperation;
-   }
-
-   public WSDLInterfaceOperation getWsdlOperation()
-   {
-      return wsdlOperation;
-   }
-
-   public NCName getMessageLabel()
-   {
-      return messageLabel;
-   }
-
-   public void setMessageLabel(NCName messageLabel)
-   {
-      log.trace("setMessageLabel: " + messageLabel);
-      this.messageLabel = messageLabel;
-   }
-
-   public QName getElement()
-   {
-      return element;
-   }
-
-   public void setElement(QName element)
-   {
-      log.trace("setElement: " + element);
-      this.element = element;
-   }
-
-   /** Get the xmlType for this operation part.
-    */
-   public QName getXMLType()
-   {
-      QName xmlType = null;
-
-      // First try to read it from the schema
-      WSDLDefinitions wsdlDefinitions = wsdlOperation.getWsdlInterface().getWsdlDefinitions();
-      WSDLTypes wsdlTypes = wsdlDefinitions.getWsdlTypes();
-      xmlType = wsdlTypes.getXMLType(element);
-
-      // Fall back to the property
-      if (xmlType == null)
-      {
-         WSDLProperty property = getProperty(Constants.WSDL_PROPERTY_RPC_XMLTYPE);
-         if (property != null)
-         {
-            String qnameRef = property.getValue();
-            int colIndex = qnameRef.indexOf(':');
-            String prefix = qnameRef.substring(0, colIndex);
-            String localPart = qnameRef.substring(colIndex + 1);
-            String nsURI = wsdlDefinitions.getNamespaceURI(prefix);
-            xmlType = new QName(nsURI, localPart, prefix);
-         }
-      }
-
-      if (xmlType == null)
-         throw new WSException("Cannot obtain xmlType for element: " + element);
-
-      return xmlType;
-   }
-
-   public int compareTo(Object o)
-   {
-      int c = -1;
-      if (o instanceof WSDLInterfaceOperationPart)
-      {
-         WSDLInterfaceOperationPart w = (WSDLInterfaceOperationPart)o;
-         String oname = w.getElement().getLocalPart();
-         String myname = getElement().getLocalPart();
-         c = myname.compareTo(oname);
-      }
-      return c;
-   }
-}
\ No newline at end of file

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.metadata.wsdl;
+
+import java.io.Serializable;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a WSDL 1.1 MIME Multipart attachment.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class WSDLMIMEPart implements Serializable
+{
+   private static final long serialVersionUID = -3102495235178249853L;
+
+   private final String partName;
+   private final QName xmlType;
+   private final String mimeTypes;
+
+   public WSDLMIMEPart(String partName, QName xmlType, String mimeTypes)
+   {
+      this.mimeTypes = mimeTypes;
+      this.partName = partName;
+      this.xmlType = xmlType;
+   }
+
+   /**
+    * Returns the xml type of this attachment. Typically xsd:hexBinary
+    *
+    * @return the name of the header schema element
+    */
+   public QName getXmlType()
+   {
+      return xmlType;
+   }
+
+   /**
+    * Returns the name of the WSDL 1.1 part, if the output is WSDL 1.1
+    *
+    * @return the name of the part
+    */
+   public String getPartName()
+   {
+      return partName;
+   }
+
+   /**
+    * Returns a comma seperated list of allowed mime types.
+    *
+    * @return the mime types
+    */
+   public String getMimeTypes()
+   {
+      return mimeTypes;
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.metadata.wsdl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a child part of a RPC style message reference. This is currently
+ * only used for WSDL 1.1 compatibility.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class WSDLRPCPart
+{
+   private final String name;
+   private final QName type;
+
+   public WSDLRPCPart(String name, QName type)
+   {
+      this.name = name;
+      this.type = type;
+   }
+
+   /**
+    * Gets the XML local name of this part.
+    *
+    * @return the XML local name
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Gets the XML type of this part.
+    *
+    * @return the XML type
+    */
+   public QName getType()
+   {
+      return type;
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ws.metadata.wsdl;
+
+
+/**
+ * Represents an individual item of a wrpc:signature
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class WSDLRPCSignatureItem
+{
+   public enum Direction {IN, OUT, INOUT, RETURN};
+
+   private Direction direction;
+   private final String name;
+   private int position;
+
+   public WSDLRPCSignatureItem(String name)
+   {
+      this.name = name;
+      this.direction = Direction.IN;
+   }
+
+   public WSDLRPCSignatureItem(String name, Direction direction)
+   {
+      this.direction = direction;
+      this.name = name;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public Direction getDirection()
+   {
+      return direction;
+   }
+
+   public void setDirection(Direction direction)
+   {
+      this.direction = direction;
+   }
+
+   public void setPosition(int position)
+   {
+      this.position = position;
+   }
+
+   public int getPosition()
+   {
+      return position;
+   }
+}


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.metadata.wsdl;
+
+import java.io.Serializable;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a WSDL 2.0 SOAP Header Block. The presence of the SOAP Header
+ * Block component indicates that the service supports headers and MAY require a
+ * web service consumer/client to use the header. It may appear up to one time
+ * in the message.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class WSDLSOAPHeader implements Serializable
+{
+   private static final long serialVersionUID = -3102495235178249853L;
+
+   private final QName element;
+   private final String partName;
+   private boolean required = false;
+   private boolean mustUnderstand = false;
+   private boolean includeInSignature = false;
+
+   public WSDLSOAPHeader(QName element, String partName)
+   {
+      this.element = element;
+      this.partName = partName;
+   }
+
+   /**
+    * Returns the name of the header schema element that describes the header's
+    * contents.
+    *
+    * @return the name of the header schema element
+    */
+   public QName getElement()
+   {
+      return element;
+   }
+
+   /**
+    * Returns the name of the WSDL 1.1 part, if the output is WSDL 1.1
+    *
+    * @return the name of the part
+    */
+   public String getPartName()
+   {
+      return partName;
+   }
+
+   /**
+    * Indicates whether the resulting SOAP header has a mustUnderstand attribute
+    * set to true.
+    *
+    * @return the value of the SOAP mustUnderstand attribute
+    */
+   public boolean isMustUnderstand()
+   {
+      return mustUnderstand;
+   }
+
+   /**
+    * Specifies whether the resulting SOAP Header has a mustUnderstand attribute
+    * set to true.
+    *
+    * @param mustUnderstand the value of the SOAP mustUnderstand attribute
+    */
+   public void setMustUnderstand(boolean mustUnderstand)
+   {
+      this.mustUnderstand = mustUnderstand;
+   }
+
+   /**
+    * Indicates whether the resulting SOAP header must be present in the
+    * message.
+    *
+    * @return true if the header must be present, otherwise false
+    */
+   public boolean isRequired()
+   {
+      return required;
+   }
+
+   /**
+    * Specifies whether the resulting SOAP header is required to be present on
+    * the message.
+    *
+    * @param required true if the header must be present, otherwise false
+    */
+   public void setRequired(boolean required)
+   {
+      this.required = required;
+   }
+
+   /**
+    * Indicates the resulting WSDL should include this header as part of the
+    * interface message. This is currently only valid for WSDL 1.1, as WSDL 2.0
+    * does not have an equivalent way to specify this. This serves as a hint to
+    * binding tools that the header should be mapped to a Java parameter.
+    *
+    * @return whether the header should be part of the interface message
+    */
+   public boolean isIncludeInSignature()
+   {
+      return includeInSignature;
+   }
+
+   /**
+    * Speficies the resulting WSDL should include this header as part of the
+    * interface message. This is currently only valid for WSDL 1.1, as WSDL 2.0
+    * does not have an equivalent way to specify this. This serves as a hint to
+    * binding tools that the header should be mapped to a Java parameter.
+    *
+    * @param includeInSignature whether the header should be part of the
+    * interface message
+    */
+   public void setIncludeInSignature(boolean includeInSignature)
+   {
+      this.includeInSignature = includeInSignature;
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/server/MessageContextInjector.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/MessageContextInjector.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/server/MessageContextInjector.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -21,7 +21,7 @@
  */
 package org.jboss.ws.server;
 
-// $Id: $
+// $Id$
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/server/ServletHeaderSource.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/ServletHeaderSource.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/server/ServletHeaderSource.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -21,7 +21,7 @@
  */
 package org.jboss.ws.server;
 
-// $Id: $
+// $Id$
 
 import java.util.ArrayList;
 import java.util.Enumeration;

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools;
+
+import java.util.List;
+import java.util.SortedMap;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.ws.jaxws.WrapperGenerator;
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.metadata.ParameterMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
+import org.jboss.ws.utils.JavaUtils;
+
+import com.sun.codemodel.JAnnotationArrayMember;
+import com.sun.codemodel.JAnnotationUse;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JFieldVar;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+
+/**
+ * Generates source for wrapper beans
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class SourceWrapperGenerator extends WrapperGenerator
+{
+
+   private static Logger log = Logger.getLogger(SourceWrapperGenerator.class);
+   private JCodeModel codeModel = new JCodeModel();
+
+   public SourceWrapperGenerator(ClassLoader loader)
+   {
+      super(loader);
+   }
+
+   public void generate(ParameterMetaData pmd)
+   {
+      List<WrappedParameter> wrappedParameters = pmd.getWrappedParameters();
+      OperationMetaData operationMetaData = pmd.getOperationMetaData();
+
+      if (operationMetaData.isDocumentWrapped() == false)
+         throw new WSException("Operation is not document/literal (wrapped)");
+
+      if (wrappedParameters == null)
+         throw new WSException("Cannot generate a type when their is no type information");
+
+      String wrapperName = pmd.getJavaTypeName();
+      if (log.isDebugEnabled())
+         log.debug("Generating wrapper: " + wrapperName);
+
+      try
+      {
+
+         JDefinedClass clazz = codeModel._class(wrapperName);
+         addClassAnnotations(clazz, pmd.getXmlName(), pmd.getXmlType(), null);
+         for (WrappedParameter wrapped : wrappedParameters)
+         {
+            addProperty(clazz, wrapped.type, wrapped.name, wrapped.variable);
+         }
+      }
+      catch (Exception e)
+      {
+         throw new WSException("Could not generate wrapper type: " + wrapperName, e);
+      }
+   }
+   public void generate(FaultMetaData fmd)
+   {
+      String faultBeanName = fmd.getFaultBeanName();
+      Class exception = fmd.getJavaType();
+
+      try
+      {
+         SortedMap<String, Class<?>> properties = getExceptionProperties(exception);
+         String[] propertyOrder = properties.keySet().toArray(new String[0]);
+
+         JDefinedClass clazz = codeModel._class(faultBeanName);
+         addClassAnnotations(clazz, fmd.getXmlName(), fmd.getXmlType(), propertyOrder);
+
+         for (String property : propertyOrder)
+            addProperty(clazz, properties.get(property).getName(), new QName(property), property);
+      }
+      catch (Exception e)
+      {
+         throw new WSException("Could not generate wrapper type: " + faultBeanName, e);
+      }
+   }
+
+   private static String getterPrefix(Class type)
+   {
+      return Boolean.TYPE == type || Boolean.class == type ? "is" : "get";
+   }
+
+   private void addProperty(JDefinedClass clazz, String typeName, QName name, String variable)
+         throws ClassNotFoundException
+   {
+      Class type = JavaUtils.loadJavaType(typeName, loader);
+      JFieldVar field = clazz.field(JMod.PRIVATE, type, variable);
+      JAnnotationUse annotation = field.annotate(XmlElement.class);
+      if (name.getNamespaceURI() != null)
+         annotation.param("namespace", name.getNamespaceURI());
+      annotation.param("name", name.getLocalPart());
+
+      // Add acessor methods
+      JMethod method = clazz.method(JMod.PUBLIC, type, getterPrefix(type) + JavaUtils.capitalize(variable));
+      method.body()._return(JExpr._this().ref(variable));
+
+      method = clazz.method(JMod.PUBLIC, type, "set" + JavaUtils.capitalize(variable));
+      method.body().assign(JExpr._this().ref(variable), method.param(type, variable));
+   }
+
+   private static void addClassAnnotations(JDefinedClass clazz, QName xmlName, QName xmlType, String[] propertyOrder)
+   {
+      JAnnotationUse annotation = clazz.annotate(XmlRootElement.class);
+      if (xmlName.getNamespaceURI() != null && xmlName.getNamespaceURI().length() > 0)
+         annotation.param("namespace", xmlName.getNamespaceURI());
+      annotation.param("name", xmlName.getLocalPart());
+
+      annotation = clazz.annotate(XmlType.class);
+      if (xmlType.getNamespaceURI() != null & xmlType.getNamespaceURI().length() > 0)
+         annotation.param("namespace", xmlType.getNamespaceURI());
+      annotation.param("name", xmlType.getLocalPart());
+      if (propertyOrder != null)
+      {
+         JAnnotationArrayMember paramArray = annotation.paramArray("propOrder");
+         for (String property : propertyOrder)
+            paramArray.param(property);
+      }
+
+      annotation = clazz.annotate(XmlAccessorType.class);
+      annotation.param("value", XmlAccessType.FIELD);
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -355,7 +355,7 @@
       return null;
    }
 
-   private void appendMethods(WSDLInterface intf, StringBuilder buf ) throws IOException
+   private void appendMethods(WSDLInterface intf, StringBuilder buf) throws IOException
    {
       buf.append(newline);
       String itfname = intf.getName().toString();
@@ -439,7 +439,7 @@
             //Get the main fault from the wsdlInterface
             WSDLInterfaceFault intfFault = fault.getWsdlInterfaceOperation().getWsdlInterface().getFault(new NCName(faultqname.getLocalPart()));
             JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
-            QName faultXMLName = intfFault.getXmlName();
+            QName faultXMLName = intfFault.getElement();
             QName faultXMLType = intfFault.getXmlType();
 
             XSElementDeclaration xe = xsmodel.getElementDeclaration(faultXMLName.getLocalPart(),faultXMLName.getNamespaceURI());

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -47,6 +47,7 @@
 import org.jboss.ws.metadata.FaultMetaData;
 import org.jboss.ws.metadata.OperationMetaData;
 import org.jboss.ws.metadata.ParameterMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.jaxrpcmapping.ExceptionMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaXmlTypeMapping;
@@ -84,6 +85,7 @@
 import org.jboss.ws.tools.JavaToXSD;
 import org.jboss.ws.tools.interfaces.JavaToXSDIntf;
 import org.jboss.ws.tools.interfaces.SchemaCreatorIntf;
+import org.jboss.ws.tools.jaxws.WSDLGenerator;
 import org.jboss.ws.utils.JavaUtils;
 
 /**
@@ -91,7 +93,7 @@
  *  @author <mailto:Anil.Saldhana at jboss.org>Anil Saldhana
  *  @since  Oct 7, 2005
  */
-public class JavaToWSDLHelper
+public class JavaToWSDLHelper extends WSDLGenerator
 {
    protected WSDLDefinitions wsdl = null;
 
@@ -156,21 +158,16 @@
 
    private Map<String, QName> buildElementNameMap(ParameterMetaData pmd)
    {
-      List<QName> elements = pmd.getWrappedElementNames();
-      List<String> variables = pmd.getWrappedVariables();
+      List<WrappedParameter> wrappedParameters = pmd.getWrappedParameters();
 
-      if (elements == null || variables == null)
+      if (wrappedParameters == null)
          return null;
 
-      if (elements.size() != variables.size())
-         return null;
+      Map<String, QName> map = new LinkedHashMap<String, QName>(wrappedParameters.size());
 
-      Map<String, QName> map = new LinkedHashMap<String, QName>(elements.size());
+      for (WrappedParameter param : wrappedParameters)
+         map.put(param.variable, param.name);
 
-      int i = 0;
-      for (String variable : variables)
-         map.put(variable, elements.get(i++));
-
       return map;
    }
 
@@ -400,12 +397,11 @@
          {
             if (isWrapped && param.isInHeader() == false)
             {
-               List<String> wrappedTypes = param.getWrappedTypes();
-               List<QName> wrappedElementNames = param.getWrappedElementNames();
-               for (int c = 0; c < wrappedTypes.size(); c++)
+               List<WrappedParameter> wrappedParameters = param.getWrappedParameters();
+               for (WrappedParameter wrapped : wrappedParameters)
                {
-                  String type = JavaUtils.convertJVMNameToSourceName(wrappedTypes.get(c), endpoint.getClassLoader());
-                  String name = wrappedElementNames.get(c).getLocalPart();
+                  String type = JavaUtils.convertJVMNameToSourceName(wrapped.type, endpoint.getClassLoader());
+                  String name = wrapped.name.getLocalPart();
 
                   buildParamMapping(methodMapping, interfaceName, operation, name, type, "IN", false, i++);
                }
@@ -419,13 +415,14 @@
          }
 
          ParameterMetaData returnParam = operation.getReturnParameter();
-         if (returnParam != null && ((! isWrapped) || (! returnParam.getWrappedElementNames().isEmpty())))
+         if (returnParam != null && ((! isWrapped) || (! returnParam.getWrappedParameters().isEmpty())))
          {
             String name, type;
             if (isWrapped)
             {
-               name = returnParam.getWrappedElementNames().get(0).getLocalPart();
-               type = returnParam.getWrappedTypes().get(0);
+               WrappedParameter wrappedParameter = returnParam.getWrappedParameters().get(0);
+               name = wrappedParameter.name.getLocalPart();
+               type = wrappedParameter.type;
             }
             else
             {
@@ -741,7 +738,7 @@
          //Add the fault to the interface
          fault = new WSDLInterfaceFault(wsdlInterface);
          fault.setName(new NCName(xmlName.getLocalPart()));
-         fault.setXmlName(xmlName);
+         fault.setElement(xmlName);
          wsdlInterface.addFault(fault);
       }
 

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -68,7 +68,7 @@
 import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
 import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput;
 import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
-import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationPart;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceMessageReference;
 import org.jboss.ws.metadata.wsdl.WSDLProperty;
 import org.jboss.ws.metadata.wsdl.WSDLService;
 import org.jboss.ws.metadata.wsdl.WSDLTypes;
@@ -367,7 +367,7 @@
             for (WSDLInterfaceFault fault : wi.getFaults())
             {
                QName xmlType = fault.getXmlType();
-               QName xmlName = fault.getXmlName();
+               QName xmlName = fault.getElement();
 
                WSDLTypes types = wsdlDefinitions.getWsdlTypes();
                JBossXSModel xsmodel = WSDLUtils.getSchemaModel(types);
@@ -487,7 +487,7 @@
          throw new WSException("typeMapping is null");
    }
 
-   private XSTypeDefinition getXSType(WSDLInterfaceOperationPart part)
+   private XSTypeDefinition getXSType(WSDLInterfaceMessageReference part)
    {
       //Check if there are any custom properties
       WSDLInterfaceOperation op  = part.getWsdlOperation();

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -47,6 +47,7 @@
 import org.jboss.ws.metadata.ParameterMetaData;
 import org.jboss.ws.metadata.ServiceMetaData;
 import org.jboss.ws.metadata.UnifiedMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaXmlTypeMapping;
 import org.jboss.ws.metadata.wsdl.NCName;
@@ -234,17 +235,16 @@
    private void createWrapperType(ParameterMetaData parameter, String name, String packageName, Map<QName, JavaXmlTypeMapping> mappingIndex, ClassLoader classLoader,
          String outDir) throws IOException
    {
-      List<String> wrappedVariables = parameter.getWrappedVariables();
+      List<WrappedParameter> wrappedParameters = parameter.getWrappedParameters();
 
-      if (wrappedVariables == null)
+      if (wrappedParameters == null)
          return;
 
       List<VAR> vars = new ArrayList<VAR>();
-      List<String> wrappedTypes = parameter.getWrappedTypes();
-      for (int i = 0; i < wrappedVariables.size(); i++)
+      for (WrappedParameter wrapped : wrappedParameters)
       {
-         String typeName = JavaUtils.convertJVMNameToSourceName(wrappedTypes.get(i), classLoader);
-         vars.add(new VAR(wrappedVariables.get(i), typeName, false));
+         String typeName = JavaUtils.convertJVMNameToSourceName(wrapped.type, classLoader);
+         vars.add(new VAR(wrapped.variable, typeName, false));
       }
 
       JavaWriter writer = new JavaWriter();

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ws.tools.jaxws;
+
+import java.io.IOException;
+
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.metadata.ServiceMetaData;
+import org.jboss.ws.metadata.wsdl.DOMTypes;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.sun.xml.bind.api.JAXBRIContext;
+
+
+public class JAXBWSDLGenerator extends WSDLGenerator
+{
+
+   protected void processTypes(JAXBRIContext ctx)
+   {
+      // Register namespaces
+      for (String ns : ctx.getKnownNamespaceURIs())
+         if (ns.length() > 0)
+            wsdl.registerNamespaceURI(ns, null);
+
+      try
+      {
+         DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+         Document doc = builder.newDocument();
+         DOMTypes types = new DOMTypes(doc);
+         final Element element = types.getElement();
+
+         ctx.generateSchema(new SchemaOutputResolver()
+         {
+            @Override
+            public Result createOutput(String namespace, String file) throws IOException
+            {
+               DOMResult result = new DOMResult(element);
+               result.setSystemId(namespace);
+               return result;
+            }
+         });
+      }
+      catch (Exception exception)
+      {
+         throw new WSException("Could not generate schema: " + exception.getMessage(), exception);
+      }
+   }
+
+   /**
+    * Generate a WSDL object model from the passed in ServiceMetaData.
+    *
+    * @param service the service
+    * @param ctx the JAXB context containing all types referenced
+    * @return the WSDL object model
+    */
+   public WSDLDefinitions generate(ServiceMetaData service, JAXBRIContext ctx)
+   {
+      // For now only WSDL 1.1
+      wsdl = new WSDLDefinitions();
+      wsdl.setWsdlNamespace(Constants.NS_WSDL11);
+
+      // One WSDL per service
+      String ns = service.getQName().getNamespaceURI();
+      wsdl.setTargetNamespace(ns);
+      wsdl.registerNamespaceURI(ns, "tns");
+
+      processTypes(ctx);
+      processService(service);
+
+      return wsdl;
+   }
+}


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,286 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.jaxws;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.ParameterMode;
+
+import org.jboss.ws.Constants;
+import org.jboss.ws.jaxrpc.Style;
+import org.jboss.ws.metadata.EndpointMetaData;
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.metadata.ParameterMetaData;
+import org.jboss.ws.metadata.ServerEndpointMetaData;
+import org.jboss.ws.metadata.ServiceMetaData;
+import org.jboss.ws.metadata.wsdl.NCName;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
+import org.jboss.ws.metadata.wsdl.WSDLBindingFault;
+import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
+import org.jboss.ws.metadata.wsdl.WSDLBindingOperationInput;
+import org.jboss.ws.metadata.wsdl.WSDLBindingOperationOutput;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLInterface;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceFault;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutfault;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
+import org.jboss.ws.metadata.wsdl.WSDLRPCPart;
+import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem;
+import org.jboss.ws.metadata.wsdl.WSDLSOAPHeader;
+import org.jboss.ws.metadata.wsdl.WSDLService;
+import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem.Direction;
+
+
+/**
+ * Generates a WSDL object model.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class WSDLGenerator
+{
+   protected WSDLDefinitions wsdl;
+
+   protected void processEndpoint(WSDLService service, ServerEndpointMetaData endpoint)
+   {
+      WSDLEndpoint wsdlEndpoint = new WSDLEndpoint(service);
+      wsdlEndpoint.setQName(endpoint.getQName());
+      wsdlEndpoint.setName(new NCName(endpoint.getQName().getLocalPart()));
+      wsdlEndpoint.setAddress(endpoint.getEndpointAddress());
+
+      WSDLInterface wsdlInterface = new WSDLInterface(wsdl);
+      QName interfaceQName = endpoint.getInterfaceQName();
+      wsdlInterface.setQName(interfaceQName);
+      wsdlInterface.setName(new NCName(interfaceQName));
+
+      WSDLBinding wsdlBinding = new WSDLBinding(wsdl);
+      QName bindingQName = new QName(interfaceQName.getNamespaceURI(), interfaceQName.getLocalPart() + "Binding");
+      wsdlBinding.setQName(bindingQName);
+      wsdlBinding.setName(new NCName(bindingQName.getLocalPart()));
+      wsdlBinding.setInterfaceName(interfaceQName);
+
+      for (OperationMetaData operation : endpoint.getOperations())
+      {
+         processOperation(wsdlInterface, wsdlBinding, operation);
+      }
+   }
+
+   protected void processOperation(WSDLInterface wsdlInterface, WSDLBinding wsdlBinding, OperationMetaData operation)
+   {
+      WSDLInterfaceOperation interfaceOperation = new WSDLInterfaceOperation(wsdlInterface);
+      WSDLBindingOperation bindingOperation = new WSDLBindingOperation(wsdlBinding);
+
+      interfaceOperation.setName(new NCName(operation.getQName().getLocalPart()));
+      interfaceOperation.setPattern(operation.isOneWayOperation() ? Constants.WSDL20_PATTERN_IN_ONLY
+            : Constants.WSDL20_PATTERN_IN_OUT);
+
+      bindingOperation.setRef(operation.getQName());
+      bindingOperation.setSOAPAction(operation.getSOAPAction());
+
+      if (operation.getStyle() == Style.DOCUMENT)
+         processOperationDOC(interfaceOperation, bindingOperation, operation);
+      else
+         processOperationRPC(interfaceOperation, bindingOperation, operation);
+
+      for (FaultMetaData fault : operation.getFaults())
+      {
+         WSDLInterfaceFault interfaceFault = new WSDLInterfaceFault(wsdlInterface);
+         interfaceFault.setElement(fault.getXmlName());
+         interfaceFault.setName(new NCName(fault.getXmlName().getLocalPart()));
+         wsdlInterface.addFault(interfaceFault);
+
+         QName ref = new QName(wsdl.getTargetNamespace(), interfaceFault.getName().toString());
+         WSDLInterfaceOperationOutfault outfault = new WSDLInterfaceOperationOutfault(interfaceOperation);
+         outfault.setRef(ref);
+         interfaceOperation.addOutfault(outfault);
+
+         WSDLBindingFault bindingFault = new WSDLBindingFault(wsdlBinding);
+         bindingFault.setRef(ref);
+         wsdlBinding.addFault(bindingFault);
+      }
+
+      wsdlInterface.addOperation(interfaceOperation);
+      wsdlBinding.addOperation(bindingOperation);
+   }
+
+   protected void addSignatureItem(WSDLInterfaceOperation operation, ParameterMetaData param, boolean isReturn)
+   {
+      Direction direction;
+      if (isReturn)
+      {
+         direction = Direction.RETURN;
+      }
+      else if (param.getMode() == ParameterMode.INOUT)
+      {
+         direction = Direction.INOUT;
+      }
+      else if (param.getMode() == ParameterMode.OUT)
+      {
+         direction = Direction.OUT;
+      }
+      else
+      {
+         direction = Direction.IN;
+      }
+
+      operation.addRpcSignatureItem(new WSDLRPCSignatureItem(param.getPartName(), direction));
+   }
+
+   protected void processOperationDOC(WSDLInterfaceOperation interfaceOperation, WSDLBindingOperation bindingOperation, OperationMetaData operation)
+   {
+      interfaceOperation.setStyle(Constants.URI_STYLE_IRI);
+
+      WSDLInterfaceOperationInput input = new WSDLInterfaceOperationInput(interfaceOperation);
+      WSDLBindingOperationInput bindingInput = new WSDLBindingOperationInput(bindingOperation);
+      QName operationName = operation.getQName();
+      input.setElement(operationName);
+
+      WSDLInterfaceOperationOutput output = null;
+      WSDLBindingOperationOutput bindingOutput = null;
+
+      boolean twoWay = !operation.isOneWayOperation();
+      if (twoWay)
+      {
+         output = new WSDLInterfaceOperationOutput(interfaceOperation);
+         bindingOutput = new WSDLBindingOperationOutput(bindingOperation);
+
+         ParameterMetaData returnParameter = operation.getReturnParameter();
+         if (returnParameter != null)
+         {
+            output.setElement(returnParameter.getXmlName());
+            addSignatureItem(interfaceOperation, returnParameter, true);
+         }
+
+         // If there is no return parameter, it will be set later with an INOUT or OUT parameter
+         interfaceOperation.addOutput(output);
+         bindingOperation.addOutput(bindingOutput);
+      }
+
+      for (ParameterMetaData param : operation.getParameters())
+      {
+         if (param.isInHeader())
+         {
+            WSDLSOAPHeader header = new WSDLSOAPHeader(param.getXmlName(), param.getPartName());
+            header.setIncludeInSignature(true);
+            if (param.getMode() != ParameterMode.OUT)
+               bindingInput.addSoapHeader(header);
+            if (twoWay && param.getMode() != ParameterMode.IN)
+               bindingOutput.addSoapHeader(header);
+         }
+         else
+         {
+            if (param.getMode() != ParameterMode.OUT)
+               input.setElement(param.getXmlName());
+            if (twoWay && param.getMode() != ParameterMode.IN)
+               output.setElement(param.getXmlName());
+         }
+         addSignatureItem(interfaceOperation, param, false);
+      }
+
+      interfaceOperation.addInput(input);
+      bindingOperation.addInput(bindingInput);
+   }
+
+   protected void processOperationRPC(WSDLInterfaceOperation interfaceOperation, WSDLBindingOperation bindingOperation, OperationMetaData operation)
+   {
+      interfaceOperation.setStyle(Constants.URI_STYLE_RPC);
+
+      WSDLInterfaceOperationInput input = new WSDLInterfaceOperationInput(interfaceOperation);
+      WSDLBindingOperationInput bindingInput = new WSDLBindingOperationInput(bindingOperation);
+      QName operationName = operation.getQName();
+      input.setElement(operationName);
+
+      WSDLInterfaceOperationOutput output = null;
+      WSDLBindingOperationOutput bindingOutput = null;
+
+      boolean twoWay = !operation.isOneWayOperation();
+      if (twoWay)
+      {
+         output = new WSDLInterfaceOperationOutput(interfaceOperation);
+         bindingOutput = new WSDLBindingOperationOutput(bindingOperation);
+         output.setElement(new QName(operationName.getNamespaceURI(), operationName.getLocalPart() + "Response"));
+
+         ParameterMetaData returnParam = operation.getReturnParameter();
+         if (returnParam != null)
+         {
+            WSDLRPCPart part = new WSDLRPCPart(returnParam.getPartName(), returnParam.getXmlType());
+            output.addChildPart(part);
+            addSignatureItem(interfaceOperation, returnParam, true);
+         }
+
+         interfaceOperation.addOutput(output);
+         bindingOperation.addOutput(bindingOutput);
+      }
+
+      for (ParameterMetaData param : operation.getParameters())
+      {
+         if (param.isInHeader())
+         {
+            WSDLSOAPHeader header = new WSDLSOAPHeader(param.getXmlName(), param.getPartName());
+            header.setIncludeInSignature(true);
+            if (param.getMode() != ParameterMode.OUT)
+               bindingInput.addSoapHeader(header);
+            if (twoWay && param.getMode() != ParameterMode.IN)
+               bindingOutput.addSoapHeader(header);
+         }
+         else
+         {
+            WSDLRPCPart part = new WSDLRPCPart(param.getPartName(), param.getXmlType());
+            if (param.getMode() != ParameterMode.OUT)
+               input.addChildPart(part);
+            if (twoWay && param.getMode() != ParameterMode.IN)
+               output.addChildPart(part);
+         }
+         addSignatureItem(interfaceOperation, param, true);
+      }
+
+      interfaceOperation.addInput(input);
+      bindingOperation.addInput(bindingInput);
+   }
+
+   protected void processService(ServiceMetaData service)
+   {
+
+      WSDLService wsdlService = new WSDLService(wsdl);
+      wsdlService.setQName(service.getQName());
+      wsdlService.setName(new NCName(service.getQName().getLocalPart()));
+      wsdl.addService(wsdlService);
+
+      EndpointMetaData endpoint = null;
+      for (Iterator<EndpointMetaData> iter = service.getEndpoints().iterator(); iter.hasNext();)
+      {
+         endpoint = iter.next();
+         if (endpoint instanceof ServerEndpointMetaData)
+            processEndpoint(wsdlService, (ServerEndpointMetaData) endpoint);
+      }
+
+      if (endpoint == null)
+         throw new IllegalStateException("A service must have an endpoint");
+
+      wsdlService.setInterfaceName(endpoint.getQName());
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -39,6 +39,7 @@
 import org.jboss.ws.metadata.FaultMetaData;
 import org.jboss.ws.metadata.OperationMetaData;
 import org.jboss.ws.metadata.ParameterMetaData;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.wsdl.WSDLUtils;
 import org.jboss.ws.tools.ToolsUtils;
 import org.jboss.ws.tools.Configuration.OperationConfig;
@@ -148,22 +149,17 @@
             om.setOneWayOperation(opc.isOneWay);
 
          ParameterMetaData wrappedParameter = null;
-         List<String> wrappedVariables = null;
-         List<String> wrappedTypes = null;
-         List<QName> wrappedNames = null;
+         List<WrappedParameter> wrappedParameters = null;
 
+
          if (om.isDocumentWrapped())
          {
             QName xmlName = new QName(tmd.typeNamespace, om.getQName().getLocalPart());
             QName xmlType = xmlName;
 
             wrappedParameter = new ParameterMetaData(om, xmlName, xmlType, null);
-            wrappedVariables = new ArrayList<String>(len);
-            wrappedTypes = new ArrayList<String>(len);
-            wrappedNames = new ArrayList<QName>(len);
-            wrappedParameter.setWrappedVariables(wrappedVariables);
-            wrappedParameter.setWrappedTypes(wrappedTypes);
-            wrappedParameter.setWrappedElementNames(wrappedNames);
+            wrappedParameters = new ArrayList<WrappedParameter>(len);
+            wrappedParameter.setWrappedParameters(wrappedParameters);
 
             om.addParameter(wrappedParameter);
 
@@ -171,9 +167,7 @@
             {
                xmlType = xmlName = new QName(tmd.typeNamespace, om.getResponseName().getLocalPart());
                ParameterMetaData retMetaData = new ParameterMetaData(om, xmlName, xmlType, null);
-               retMetaData.setWrappedVariables(new ArrayList<String>(0));
-               retMetaData.setWrappedTypes(new ArrayList<String>(0));
-               retMetaData.setWrappedElementNames(new ArrayList<QName>(0));
+               retMetaData.setWrappedParameters(new ArrayList<WrappedParameter>(0));
                om.setReturnParameter(retMetaData);
             }
          }
@@ -189,10 +183,8 @@
 
             if (om.isDocumentWrapped() && !isHeaderParameter(opc, i))
             {
-               wrappedTypes.add(paramType.getName());
                QName xmlName = getXmlName(paramType, opc, i, null);
-               wrappedNames.add(xmlName);
-               wrappedVariables.add(convertToProperty(xmlName.getLocalPart()));
+               wrappedParameters.add(new WrappedParameter(xmlName, paramType.getName(), convertToProperty(xmlName.getLocalPart()), i));
             }
             else
             {
@@ -211,10 +203,9 @@
             {
                QName name = getReturnXmlName(opc, null);
 
+               WrappedParameter wrapped = new WrappedParameter(name, returnType.getName(), convertToProperty(name.getLocalPart()), -1);
                ParameterMetaData retMetaData = om.getReturnParameter();
-               retMetaData.getWrappedVariables().add(name.getLocalPart());
-               retMetaData.getWrappedTypes().add(returnType.getName());
-               retMetaData.getWrappedElementNames().add(name);
+               retMetaData.getWrappedParameters().add(wrapped);
             }
             else
             {

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -36,8 +36,9 @@
 public class ToolsEndpointMetaData extends EndpointMetaData
 {
    public String typeNamespace;
-   public ToolsEndpointMetaData(ServiceMetaData service, QName portName)
+
+   public ToolsEndpointMetaData(ServiceMetaData service, QName name, QName interfaceQName)
    {
-      super(service, portName, Type.JAXRPC);
+      super(service, name, interfaceQName, Type.JAXRPC);
    }
 }
\ No newline at end of file

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -89,8 +89,7 @@
       if (serviceName == null)
          serviceName = seiName + "Service";
 
-      String portName = seiName + "Port";
-      um.addService(getServiceMetaData(um, targetNamespace, serviceName, portName, seiClass));
+      um.addService(getServiceMetaData(um, targetNamespace, serviceName, seiName, seiClass));
 
       generateOperationMetaData(seiClass);
    }
@@ -106,10 +105,12 @@
       em = rmb.generate();
    }
 
-   private ServiceMetaData getServiceMetaData(UnifiedMetaData um, String targetNamespace, String serviceName, String portName, Class seiClass)
+   private ServiceMetaData getServiceMetaData(UnifiedMetaData um, String targetNamespace, String serviceName, String portTypeName, Class seiClass)
    {
-      ServiceMetaData sm = new ServiceMetaData(um, new QName(targetNamespace, serviceName));
-      ToolsEndpointMetaData tm = new ToolsEndpointMetaData(sm, new QName(targetNamespace, portName));
+      ServiceMetaData sm = new ServiceMetaData(um, new QName(targetNamespace,serviceName));
+      QName name = new QName(targetNamespace, portTypeName + "Port");
+      QName interfaceName = new QName(targetNamespace, portTypeName);
+      ToolsEndpointMetaData tm = new ToolsEndpointMetaData(sm, name, interfaceName);
       tm.typeNamespace = typeNamespace;
       tm.setServiceEndpointInterfaceName(seiClass.getName());
       tm.setStyle(style);

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -56,6 +56,8 @@
 package org.jboss.ws.utils;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Calendar;
@@ -93,16 +95,20 @@
  */
 public class HolderUtils
 {
+   /*
+    * FIXME Need to have smoother holder unifaction between JAX-RPC and JAX-WS
+    */
+
    // provide logging
    private static final Logger log = Logger.getLogger(HolderUtils.class);
-   
+
    /** True if the given type is a holder. */
    public static boolean isHolderType(Class javaType)
    {
       if (javaType == null)
          throw new IllegalArgumentException("Illegal null parameter");
 
-      return Holder.class.isAssignableFrom(javaType);
+      return Holder.class.isAssignableFrom(javaType) || javax.xml.ws.Holder.class.isAssignableFrom(javaType);
    }
 
    /** Get the Holder for a given valueType.
@@ -175,7 +181,7 @@
          return StringHolder.class;
       if (valueType == Object.class)
          return ObjectHolder.class;
-      
+
       log.warn("Cannot get holder type for: " + valueType);
 
       return null;
@@ -188,7 +194,7 @@
       if (holderType == null)
          throw new IllegalArgumentException("Illegal null parameter");
 
-      if (Holder.class.isAssignableFrom(holderType) == false)
+      if (!Holder.class.isAssignableFrom(holderType) && !javax.xml.ws.Holder.class.isAssignableFrom(holderType))
          throw new IllegalArgumentException("Is not a holder: " + holderType.getName());
 
       // Holder is supposed to have a public value field.
@@ -265,4 +271,9 @@
          throw new IllegalArgumentException("Cannot access public value field: " + holder);
       }
    }
+
+   public static Type getGenericValueType(Type holder)
+   {
+      return ((ParameterizedType)holder).getActualTypeArguments()[0];
+   }
 }

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/IOUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/IOUtils.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/IOUtils.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -65,16 +65,28 @@
       }
    }
 
+   public static String printArray(Object[] val)
+   {
+      StringBuilder out = new StringBuilder("[");
+      for (int i = 0; i < val.length; i++)
+      {
+         if (i > 0)
+            out.append(", ");
+         out.append(val[i].getClass().isArray() ? printArray((Object[])val[i]) : val[i]);
+      }
+      return out.append("]").toString();
+   }
+
    /**
     * Transform a Reader to an InputStream
-    * Background is that DocumentBuilder.parse() cannot take the Reader directly 
+    * Background is that DocumentBuilder.parse() cannot take the Reader directly
     */
    public static InputStream transformReader(Reader reader) throws IOException
    {
       int capacity = 1024;
       char[] charBuffer = new char[capacity];
       StringBuffer strBuffer = new StringBuffer(capacity);
-      
+
       int len = reader.read(charBuffer, 0, capacity);
       while (len > 0)
       {

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JBossWSEntityResolver.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/JBossWSEntityResolver.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JBossWSEntityResolver.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -21,7 +21,7 @@
  */
 package org.jboss.ws.utils;
 
-// $Id: $
+// $Id$
 
 import java.io.IOException;
 import java.net.URL;

Modified: branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -24,7 +24,13 @@
 // $Id$
 
 import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
 import java.util.HashMap;
+import java.util.HashSet;
 
 import org.jboss.logging.Logger;
 
@@ -38,7 +44,9 @@
    // provide logging
    private static final Logger log = Logger.getLogger(JavaUtils.class);
 
-   private static HashMap<String, Class> primitiveNames = new HashMap<String, Class>();
+   private static HashMap<String, Class> primitiveNames = new HashMap<String, Class>(8);
+   private static HashMap<String, String> primitiveNameDescriptors = new HashMap<String, String>(8);
+   private static HashSet<String> reservedKeywords = new HashSet<String>(50);
 
    static
    {
@@ -50,6 +58,66 @@
       primitiveNames.put("double", double.class);
       primitiveNames.put("float", float.class);
       primitiveNames.put("char", char.class);
+
+      primitiveNameDescriptors.put("int", "I");
+      primitiveNameDescriptors.put("short", "S");
+      primitiveNameDescriptors.put("boolean", "Z");
+      primitiveNameDescriptors.put("byte", "B");
+      primitiveNameDescriptors.put("long", "J");
+      primitiveNameDescriptors.put("double", "D");
+      primitiveNameDescriptors.put("float", "F");
+      primitiveNameDescriptors.put("char", "C");
+
+      reservedKeywords.add("abstract");
+      reservedKeywords.add("continue");
+      reservedKeywords.add("for");
+      reservedKeywords.add("new");
+      reservedKeywords.add("switch");
+      reservedKeywords.add("assert");
+      reservedKeywords.add("default");
+      reservedKeywords.add("if");
+      reservedKeywords.add("package");
+      reservedKeywords.add("synchronized");
+      reservedKeywords.add("boolean");
+      reservedKeywords.add("do");
+      reservedKeywords.add("goto");
+      reservedKeywords.add("private");
+      reservedKeywords.add("this");
+      reservedKeywords.add("break");
+      reservedKeywords.add("double");
+      reservedKeywords.add("implements");
+      reservedKeywords.add("protected");
+      reservedKeywords.add("throw");
+      reservedKeywords.add("byte");
+      reservedKeywords.add("else");
+      reservedKeywords.add("import");
+      reservedKeywords.add("public");
+      reservedKeywords.add("throws");
+      reservedKeywords.add("case");
+      reservedKeywords.add("enum");
+      reservedKeywords.add("instanceof");
+      reservedKeywords.add("return");
+      reservedKeywords.add("transient");
+      reservedKeywords.add("catch");
+      reservedKeywords.add("extends");
+      reservedKeywords.add("int");
+      reservedKeywords.add("short");
+      reservedKeywords.add("try");
+      reservedKeywords.add("char");
+      reservedKeywords.add("final");
+      reservedKeywords.add("interface");
+      reservedKeywords.add("static");
+      reservedKeywords.add("void");
+      reservedKeywords.add("class");
+      reservedKeywords.add("finally");
+      reservedKeywords.add("long");
+      reservedKeywords.add("strictfp");
+      reservedKeywords.add("volatile");
+      reservedKeywords.add("const");
+      reservedKeywords.add("float");
+      reservedKeywords.add("native");
+      reservedKeywords.add("super");
+      reservedKeywords.add("while");
    }
 
    /**
@@ -403,6 +471,35 @@
       return typeName;
    }
 
+   /**
+    * Converts a JVM external name to a JVM signature name. An external name is
+    * that which is returned from {@link Class#getName()} A signature name is
+    * the name in class file format.
+    * <p>
+    * For example:
+    * <p>
+    * [java.lang.Object
+    * <p>
+    * becomes:
+    * <p>
+    * [Ljava/lang/Object;
+    *
+    * @param externalName
+    * @return
+    */
+   public static String toSignature(String externalName)
+   {
+      if (externalName == null)
+         return null;
+
+      String ret = primitiveNameDescriptors.get(externalName);
+      if (ret != null)
+         return ret;
+
+      ret = externalName.replace('.', '/');
+      return (ret.charAt(0) == '[') ? ret : "L" + ret + ";";
+   }
+
    public static String getSourceName(Class type)
    {
       if (! type.isArray())
@@ -418,4 +515,87 @@
 
       return component.getName() + arrayNotation;
    }
-}
+
+   public static String capitalize(String source)
+   {
+      if (source == null)
+         return null;
+
+      if (source.length() == 0)
+         return source;
+
+      if (Character.isUpperCase(source.charAt(0)))
+         return source;
+
+      char c = Character.toUpperCase(source.charAt(0));
+
+      return c + source.substring(1);
+   }
+
+   public static boolean isLoaded(String className, ClassLoader loader)
+   {
+      try
+      {
+         loadJavaType(className, loader);
+      }
+      catch (ClassNotFoundException e)
+      {
+         return false;
+      }
+
+      return true;
+   }
+
+   public static String getPackageName(Class<?> clazz)
+   {
+      String fullName = clazz.getName();
+      return fullName.substring(0, fullName.lastIndexOf("."));
+   }
+
+   public static boolean isReservedKeyword(String keyword)
+   {
+      return reservedKeywords.contains(keyword);
+   }
+
+   /**
+    * Erases a type according to the JLS type erasure rules
+    *
+    * @param t type to erase
+    * @return erased type
+    */
+   public static Class erasure(Type type)
+   {
+      if (type instanceof ParameterizedType)
+      {
+         return erasure(((ParameterizedType)type).getRawType());
+      }
+      if (type instanceof TypeVariable)
+      {
+         return erasure(((TypeVariable)type).getBounds()[0]);
+      }
+      if (type instanceof WildcardType)
+      {
+         return erasure(((WildcardType)type).getUpperBounds()[0]);
+      }
+      if (type instanceof GenericArrayType)
+      {
+         return Array.newInstance(erasure(((GenericArrayType)type).getGenericComponentType()), 0).getClass();
+      }
+
+      // Only type left is class
+      return (Class)type;
+   }
+
+   public static String[] getRawParameterTypeArguments(ParameterizedType type)
+   {
+      Type[] arguments = type.getActualTypeArguments();
+      String[] ret = new String[arguments.length];
+      for (int i = 0; i < arguments.length; i++)
+      {
+         Class raw = erasure(arguments[i]);
+         ret[i] = raw.getName();
+      }
+
+      return ret;
+   }
+}
\ No newline at end of file

Added: branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.utils;
+
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.FieldInfo;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.SignatureAttribute;
+import javassist.bytecode.annotation.ArrayMemberValue;
+import javassist.bytecode.annotation.EnumMemberValue;
+import javassist.bytecode.annotation.StringMemberValue;
+
+/**
+ * Utility functions that simplify Javassist.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @version $Revision:$
+ */
+public class JavassistUtils
+{
+   public static void addFieldAnnotation(CtField field, javassist.bytecode.annotation.Annotation annotation)
+   {
+      FieldInfo fieldInfo = field.getFieldInfo();
+      AnnotationsAttribute attribute = new AnnotationsAttribute(fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag);
+      attribute.setAnnotation(annotation);
+      fieldInfo.addAttribute(attribute);
+   }
+
+   public static void addClassAnnotation(CtClass clazz, javassist.bytecode.annotation.Annotation annotation)
+   {
+      ClassFile classFile = clazz.getClassFile();
+      AnnotationsAttribute attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
+      attribute.setAnnotation(annotation);
+      classFile.addAttribute(attribute);
+   }
+
+   public static Annotation createAnnotation(Class<? extends java.lang.annotation.Annotation> annotation, ConstPool constPool)
+   {
+      return new Annotation(annotation, constPool);
+   }
+
+   public static void addSignature(CtField field, String signature)
+   {
+      FieldInfo fieldInfo = field.getFieldInfo();
+      ConstPool constPool = fieldInfo.getConstPool();
+      SignatureAttribute signatureAttribute = new SignatureAttribute(constPool, signature);
+      fieldInfo.addAttribute(signatureAttribute);
+   }
+
+   public static void addSignature(CtMethod method, String signature)
+   {
+      MethodInfo methodInfo = method.getMethodInfo();
+      ConstPool constPool = methodInfo.getConstPool();
+      SignatureAttribute signatureAttribute = new SignatureAttribute(constPool, signature);
+      methodInfo.addAttribute(signatureAttribute);
+   }
+
+   public static class Annotation
+   {
+      private javassist.bytecode.annotation.Annotation annotation;
+      private ConstPool constPool;
+
+      public Annotation(Class<? extends java.lang.annotation.Annotation> annotation, ConstPool constPool)
+      {
+         this.annotation = new javassist.bytecode.annotation.Annotation(annotation.getName(), constPool);
+         this.constPool = constPool;
+      }
+
+      public void addParameter(String name, String value)
+      {
+         annotation.addMemberValue(name, new StringMemberValue(value, constPool));
+      }
+
+      public void addParameter(String name, Enum value)
+      {
+         EnumMemberValue enumValue = new EnumMemberValue(constPool);
+         enumValue.setType(value.getClass().getName());
+         enumValue.setValue(value.name());
+         annotation.addMemberValue(name, enumValue);
+      }
+
+      public void addParameter(String name, String[] values)
+      {
+         ArrayMemberValue member = new ArrayMemberValue(constPool);
+         StringMemberValue[] members = new StringMemberValue[values.length];
+         for (int i = 0; i < values.length; i++)
+            members[i] = new StringMemberValue(values[i], constPool);
+         member.setValue(members);
+         annotation.addMemberValue(name, member);
+      }
+
+      public void markClass(CtClass clazz)
+      {
+         addClassAnnotation(clazz, annotation);
+      }
+
+      public void markField(CtField field)
+      {
+         addFieldAnnotation(field, annotation);
+      }
+   }
+}
\ No newline at end of file


Property changes on: branches/jgreene/trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jgreene/trunk/src/test/java/org/jboss/test/ws/jbws1125/JBWS1125TestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jbws1125/JBWS1125TestCase.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/test/java/org/jboss/test/ws/jbws1125/JBWS1125TestCase.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -21,7 +21,7 @@
  */
 package org.jboss.test.ws.jbws1125;
 
-// $Id: $
+// $Id$
 
 import java.io.ByteArrayInputStream;
 

Modified: branches/jgreene/trunk/src/test/java/org/jboss/test/ws/tools/validation/WSDL11Validator.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/tools/validation/WSDL11Validator.java	2006-08-21 16:58:45 UTC (rev 801)
+++ branches/jgreene/trunk/src/test/java/org/jboss/test/ws/tools/validation/WSDL11Validator.java	2006-09-08 22:12:40 UTC (rev 919)
@@ -121,8 +121,8 @@
          {
             WSDLInterfaceFault flt1 = faults1[k];
             WSDLInterfaceFault flt2 = faults2[k];
-            QName elt = flt1.getXmlName();
-            QName elt2 = flt2.getXmlName();
+            QName elt = flt1.getElement();
+            QName elt2 = flt2.getElement();
             if(!(elt.getLocalPart().equals(elt2.getLocalPart()) &&
                   elt.getNamespaceURI().equals(elt2.getNamespaceURI())))
             {




More information about the jboss-svn-commits mailing list