[jboss-svn-commits] JBossWS SVN: r1145 - in trunk/src: main/java/org/jboss/ws/binding main/java/org/jboss/ws/common main/java/org/jboss/ws/deployment main/java/org/jboss/ws/jaxrpc main/java/org/jboss/ws/jaxws main/java/org/jboss/ws/jaxws/spi main/java/org/jboss/ws/metadata main/java/org/jboss/ws/metadata/wsdl main/java/org/jboss/ws/tools main/java/org/jboss/ws/tools/helpers main/java/org/jboss/ws/tools/jaxws main/java/org/jboss/ws/tools/metadata main/java/org/jboss/ws/utils test/etc test/java/org/jboss/test/ws/jaxws/jsr181/webservice test/java/org/jboss/test/ws/jaxws/samples/jsr181ejb test/java/org/jboss/test/ws/jaxws/samples/jsr181pojo test/java/org/jboss/test/ws/jaxws/samples/wsaddressing test/java/org/jboss/test/ws/tools/validation

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 5 13:49:04 EDT 2006


Author: jason.greene at jboss.com
Date: 2006-10-05 13:48:45 -0400 (Thu, 05 Oct 2006)
New Revision: 1145

Added:
   trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java
   trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceMessageReference.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java
   trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java
   trunk/src/main/java/org/jboss/ws/tools/jaxws/
   trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
   trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java
   trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java
Removed:
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java
Modified:
   trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java
   trunk/src/main/java/org/jboss/ws/common/CommonClient.java
   trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java
   trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java
   trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/JSR181ClientMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java
   trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java
   trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java
   trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java
   trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLWriter.java
   trunk/src/main/java/org/jboss/ws/tools/JavaToWSDL11.java
   trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java
   trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java
   trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
   trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
   trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java
   trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java
   trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java
   trunk/src/main/java/org/jboss/ws/utils/IOUtils.java
   trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java
   trunk/src/test/etc/log4j.xml
   trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webservice/JSEBean01.java
   trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181ejb/EJB3Bean01.java
   trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181pojo/JSEBean01.java
   trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpoint.java
   trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java
   trunk/src/test/java/org/jboss/test/ws/tools/validation/WSDL11Validator.java
Log:
Refactor WSDL model to be capable of representing both WSDL 2.0 and WSDL 1.1
Correct many issues with WSDL 1.1 representation
Replace WSDL generation with a new generator that supports JAXB and JAX-RPC generation
Refactor ParameterMetaData to be capable of handling JAX-WS parameters
Refactor Binding layer to deal with parameter order, and WSDL model changes
Refactor JAX-RPC tools to be compatible with the updated model
Refactor all metadata builders for the above listed items
Refactor JSR181MetaDataBuilder to be JAX-WS compatible
Integrate JAXB schema generation
Add support for dynamically generating JAXB request/response wrappers
Implement Javassist enhancments that allow generation of annotations and generics
Implement type erasure
Update tests to be inline with changes


Modified: trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/binding/EndpointInvocation.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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

Modified: trunk/src/main/java/org/jboss/ws/common/CommonClient.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/common/CommonClient.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/common/CommonClient.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -57,13 +57,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);
@@ -97,7 +97,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)
       {
@@ -125,7 +125,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);
 
@@ -184,7 +184,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);
@@ -242,17 +242,17 @@
          SOAPMessage reqMessage = (SOAPMessage)binding.bindRequestMessage(opMetaData, epInv, unboundHeaders);
 
          setOutboundContextProperties();
-         
+
          // Call the request handlers
          QName portName = epMetaData.getQName();
          boolean handlerPass = callRequestHandlerChain(portName, HandlerType.PRE);
          handlerPass = handlerPass && callRequestHandlerChain(portName, HandlerType.ENDPOINT);
          handlerPass = handlerPass && callRequestHandlerChain(portName, HandlerType.POST);
-         
+
          if (handlerPass)
          {
             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)
@@ -279,7 +279,7 @@
                throw new WSException("Target endpoint address not set");
 
             EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, getRequestContext());
-            
+
             SOAPMessage resMessage;
             if (oneway)
             {
@@ -295,21 +295,21 @@
          }
 
          setInboundContextProperties();
-         
+
          // Get the return object
          Object retObj = null;
          if (oneway == false)
          {
             // Call the response handlers
             handlerPass = callResponseHandlerChain(portName, HandlerType.POST);
-            
+
             // unbind the return values
             if (handlerPass)
             {
                SOAPMessage resMessage = msgContext.getSOAPMessage();
                binding.unbindResponseMessage(opMetaData, resMessage, epInv, unboundHeaders);
             }
-            
+
             handlerPass = handlerPass && callResponseHandlerChain(portName, HandlerType.ENDPOINT);
             handlerPass = handlerPass && callResponseHandlerChain(portName, HandlerType.PRE);
 
@@ -320,7 +320,7 @@
                SOAPMessage resMessage = msgContext.getSOAPMessage();
                binding.unbindResponseMessage(opMetaData, resMessage, epInv, unboundHeaders);
             }
-            
+
             retObj = syncOutputParams(inputParams, epInv);
          }
 
@@ -356,14 +356,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();
@@ -372,14 +368,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;

Modified: trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -79,12 +79,12 @@
 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
  */
-public abstract class CommonSOAPBinding implements CommonBinding 
+public abstract class CommonSOAPBinding implements CommonBinding
 {
    // provide logging
    private static Logger log = Logger.getLogger(CommonSOAPBinding.class);
@@ -155,6 +155,7 @@
             log.debug("Create RPC body element: " + opName);
             SOAPBodyElement soapBodyElement = new SOAPBodyElementRpc(opName);
 
+
             soapBodyElement = (SOAPBodyElement)soapBody.addChildElement(soapBodyElement);
 
             for (ParameterMetaData paramMetaData : opMetaData.getInputParameters())
@@ -454,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: trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -75,7 +75,7 @@
    {
       if (wsdlURL == null)
          throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);
-      
+
       log.debug("START buildMetaData: [service=" + serviceQName + "]");
       try
       {
@@ -92,10 +92,10 @@
          buildMetaDataInternal(serviceMetaData, wsdlDefinitions);
 
          // Read the WSDL and initialize the schema model
-         // This should only be needed for debuging purposes of the UMDM 
+         // This should only be needed for debuging purposes of the UMDM
          JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
          serviceMetaData.getTypesMetaData().setSchemaModel(schemaModel);
-         
+
          log.debug("END buildMetaData: " + wsMetaData);
          return serviceMetaData;
       }
@@ -134,13 +134,14 @@
       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);
 
          // Init the endpoint binding
          initEndpointBinding(wsdlEndpoint, epMetaData);
-         
+
          // Init the service encoding style
          initEndpointEncodingStyle(epMetaData);
 
@@ -168,7 +169,7 @@
 
          // Set the operation style
          String style = wsdlOperation.getStyle();
-         epMetaData.setStyle(Style.valueOf(style));
+         epMetaData.setStyle((Constants.URI_STYLE_IRI.equals(style) ? Style.DOCUMENT : Style.RPC));
 
          // Set the operation MEP
          if (Constants.WSDL20_PATTERN_IN_ONLY.equals(wsdlOperation.getPattern()))
@@ -184,20 +185,20 @@
          String encStyle = epMetaData.getEncodingStyle().toURI();
          TypeMappingRegistry tmRegistry = new TypeMappingRegistryImpl();
          TypeMappingImpl typeMapping = (TypeMappingImpl)tmRegistry.getTypeMapping(encStyle);
+//
+//         // Build the parameter meta data
+//         if (opMetaData.getStyle() == Style.RPC)
+//         {
+//            buildParameterMetaDataRpc(opMetaData, wsdlOperation, typeMapping);
+//         }
+//         else
+//         {
+//            buildParameterMetaDataDoc(opMetaData, wsdlOperation, typeMapping);
+//         }
+//
+//         // Build operation faults
+//         buildFaultMetaData(opMetaData, wsdlOperation);
 
-         // Build the parameter meta data
-         if (opMetaData.getStyle() == Style.RPC)
-         {
-            buildParameterMetaDataRpc(opMetaData, wsdlOperation, typeMapping);
-         }
-         else
-         {
-            buildParameterMetaDataDoc(opMetaData, wsdlOperation, typeMapping);
-         }
-
-         // Build operation faults
-         buildFaultMetaData(opMetaData, wsdlOperation);
-
          // process further operation extensions
          processOpMetaExtensions(opMetaData, wsdlOperation);
       }

Modified: trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JAXWSMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -43,6 +43,6 @@
    protected void replaceAddressLocation(ServerEndpointMetaData epMetaData)
    {
       // FIXME: JBWS-1026
-      // Remove this method 
+      // Remove this method
    }
 }

Modified: trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JAXWSProviderMetaDataBuilderJSE.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -131,7 +131,7 @@
       WSDLUtils wsdlUtils = WSDLUtils.getInstance();
 
       String name = wsdlUtils.getJustClassName(sepClass);
-      
+
       String serviceName = anWebServiceProvider.serviceName();
       if (serviceName.length() == 0)
          serviceName = name + "Service";
@@ -149,7 +149,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: trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR109ClientMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -174,7 +174,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: trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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();
@@ -163,7 +178,7 @@
 
          // Set the operation style
          String style = wsdlOperation.getStyle();
-         epMetaData.setStyle(Style.valueOf(style));
+         epMetaData.setStyle((Constants.URI_STYLE_IRI.equals(style) ? Style.DOCUMENT : Style.RPC));
 
          // Set the operation MEP
          if (Constants.WSDL20_PATTERN_IN_ONLY.equals(wsdlOperation.getPattern()))
@@ -198,189 +213,211 @@
       }
    }
 
-   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.setPartName(partName);
+      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, xmlName, xmlType, javaTypeName);
+      outMetaData.setPartName(partName);
 
-               // 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);
-                  }
-               }
+      if (hasReturnMapping)
+      {
+         opMetaData.setReturnParameter(outMetaData);
+      }
+      else
+      {
+         outMetaData.setIndex(pos);
+         outMetaData.setMode(ParameterMode.OUT);
+         opMetaData.addParameter(outMetaData);
+      }
 
-               setupAttachmentParameter(opOutput, outMetaData);
-            }
-            else
-            {
-               outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName);
-               outMetaData.setMode(ParameterMode.OUT);
-               opMetaData.addParameter(outMetaData);
+      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);
+      return outMetaData;
+   }
 
-               outMetaData.setInHeader(inHeader);
-            }
+   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();
 
-            // SOAPENC:Array
-            setupSOAPArrayParameter(outMetaData, javaTypeName);
-         }
+         ParameterMetaData pmd = buildInputParameter(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, partName, xmlName, xmlType, wsdlPosition++);
+         pmd.setInHeader(true);
       }
+
+      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);
-      String localPart = xmlType.getLocalPart() != null ? xmlType.getLocalPart() : "";
-      String ns = xmlType.getNamespaceURI() != null ? xmlType.getNamespaceURI() : "";
-      XSTypeDefinition xsType = schemaModel.getTypeDefinition(localPart, ns);
-      XOPScanner scanner = new XOPScanner();
-      if(scanner.findXOPTypeDef(xsType)!=null | (localPart.equals("base64Binary")&&ns.equals(Constants.NS_SCHEMA_XSD)))
+      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
@@ -388,7 +425,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();
@@ -397,6 +434,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
@@ -417,211 +455,367 @@
       }
    }
 
-   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);
+      String localPart = xmlType.getLocalPart() != null ? xmlType.getLocalPart() : "";
+      String ns = xmlType.getNamespaceURI() != null ? xmlType.getNamespaceURI() : "";
+      XSTypeDefinition xsType = schemaModel.getTypeDefinition(localPart, ns);
+      XOPScanner scanner = new XOPScanner();
+      if(scanner.findXOPTypeDef(xsType)!=null | (localPart.equals("base64Binary")&&ns.equals(Constants.NS_SCHEMA_XSD)))
+      {
+         // 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:" + opMetaData.getQName());
 
-      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++;
+
+               setupXOPAttachmentParameter(wsdlOperation, pmd);
+               setupSOAPArrayParameter(pmd);
             }
          }
 
-         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(OperationMetaData operation, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping, TypeMappingImpl typeMapping, List<WrappedParameter> wrappedParameters, List<WrappedParameter> wrappedResponseParameters)
+   {
+      WSDLInterfaceOperationInput input = wsdlOperation.getInputs()[0];
+      int wsdlPosition;
+
+      QName xmlName = input.getElement();
+      QName xmlType = input.getXMLType();
+      String javaTypeName = typeMapping.getJavaTypeName(xmlType);
+
+      TypesMetaData typesMetaData = operation.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
+      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);
+      operation.getEndpointMetaData().setParameterStyle(isWrapped ? ParameterStyle.WRAPPED : ParameterStyle.BARE);
+
+      ParameterMetaData inMetaData = new ParameterMetaData(operation, xmlName, xmlType, javaTypeName);
+      operation.addParameter(inMetaData);
+
+
+      // 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();
       }
-
-      for (WSDLInterfaceOperationOutput opOutput : wsdlOperation.getOutputs())
+      else
       {
-         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)
+         if (seiMethodMapping != null)
          {
-            paramMetaData.setMode(ParameterMode.INOUT);
+            MethodParamPartsMapping part = seiMethodMapping.getMethodParamPartsMappingByPartName(input.getPartName());
+            if (part != null)
+            {
+               inMetaData.setJavaTypeName(part.getParamType());
+               inMetaData.setIndex(part.getParamPosition());
+            }
          }
-         else
-         {
-            QName xmlType = opOutput.getXMLType();
-            String javaTypeName = typeMapping.getJavaTypeName(xmlType);
 
-            boolean inHeader = opOutput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-            boolean hasReturnMapping = (inHeader == false);
+         setupXOPAttachmentParameter(wsdlOperation, inMetaData);
+         wsdlPosition = 1;
+      }
 
-            if (typesMetaData.getTypeMappingByXMLType(xmlType) != null)
-               javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName();
+      return wsdlPosition;
+   }
 
-            if (javaTypeName == null)
-               throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType);
+   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)
+      {
 
-            if (hasReturnMapping)
+         MethodParamPartsMapping[] partsMappings = seiMethodMapping.getMethodParamPartsMappings();
+         if (partsMappings.length > 0)
+         {
+            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> 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(wrappedResponseParameters);
       }
-
-      // 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;
+               javaTypeName = part.getParamType();
+               outMetaData.setIndex(part.getParamPosition());
+               outMetaData.setJavaTypeName(javaTypeName);
+            }
+            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());
+
+      WSDLBindingOperation bindingOperation = wsdlOperation.getBindingOperation();
+      if (bindingOperation == null)
+         throw new WSException("Could not locate binding operation for:" + bindingOperation);
+
+      List<WrappedParameter> wrappedParameters = new ArrayList<WrappedParameter>();
+      List<WrappedParameter> wrappedResponseParameters = new ArrayList<WrappedParameter>();
+
+      int wsdlPosition = 0;
+      // WS-I BP 1.0 allows document/literal bare to have zero message parts
+      if (wsdlOperation.getInputs().length > 0)
+      {
+         wsdlPosition = processDocElement(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, wrappedParameters, wrappedResponseParameters);
+         wsdlPosition = processBindingParameters(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, bindingOperation, wsdlPosition);
+      }
+      if (wsdlOperation.getOutputs().length > 0)
+      {
+         wsdlPosition = processOutputDocElement(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, wrappedResponseParameters, wsdlPosition);
+         wsdlPosition = processBindingOutputParameters(opMetaData, wsdlOperation, seiMethodMapping, typeMapping, bindingOperation, wsdlPosition);
+      }
+   }
+
    /**
     * Build default action according to the pattern described in
     * http://www.w3.org/Submission/2004/SUBM-ws-addressing-20040810/
@@ -652,5 +846,4 @@
 
       return actionValue;
    }
-
 }

Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR109ServerMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -127,8 +127,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();

Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR181ClientMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR181ClientMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR181ClientMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -51,24 +51,28 @@
 
       // Clear handlers
       epMetaData.clearHandlers();
-      
+
       // Add pre handlers
       WSClientConfigJAXWS jaxwsConfig = (WSClientConfigJAXWS)epMetaData.getEndpointConfig();
       epMetaData.addHandlers(jaxwsConfig.getHandlers(epMetaData, HandlerType.PRE));
-      
+
       // Process an optional @HandlerChain annotation
       if (wsClass.isAnnotationPresent(HandlerChain.class))
          processHandlerChain(epMetaData, wsClass);
 
       // Add post handlers
       epMetaData.addHandlers(jaxwsConfig.getHandlers(epMetaData, HandlerType.POST));
-      
+
       // Process @WebMethod
       processWebMethods(epMetaData, wsClass, true);
-      
+
+      // Build JAXB Context
+      createJAXBContext();
+      populateXmlTypes(epMetaData);
+
       // Eager initialization
       epMetaData.eagerInitialize();
-      
+
       log.debug("END: rebuildMetaData\n" + epMetaData.getServiceMetaData());
    }
 }

Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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,8 +76,8 @@
 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.HandlerMetaData.HandlerType;
+import org.jboss.ws.metadata.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.config.jaxws.WSEndpointConfigJAXWS;
 import org.jboss.ws.metadata.j2ee.UnifiedHandlerMetaData;
 import org.jboss.ws.metadata.jsr181.HandlerChainFactory;
@@ -84,12 +87,20 @@
 import org.jboss.ws.metadata.wsdl.WSDLUtils;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
 import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
-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.tools.jaxws.WSDLGenerator;
 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
@@ -99,13 +110,18 @@
 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);
@@ -129,6 +145,8 @@
 
          WSDLUtils wsdlUtils = WSDLUtils.getInstance();
 
+      wrapperGenerator = new DynamicWrapperGenerator(udi.annotationsCl);
+
          String name = anWebService.name();
          if (name.length() == 0)
             name = wsdlUtils.getJustClassName(wsClass);
@@ -148,15 +166,17 @@
          ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, new QName(targetNS, serviceName));
          wsMetaData.addService(serviceMetaData);
 
+      // Setup the ServerEndpointMetaData
+      QName portQName = new QName(targetNS, portName);
+      QName portTypeQName = new QName(targetNS, name);
+      ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portQName, portTypeQName, EndpointMetaData.Type.JAXWS);
+      sepMetaData.setLinkName(linkName);
+
          // Assign the WS-Security configuration,
          WSSecurityConfiguration securityConfiguration = getWsSecurityConfiguration(udi);
          serviceMetaData.setSecurityConfiguration(securityConfiguration);
-         
-         // Setup the ServerEndpointMetaData
-         QName portQName = new QName(targetNS, portName);
-         ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, portQName, Type.JAXWS);
-         sepMetaData.setLinkName(linkName);
 
+
          sepMetaData.setServiceEndpointImplName(sepClass.getName());
          sepMetaData.setServiceEndpointInterfaceName(wsClass.getName());
 
@@ -173,11 +193,16 @@
          boolean includeAllMethods = (wsClass == seiClass);
          processWebMethods(sepMetaData, wsClass, includeAllMethods);
 
+         // Build JAXB Context
+         createJAXBContext();
+         populateXmlTypes(sepMetaData);
+
          // Process or generate WSDL
          String wsdlLocation = anWebService.wsdlLocation();
          processOrGenerateWSDL(wsClass, serviceMetaData, wsdlLocation, sepMetaData);
 
          // Read the generated WSDL and initialize the schema model
+         // FIXME - This should be removed
          WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions();
          JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
          serviceMetaData.getTypesMetaData().setSchemaModel(schemaModel);
@@ -218,6 +243,51 @@
       }
    }
 
+   protected 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);
+      }
+   }
+
+   protected void populateXmlTypes(EndpointMetaData endpoint)
+   {
+      TypesMetaData types = endpoint.getServiceMetaData().getTypesMetaData();
+      for (OperationMetaData operation : endpoint.getOperations())
+      {
+         for (ParameterMetaData parameter : operation.getParameters())
+         {
+            populateXmlType(types, parameter);
+         }
+         ParameterMetaData returnParameter = operation.getReturnParameter();
+         if (returnParameter != null)
+            populateXmlType(types, returnParameter);
+      }
+   }
+
+   private void populateXmlType(TypesMetaData types, ParameterMetaData parameter)
+   {
+      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);
@@ -306,22 +376,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))
@@ -331,173 +391,199 @@
 
       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.isOneWay())
          {
-            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.isOneWay() && 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.isOneWay())
             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.isOneWay())
+         {
+            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)))
@@ -511,14 +597,14 @@
       return variable;
    }
 
-   /** 
+   /**
     * Process an optional @HandlerChain annotation
-    * 
+    *
     * Location of the handler chain file. The location supports 2 formats.
-    * 
+    *
     *    1. An absolute java.net.URL in externalForm.
     *    (ex: http://myhandlers.foo.com/handlerfile1.xml)
-    *    
+    *
     *    2. A relative path from the source file or class file.
     *    (ex: bar/handlerfile1.xml)
     */
@@ -609,7 +695,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();
@@ -630,27 +716,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;
@@ -661,43 +731,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.isOneWay())
          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;
    }
 
    /**
@@ -719,4 +860,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();
+
+            WSDLGenerator generator = new JAXBWSDLGenerator(jaxbCtx);
+            WSDLDefinitions wsdlDefinitions = generator.generate(serviceMetaData);
+
+            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: trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/deployment/MetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -144,8 +144,7 @@
       return config;
    }
 
-   /** Inititialize the endpoint binding 
-    */
+   /** Inititialize the endpoint binding */
    protected void initEndpointBinding(WSDLEndpoint wsdlEndpoint, ClientEndpointMetaData epMetaData)
    {
       WSDLDefinitions wsdlDefinitions = wsdlEndpoint.getWsdlService().getWsdlDefinitions();
@@ -250,7 +249,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;
 

Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -271,9 +271,10 @@
 
       OperationMetaData opMetaData = getOperationMetaData();
       ParameterMetaData paramMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaType.getName());
-      opMetaData.addParameter(paramMetaData);
       paramMetaData.setMode(mode);
       paramMetaData.setInHeader(inHeader);
+      paramMetaData.setIndex(opMetaData.getParameters().size());
+      opMetaData.addParameter(paramMetaData);
 
       registerParameterType(xmlType, javaType);
    }

Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/ParameterWrapping.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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.isOneWay() == 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();
@@ -455,16 +316,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);
@@ -489,17 +347,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: trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/jaxws/DynamicWrapperGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/jaxws/WrapperGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -60,10 +60,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
  */
@@ -96,7 +96,7 @@
       builder.setClassLoader(ctxClassLoader);
 
       serviceMetaData = builder.buildMetaData(serviceName, wsdlURL);
-      
+
       for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
       {
          QName portName = epMetaData.getQName();
@@ -107,8 +107,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
@@ -116,20 +116,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)
@@ -142,7 +142,7 @@
 
       String seiClassName = seiClass.getName();
       EndpointMetaData epMetaData = serviceMetaData.getEndpointByServiceEndpointInterface(seiClassName);
-      
+
       if (epMetaData == null && serviceMetaData.getEndpoints().size() == 1)
       {
          epMetaData = serviceMetaData.getEndpoints().get(0);
@@ -151,7 +151,7 @@
 
       if (epMetaData == null)
          throw new WebServiceException("Cannot get port meta data for: " + seiClassName);
-      
+
       return getPortInternal(epMetaData, seiClass);
    }
 
@@ -172,9 +172,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.
     */
 
@@ -207,12 +207,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());
       }
@@ -288,7 +288,7 @@
             impl.initHandlerChain(epMetaData, HandlerType.ENDPOINT);
             impl.initHandlerChain(epMetaData, HandlerType.POST);
          }
-         
+
          ExecutorService executor = (ExecutorService)getExecutor();
          ClientProxy handler = new ClientProxy(executor, new ClientImpl(epMetaData, handlerResolver));
          ClassLoader cl = epMetaData.getClassLoader();
@@ -304,13 +304,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: trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -52,9 +52,9 @@
    // provide logging
    private static Logger log = Logger.getLogger(ClientEndpointMetaData.class);
 
-   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: trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -78,6 +78,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
@@ -111,10 +113,11 @@
    // The operation meta data cache
    private transient Map<Method,OperationMetaData> methodCache = new HashMap<Method,OperationMetaData>();
 
-   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
@@ -131,6 +134,11 @@
       return portName;
    }
 
+   public QName getInterfaceQName()
+   {
+      return interfaceQName;
+   }
+
    public String getConfigFile()
    {
       return configFile;

Modified: trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/OperationMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -21,12 +21,13 @@
  */
 package org.jboss.ws.metadata;
 
-// $Id: OperationMetaData.java 740 2006-08-14 08:07:47Z thomas.diesler at jboss.com
-// $
+// $Id$
 
 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;
@@ -46,9 +47,8 @@
 import org.w3c.dom.Element;
 
 /**
- * An Operation component describes an operation that a given interface
- * supports.
- * 
+ * An Operation component describes an operation that a given interface supports.
+ *
  * @author Thomas.Diesler at jboss.org
  * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
  * @since 12-May-2004
@@ -62,28 +62,20 @@
    private EndpointMetaData epMetaData;
 
    private QName qname;
-
    private QName responseName;
-
    private String javaName;
-
    private Method javaMethod;
-
    private boolean oneWay;
-
    private String soapAction;
-
    private List<ParameterMetaData> parameters = new ArrayList<ParameterMetaData>();
-
    private List<FaultMetaData> faults = new ArrayList<FaultMetaData>();
-
    private ParameterMetaData returnParam;
 
    public OperationMetaData(QName qname, String javaName)
    {
       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);
    }
 
@@ -169,9 +161,7 @@
       return javaName;
    }
 
-   /**
-    * Lazily load the java method. The SEI class loader may not be available at
-    * creation time
+   /** Lazily load the java method. The SEI class loader may not be available at creation time
     */
    public Method getJavaMethod()
    {
@@ -188,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
-                  {
-                     boolean matchedMethodParams = compareMethodParams(methodTypes, true) || compareMethodParams(methodTypes, false);
-                     boolean matchedReturnParam = true;
-                     
-                     if (matchedMethodParams)
-                     {
-                        ParameterMetaData returnMetaData = getReturnParameter();
-                        if (returnMetaData != null)
-                        {
-                           matchedReturnParam = matchParameter(returnMetaData, returnType, true) || matchParameter(returnMetaData, returnType, false);
-                        }
-                        if (returnMetaData == null && returnType != void.class)
-                        {
-                           matchedReturnParam = false;
-                        }
-                     }
 
-                     if (matchedMethodParams && matchedReturnParam)
-                     {
-                        log.debug("Found best matching java method: " + method);
-                        javaMethod = method;
-                        break;
-                     }
-
-                     if (matchedMethodParams == false)
-                     {
-                        log.debug("Method parameters don't match: " + method);
-                        continue;
-                     }
-                     
-                     if (matchedReturnParam == false)
-                     {
-                        log.debug("Method return parameter doesn't match: " + method);
-                        continue;
-                     }
+                  // compare params by assignability
+                  if (matchParameters(method, false))
+                  {
+                     log.debug("Found possible matching java method: " + method);
+                     javaMethod = method;
+                     break;
                   }
                }
             }
@@ -261,9 +217,7 @@
       return javaMethod;
    }
 
-   /**
-    * Return true if this is a generic message style destination that takes a
-    * org.w3c.dom.Element
+   /** Return true if this is a generic message style destination that takes a org.w3c.dom.Element
     */
    public boolean isMessageEndpoint()
    {
@@ -279,33 +233,26 @@
       return isMessageEndpoint;
    }
 
-   private boolean compareMethodParams(Class[] methodParams, boolean matchByJavaTypeName)
+   private boolean compareMethodParams(Class[] methodParams, boolean matchByTypeName)
    {
-      log.trace("Compare method params by type name: " + matchByJavaTypeName);
+      log.trace("Compare method params by type name: " + matchByTypeName);
 
-      boolean pass = true;
-      boolean countMatch = (parameters.size() == methodParams.length);
-      
-      if (countMatch == false)
-      {
+      boolean pass = (parameters.size() == methodParams.length);
+      if (pass == false)
          log.trace("Unmatched parameter count: " + parameters.size() + "!=" + methodParams.length);
-         pass = false;
-      }
-      else
+
+      for (int i = 0; pass && i < methodParams.length; i++)
       {
-         for (int i = 0; pass && i < methodParams.length; i++)
-         {
-            ParameterMetaData paramMetaData = parameters.get(i);
-            pass = matchParameter(paramMetaData, methodParams[i], matchByJavaTypeName);
-         }
+         ParameterMetaData paramMetaData = parameters.get(i);
+         pass = matchParameter(paramMetaData, methodParams[i], matchByTypeName);
       }
       return pass;
    }
 
-   private boolean matchParameter(ParameterMetaData paramMetaData, Class methodParam, boolean matchByJavaTypeName)
+   private boolean matchParameter(ParameterMetaData paramMetaData, Class methodParam, boolean matchByTypeName)
    {
       QName xmlType = paramMetaData.getXmlType();
-      String javaTypeName = paramMetaData.getJavaTypeName();
+      String javaType = paramMetaData.getJavaTypeName();
 
       boolean pass = true;
       if (paramMetaData != returnParam && paramMetaData.getMode() != ParameterMode.IN)
@@ -325,22 +272,21 @@
          // In case the parameter java type has not been initialized
          // This happens when the UMDM is build from WSDL only (i.e. JAXWS Service)
          TypeMappingImpl typeMapping = epMetaData.getServiceMetaData().getTypeMapping();
-         if (javaTypeName == null)
+         if (javaType == null)
          {
-            javaTypeName = methodParam.getName();
-            paramMetaData.setJavaTypeName(javaTypeName);
-            log.debug("Set parameter java type from method param: " + javaTypeName);
+            javaType = methodParam.getName();
+            paramMetaData.setJavaTypeName(javaType);
+            log.debug("Set parameter java type from method param: " + javaType);
 
             if (epMetaData.getType() == Type.JAXWS)
             {
-               log.debug("Register parameter type from " + javaTypeName + " to " + xmlType);
                typeMapping.register(methodParam, xmlType, new JAXBSerializerFactory(), new JAXBDeserializerFactory());
             }
          }
 
-         if (matchByJavaTypeName)
+         if (matchByTypeName)
          {
-            pass = methodParam.getName().equals(javaTypeName);
+            pass = methodParam.getName().equals(javaType);
          }
          else
          {
@@ -357,7 +303,7 @@
          }
       }
 
-      String name = (matchByJavaTypeName) ? paramMetaData.getJavaTypeName() : paramMetaData.getJavaType().getName();
+      String name = (matchByTypeName) ? paramMetaData.getJavaTypeName() : paramMetaData.getJavaType().getName();
       log.trace((pass ? "Matched" : "Unmatched") + " parameter: " + name + " == " + methodParam.getName());
       return pass;
    }
@@ -449,6 +395,7 @@
    {
       log.trace("setReturnParameter: " + returnParam);
       returnParam.setMode(ParameterMode.OUT);
+      returnParam.setIndex(-1);
       this.returnParam = returnParam;
       assertOneWayOperation();
    }
@@ -497,8 +444,7 @@
    }
 
    // 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
+   // operation marked @Oneway has a return value, declares any checked exceptions or has any
    // INOUT or OUT parameters.
    private void assertOneWayOperation()
    {
@@ -585,4 +531,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: trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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,70 @@
       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());
-      
+      buffer.append("\n index=" + index);
+
       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: trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -66,12 +66,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)

Modified: trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/UnifiedMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -68,6 +68,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;
 
@@ -106,7 +107,7 @@
       String prefix = "java:/jaas/";
       if (domain != null && domain.startsWith(prefix))
          domain = domain.substring(prefix.length());
-      
+
       this.securityDomain = domain;
    }
 
@@ -180,7 +181,7 @@
       //buffer.append("\n resourceLoader: " + resourceLoader);
       //buffer.append("\n classLoader: " + classLoader);
       buffer.append("\n");
-      
+
       for (ServiceMetaData serviceMetaData : services)
       {
          buffer.append(serviceMetaData);

Modified: trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/DOMTypes.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -24,7 +24,7 @@
 import javax.xml.namespace.QName;
 
 import org.jboss.util.NotImplementedException;
-import org.jboss.ws.utils.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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Reader.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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;
+
    // Temporary files used by this reader.
    private List<File> tempFiles = new ArrayList<File>();
 
@@ -469,6 +474,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);
@@ -490,87 +496,130 @@
          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.setMessageName(srcMessage.getQName());
+               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)));
+               else
+                  messagePartToElementName(srcWsdl, srcPortType, srcOperation, srcMessage, srcPart);
             }
-
-            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());
+            rpcInput.setMessageName(srcMessage.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
-            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()));
+            // Lets remember the Message name
+            destOutput.setMessageName(srcMessage.getQName());
+            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);
+            destOutput.setPartName(srcPart.getName());
 
-            // 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
+               messagePartToElementName(srcWsdl, srcPortType, srcOperation, srcMessage, srcPart);
          }
       }
-      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"));
+         rpcOutput.setMessageName(srcMessage.getQName());
+         destOperation.addOutput(rpcOutput);
       }
    }
 
@@ -604,16 +653,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);
       }
 
@@ -636,94 +683,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)
@@ -768,15 +794,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>
@@ -790,10 +827,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)
@@ -823,7 +862,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)
       {
@@ -832,117 +870,109 @@
          {
             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");
             destBindingOperation.setSOAPAction(getOptionalAttribute(domElement, "soapAction"));
          }
       }
-      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() + "Response"));
+            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);
          }
@@ -952,18 +982,21 @@
             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)
+            if (elementName == null)
+               throw new WSException("Could not determine element name from header: " + partName);
+
+            reference.addSoapHeader(new WSDLSOAPHeader(elementName, 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);
+               callback.removeReference(elementName);
             }
+            else
+            {
+               // Just in case
+               callback.removeRPCPart(partName);
+            }
          }
          else if (extElement instanceof MIMEMultipartRelated)
          {
@@ -997,20 +1030,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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL11Writer.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -36,6 +36,7 @@
 import org.jboss.ws.utils.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)
@@ -175,11 +155,13 @@
       for (int i = 0; i < len; i++)
       {
          WSDLInterfaceOperationOutfault fault = faults[i];
-         QName xmlName = fault.getRef();
-         String exceptionName = xmlName.getLocalPart();
+         String exceptionName = fault.getRef().getLocalPart();
          if (writtenFaultMessages.contains(exceptionName))
             continue;
 
+         WSDLInterfaceFault interfaceFault = operation.getWsdlInterface().getFault(new NCName(exceptionName));
+         QName xmlName = interfaceFault.getElement();
+
          buffer.append("<message name='" + exceptionName + "' >");
          String prefix = wsdl.getPrefix(xmlName.getNamespaceURI());
          String xmlNameStr = prefix + ":" + xmlName.getLocalPart();
@@ -190,56 +172,68 @@
       }
    }
 
-   private void appendInputParts(StringBuilder buffer, WSDLInterfaceOperationInput input, int index)
+   private String getReferenceString(QName name)
    {
-      boolean header = input.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null;
-      if (wsdlStyle.equals(Constants.RPC_LITERAL) && !header)
+      String namespaceURI = name.getNamespaceURI();
+      String prefix = wsdl.getPrefix(namespaceURI);
+      if (prefix == null)
+         throw new WSException("Prefix not bound for namespace: " + namespaceURI);
+
+      return prefix + ":" + name.getLocalPart();
+   }
+
+   private void appendMessageParts(StringBuilder buffer, WSDLInterfaceMessageReference reference)
+   {
+      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())
+         {
+            buffer.append("<part name='" + part.getName()).append('\'');
+            buffer.append(" type='" + getReferenceString(part.getType()) + "'/>");
+         }
       }
-      //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();
+         buffer.append("<part name='" + reference.getPartName() + '\'');
+         buffer.append(" element='" + getReferenceString(element) + "'/>");
       }
+
+      WSDLBindingMessageReference bindingReference = getBindingReference(reference);
+      if (bindingReference == null)
+         return;
+
+      for (WSDLSOAPHeader header : bindingReference.getSoapHeaders())
+      {
+         if (header.isIncludeInSignature());
+         {
+            QName element = header.getElement();
+            buffer.append("<part name='" + header.getPartName() + '\'');
+            buffer.append(" element='" + getReferenceString(element) + "'/>");
+         }
+      }
    }
 
-   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 +253,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 +276,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 +296,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,152 +326,104 @@
       }
    }
 
-   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("WSDl 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";
-
-                  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());
-               }
-            }
-
-            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("/>");
-
+            appendSOAPBinding(buffer, wsdlInterface, operation, outputs);
             buffer.append("</output>");
          }
 
          //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++)
+         if (faults != null)
          {
-            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 + "'";
+            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>");
+         }
+      }
+   }
 
-            //String cleanref = utils.chop(utils.getFormattedString(elt), "Error");
-            buffer.append("<fault  " + n + ">");
-            buffer.append("<" + soapPrefix + ":fault  " + n + " use='literal' />");
-            buffer.append("</fault>");
+   private void appendSOAPBinding(StringBuilder buffer, WSDLInterface wsdlInterface, WSDLBindingOperation operation, WSDLBindingMessageReference[] inputs)
+   {
+      String tns = wsdl.getTargetNamespace();
+      WSDLInterfaceOperation interfaceOperation = wsdlInterface.getOperation(new NCName(operation.getRef().getLocalPart()));
+      WSDLInterfaceMessageReference reference = (inputs instanceof WSDLBindingOperationInput[]) ? interfaceOperation.getInputs()[0]
+            : interfaceOperation.getOutputs()[0];
+
+      StringBuilder bodyParts = new StringBuilder();
+      if (Constants.DOCUMENT_LITERAL == wsdlStyle)
+      {
+         bodyParts.append(reference.getPartName());
+      }
+      else
+      {
+         for (WSDLRPCPart part : reference.getChildParts())
+         {
+            if (bodyParts.length() > 0)
+               bodyParts.append(" ");
+            bodyParts.append(part.getName());
          }
+      }
 
-         buffer.append("</operation>");
+      StringBuilder soapHeader = new StringBuilder();
+      for (WSDLSOAPHeader header : inputs[0].getSoapHeaders())
+      {
+         if (header.isIncludeInSignature())
+         {
+            String messageName = wsdlInterface.getName() + "_" + operation.getRef().getLocalPart();
+            if (reference instanceof WSDLInterfaceOperationOutput)
+               messageName += "Response";
+            soapHeader.append("<").append(soapPrefix).append(":header use='literal' message='tns:").append(messageName);
+            soapHeader.append("' part='").append(header.getElement().getLocalPart()).append("'/>");
+         }
       }
+
+      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);
+      }
+      else
+      {
+         buffer.append("/>");
+      }
    }
 
    private String getBindingOperationPattern(WSDLBindingOperation operation)
@@ -554,5 +467,4 @@
       buffer.append("<" + soapPrefix + ":address location='" + endpoint.getAddress() + "'/>");
       buffer.append("</port>");
    }
-
-}
+}
\ No newline at end of file

Modified: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDL20Writer.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: 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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationInput.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperationOutput.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceFault.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: 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)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceMessageReference.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -0,0 +1,246 @@
+/*
+ * 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
+    */
+   private String partName;
+
+   /**
+    * Used for WSDL 1.1
+    */
+   private QName messageName;
+
+   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();
+   }
+
+   /**
+    * Gets the child part associated with this message reference by part name.
+    * This is only used for RPC style, and currently only supported by WSDL 1.1.
+    *
+    * @param name the part name
+    * @return the part or null if not found
+    */
+   public WSDLRPCPart getChildPart(String name)
+   {
+      return childParts.get(name);
+   }
+
+   /**
+    * 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 message name.
+    *
+    * @param messageName The part name
+    */
+   public void setMessageName(QName messageName)
+   {
+      this.messageName = messageName;
+   }
+
+   /**
+    * Gets the WSDL 1.1 message name.
+    *
+    * @return the message name
+    */
+   public QName getMessageName()
+   {
+      return messageName;
+   }
+
+   /**
+    * 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: 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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperation.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationInput.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationOutput.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLInterfaceOperationPart.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLMIMEPart.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: 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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCPart.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: 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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLRPCSignatureItem.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: 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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLSOAPHeader.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: 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: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -863,4 +863,34 @@
       primitiveMap.put("java.lang.Boolean", "boolean");
       primitiveMap.put("java.lang.Byte", "byte");
    }
+
+   public static WSDLInterfaceOperationOutput getWsdl11Output(WSDLInterfaceOperation operation)
+   {
+      WSDLInterfaceOperationOutput[] outputs = operation.getOutputs();
+      if (outputs == null)
+         return null;
+
+      switch (outputs.length)
+      {
+         case 0: return null;
+         case 1: return outputs[0];
+      }
+
+      throw new WSException("Only Request-Only and Request-Response MEPs are allowed");
+   }
+
+   public static WSDLInterfaceOperationInput getWsdl11Input(WSDLInterfaceOperation operation)
+   {
+      WSDLInterfaceOperationInput[] inputs = operation.getInputs();
+      if (inputs == null)
+         return null;
+
+      switch (inputs.length)
+      {
+         case 0: return null;
+         case 1: return inputs[0];
+      }
+
+      throw new WSException("Only Request-Only and Request-Response MEPs are allowed");
+   }
 }
\ No newline at end of file

Modified: trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLWriter.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLWriter.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/metadata/wsdl/WSDLWriter.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -50,7 +50,7 @@
 
    protected WSDLDefinitions wsdl;
    protected WSDLUtils utils = WSDLUtils.getInstance();
-   
+
    // The soap prefix
    protected String soapPrefix = "soap";
 
@@ -114,11 +114,22 @@
 
    protected void appendTypes(StringBuilder buffer)
    {
-      buffer.append("<types>");
-      JBossXSModel xsM = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
-      String schema = xsM.serialize();
-      buffer.append(schema);
-      buffer.append("</types>");
+      WSDLTypes wsdlTypes = wsdl.getWsdlTypes();
+      if (wsdlTypes instanceof XSModelTypes)
+      {
+         buffer.append("<types>");
+         JBossXSModel xsM = WSDLUtils.getSchemaModel(wsdlTypes);
+         String schema = xsM.serialize();
+         buffer.append(schema);
+         buffer.append("</types>");
+      }
+      else if (wsdlTypes instanceof DOMTypes)
+      {
+         synchronized (wsdlTypes)
+         {
+            buffer.append(DOMWriter.printNode(((DOMTypes)wsdlTypes).getElement(), true));
+         }
+      }
    }
 
    protected abstract void appendInterfaces(StringBuilder buffer);

Modified: trunk/src/main/java/org/jboss/ws/tools/JavaToWSDL11.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/JavaToWSDL11.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/JavaToWSDL11.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -156,18 +156,15 @@
     */
    public WSDLDefinitions generate(Class endpoint)
    {
-      WSDLDefinitions wsdl = new WSDLDefinitions();
-      wsdl.setWsdlTypes(new XSModelTypes());
-      wsdl.setWsdlNamespace(this.wsdlNamespace);
+      WSDLDefinitions wsdl = null;
 
       if (umd != null)
       {
-         JavaToWSDLHelper helper = new JavaToWSDLHelper(wsdl, wsdlNamespace);
+         JavaToWSDLHelper helper = new JavaToWSDLHelper();
          try
          {
-            helper.setFeatures(features);
             helper.setPackageNamespaceMap(packageNamespaceMap);
-            handleJavaToWSDLGeneration(helper, endpoint.getName());
+            wsdl = handleJavaToWSDLGeneration(helper, endpoint.getName());
 
             typeMapping = helper.getTypeMapping();
          }
@@ -204,57 +201,22 @@
    }
 
    //PRIVATE METHODS
-   private void handleJavaToWSDLGeneration(JavaToWSDLHelper helper, String endpointName) throws IOException
+   private WSDLDefinitions handleJavaToWSDLGeneration(JavaToWSDLHelper helper, String endpointName) throws IOException
    {
+      WSDLDefinitions wsdl = null;
       if (umd == null)
          throw new WSException("Unified Meta Data Model is null");
 
-      for (ServiceMetaData serviceMetaData : umd.getServices())
+      for (ServiceMetaData service : umd.getServices())
       {
-         for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
+         EndpointMetaData epMetaData = service.getEndpointByServiceEndpointInterface(endpointName);
+         if (epMetaData != null)
          {
-            // FIXME - The API needs to be reworked instead of using hacks like this
-            if (!endpointName.equals(epMetaData.getServiceEndpointInterfaceName()))
-               continue;
-
-            // FIXME - We should store the port type
-            QName portName = epMetaData.getQName();
-            String intfName = portName.getLocalPart();
-
-            String targetNamespace = portName.getNamespaceURI();
-            String bindingId = epMetaData.getBindingId();
-            helper.appendDefinitions(targetNamespace, bindingId);
-
-            if (intfName.endsWith("Port"))
-               intfName = intfName.substring(0, intfName.length() - 4);
-
-            for (OperationMetaData opMetaData : epMetaData.getOperations())
-            {
-               //Generate Types for the individual parameters
-               for (ParameterMetaData paramMetaData : opMetaData.getParameters())
-               {
-                  helper.generateTypesForXSD(paramMetaData);
-               }
-
-               for (FaultMetaData faultMetaData : opMetaData.getFaults())
-               {
-                  helper.generateTypesForXSD(faultMetaData);
-               }
-
-               ParameterMetaData returnMetaData = opMetaData.getReturnParameter();
-               if (returnMetaData != null)
-               {
-                  helper.generateTypesForXSD(returnMetaData);
-               }
-
-               helper.generateInterfaces(opMetaData, intfName);
-               helper.generateBindings(opMetaData, intfName + "Binding");
-            }
-
-            helper.generateServices(epMetaData, intfName);
-            javaWsdlMapping = helper.getJavaWsdlMapping();
+            wsdl = helper.generate(service);
             break;
          }
       }
+      javaWsdlMapping = helper.getJavaWsdlMapping();
+      return wsdl;
    }
 }
\ No newline at end of file

Added: trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/tools/SourceWrapperGenerator.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/WSDLToJava.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -36,6 +36,7 @@
 import org.apache.xerces.xs.XSComplexTypeDefinition;
 import org.apache.xerces.xs.XSElementDeclaration;
 import org.apache.xerces.xs.XSModelGroup;
+import org.apache.xerces.xs.XSObject;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSParticle;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
@@ -54,6 +55,7 @@
 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.WSDLUtils;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
 import org.jboss.ws.metadata.wsdl.xsd.SchemaUtils;
@@ -195,7 +197,7 @@
    public void setPackageNamespaceMap(Map<String, String> map)
    {
      //Lets convert the package->namespace map to namespace->package map
-     Set<String> keys = map.keySet();
+     Set keys = map.keySet();
      Iterator<String> iter = keys.iterator();
      while(iter != null && iter.hasNext())
      {
@@ -252,9 +254,9 @@
    //                             PRIVATE METHODS
    //***************************************************************************
 
-   private boolean shouldUnwrap()
+   private boolean isDocument()
    {
-      return unwrap && Constants.DOCUMENT_LITERAL.equals(style);
+      return Constants.DOCUMENT_LITERAL.equals(style);
    }
 
    private void unwrapRequest(StringBuilder buf, XSTypeDefinition xt) throws IOException
@@ -354,7 +356,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();
@@ -363,68 +365,123 @@
          throw new IllegalArgumentException("Interface " + itfname + " doesn't have operations");
       int len = ops != null ? ops.length : 0;
 
+
+      // FIXME - Add support for headers
       for (int i = 0; i < len; i++)
       {
          WSDLInterfaceOperation op = ops[i];
          //TODO: Take care of multiple outputs
-         WSDLInterfaceOperationOutput[] outs = op.getOutputs();
-         String returnType = getReturnType(outs);
-         buf.append("  public " + returnType + "  ");
-         buf.append(ToolsUtils.firstLetterLowerCase(op.getName().toString()) );
-         buf.append("(");
-         WSDLInterfaceOperationInput[] ins = op.getInputs();
-         int inlen = ins != null? ins.length :0;
-         for (int j = 0; j < inlen; j++)
+         String returnType = null;
+
+         StringBuilder paramBuffer = new StringBuilder();
+         boolean first = true;
+         WSDLInterfaceOperationInput input = WSDLUtils.getWsdl11Input(op);
+         if (input != null)
          {
-            if (j > 0) buf.append(",");
-            WSDLInterfaceOperationInput in = ins[j];
-            QName xmlName = in.getElement();
-            QName xmlType = in.getXMLType();
-            JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
-            XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
 
-            if (shouldUnwrap())
+            if (isDocument())
             {
-               unwrapRequest(buf, xt);
-               break;
+               QName xmlName = input.getElement();
+               QName xmlType = input.getXMLType();
+               JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
+               XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
+
+               if (unwrap)
+               {
+                  unwrapRequest(paramBuffer, xt);
+               }
+               else
+               {
+                  generateParameter(paramBuffer, input, xmlName, xmlType, xsmodel, xt, false, true);
+                  paramBuffer.append(" ").append(getMethodParam(xmlName));
+               }
             }
+            else
+            {
+               for (WSDLRPCPart part :input.getChildParts())
+               {
+                  if (!first)
+                  {
+                     paramBuffer.append(",");
+                     first = false;
+                  }
+                  QName xmlName = new QName(part.getName());
+                  QName xmlType = part.getType();
+                  JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
+                  XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
 
-            generateParameter(buf, in, xmlName, xmlType, xsmodel, xt, false, true);
-            buf.append(" ").append(getMethodParam(xmlName));
+                  generateParameter(paramBuffer, input, xmlName, xmlType, xsmodel, xt, false, true);
+                  paramBuffer.append(" ").append(getMethodParam(xmlName));
+               }
+            }
+
          }
 
-         //Check for out holder only
-         int lenOuts = outs != null ? outs.length : 0;
-         if ((!shouldUnwrap()) && lenOuts > 1)
+         // This needs to be rewritten, custom types, and custom holders should be supported
+         WSDLInterfaceOperationInput output = WSDLUtils.getWsdl11Input(op);
+         if (output != null)
          {
-            // This needs to be rewritten, custom types, and custom holders should be supported
-            for (int m = 1; m < lenOuts; m++)
+            if (isDocument())
             {
-               if (this.isInOutHolder(outs[m]))
-                  continue;
-               buf.append(",");
-               QName xmlName = outs[m].getElement();
-               QName xmlType = outs[m].getXMLType();
+               QName xmlName = output.getElement();
+               QName xmlType = output.getXMLType();
                JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
-               XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(), xmlType.getNamespaceURI());
+               XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
 
-               boolean primitive = true;
-               WrappedArray wrappedArray = new WrappedArray(xt);               
-               if (wrappedArray.unwrap())
+               if (unwrap)
                {
-                  xt = wrappedArray.xt;
-                  xmlType = wrappedArray.xmlType;
-                  primitive = !wrappedArray.nillable;                  
+                  returnType = unwrapResponse(xt);
                }
+               else if (output.getPartName().equals(input.getPartName()))
+               {
+                  // IN-OUT, we skip it
+               }
+               else
+               {
+                  returnType = getReturnType(xmlName, xmlType, xt);
+               }
+            }
+            else
+            {
+               boolean returnParameter = true;
+               for (WSDLRPCPart part : output.getChildParts())
+               {
+                  // IN-OUT
+                  if (input.getChildPart(part.getName()) != null)
+                     continue;
 
-               if (xt instanceof XSSimpleTypeDefinition)
-                  xmlType = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition)xt);
+                  QName xmlName = new QName(part.getName());
+                  QName xmlType = part.getType();
+                  JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
+                  XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
 
-               Class cls = this.getJavaType(xmlType, primitive);
-               buf.append(utils.getHolder(cls).getName()).append(" ").append(getMethodParam(xmlName));
+                  if (returnParameter)
+                  {
+                     returnType = getReturnType(xmlName, xmlType, xt);
+                     returnParameter = false;
+                  }
+                  else
+                  {
+                     if (!first)
+                     {
+                        paramBuffer.append(",");
+                        first = false;
+                     }
+
+                     generateParameter(paramBuffer, output, xmlName, xmlType, xsmodel, xt, false, true);
+                     paramBuffer.append(" ").append(getMethodParam(xmlName));
+                  }
+               }
             }
          }
 
+         if (returnType == null)
+            returnType = "void";
+
+         buf.append("  public " + returnType + "  ");
+         buf.append(ToolsUtils.firstLetterLowerCase(op.getName().toString()) );
+         buf.append("(").append(paramBuffer);
+
          buf.append(") throws ");
          //Generate the Exception Types
          WSDLInterfaceOperationOutfault[] outfaults = op.getOutfaults();
@@ -436,7 +493,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());
@@ -448,14 +505,7 @@
 
             Class cl = getJavaType(faultXMLType, false);
             if (cl == null)
-            {
-               String exceptionName = xt.getName();
-               if (exceptionName==null)
-               {
-                  exceptionName = faultXMLName.getLocalPart();
-               }
-               buf.append(seiPkgName + "." + utils.firstLetterUpperCase(exceptionName));
-            }
+               buf.append(seiPkgName + "." + cleanUpFaultName(faultXMLType.getLocalPart()));
             else
                buf.append( cl.getName());
             buf.append( "," );
@@ -545,20 +595,10 @@
       }
    }
 
-   private String getReturnType(WSDLInterfaceOperationOutput[] outs) throws IOException
+   private String getReturnType(QName xmlName, QName xmlType, XSTypeDefinition xt) throws IOException
    {
-      if (outs == null || outs.length == 0) return "void ";
-      WSDLInterfaceOperationOutput out = outs[0];
-
-      QName xmlType = out.getXMLType();
-      QName xmlName = out.getElement();
-
       JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
-      XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
 
-      if (shouldUnwrap())
-         return unwrapResponse(xt);
-
       boolean primitive = true;
       WrappedArray wrappedArray = new WrappedArray(xt);
       String arraySuffix = "";
@@ -574,7 +614,6 @@
          xmlType = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition) xt);
 
       Class cls = getJavaType(xmlType, primitive);
-      //Class cls = typeMapping.getJavaType(qname,true);
 
       if(xt instanceof XSComplexTypeDefinition)
          generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, xmlName.getLocalPart());
@@ -587,17 +626,40 @@
          className = utils.firstLetterUpperCase(className);
          return seiPkgName + "." + className + arraySuffix;
       }
-
-      if(isInOutHolder(out))
-         return "void"; //Taken care by the input args
-      if(isOutHolder(out))
-         return utils.getHolder(cls).getName();
       if(cls.isArray())
          return JavaUtils.getSourceName(cls);
+
       return  cls.getName() + arraySuffix;
    }
 
    /**
+    * WSDL may have appended the Faults with 'Fault' or 'Error'
+    * @param faultname
+    * @return
+    */
+   private String cleanUpFaultName(String faultname)
+   {
+      //Clean up the faultname from Error and Fault
+      boolean endsfault = faultname.endsWith("Fault");
+
+      if (endsfault)
+      {
+         int index = faultname.lastIndexOf("Fault");
+         faultname = faultname.substring(0, index);
+      }
+      else
+      {
+         boolean endsError = faultname.endsWith("Error");
+         if (endsError)
+         {
+            int index = faultname.lastIndexOf("Error");
+            faultname = faultname.substring(0, index);
+         }
+      }
+      return faultname;
+   }
+
+   /**
     * Check if an holder is required for the input type
     * @param wout
     * @param cls
@@ -623,27 +685,6 @@
          throw new WSException("TypeMapping has not been set.");
    }
 
-   private boolean isInOutHolder(WSDLInterfaceOperationOutput wout)
-   {
-      //Now check if the part exists in both input and output => Need Holder
-      WSDLInterfaceOperation op =  wout.getWsdlOperation();
-      QName el = wout.getElement();
-
-      WSDLInterfaceOperationInput inp = op.getInput(el);
-      return inp != null;
-   }
-
-   private boolean isOutHolder(WSDLInterfaceOperationOutput wout)
-   {
-      if(isInOutHolder(wout))
-         return false;
-      // Case when there are multiple outputs - need holders
-      WSDLInterfaceOperationOutput[] ops = wout.getWsdlOperation().getOutputs();
-      if(ops != null && ops.length > 1)
-         return true;
-      return false;
-   }
-
    private Class getJavaType(QName qname, boolean primitive)
    {
       Class cls = typeMapping.getJavaType(qname, primitive);

Modified: trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/helpers/JavaToWSDLHelper.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -47,6 +47,8 @@
 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.ParameterMetaData.WrappedParameter;
 import org.jboss.ws.metadata.jaxrpcmapping.ExceptionMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
 import org.jboss.ws.metadata.jaxrpcmapping.JavaXmlTypeMapping;
@@ -77,6 +79,7 @@
 import org.jboss.ws.metadata.wsdl.WSDLService;
 import org.jboss.ws.metadata.wsdl.WSDLTypes;
 import org.jboss.ws.metadata.wsdl.WSDLUtils;
+import org.jboss.ws.metadata.wsdl.XSModelTypes;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSElementDeclaration;
 import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
 import org.jboss.ws.metadata.wsdl.xmlschema.WSSchemaUtils;
@@ -84,6 +87,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,53 +95,51 @@
  *  @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;
-
-   protected String wsdlNamespace =  Constants.NS_WSDL11; //Default - wsdl11;
-
-   protected JavaToXSDIntf javaToXSD = new JavaToXSD();
-
-   protected Class seiClass = null;
-
+   private JavaToXSDIntf javaToXSD = new JavaToXSD();
    private JavaWsdlMapping javaWsdlMapping = new JavaWsdlMapping();
-
    private Map<QName, JavaXmlTypeMapping> mappedTypes = new HashMap<QName, JavaXmlTypeMapping>();
-
    private Set<String> mappedPackages = new HashSet<String>();
-
-   protected Map<String,String> packageNamespaceMap = new HashMap<String,String>();
-
+   private Map<String,String> packageNamespaceMap = new HashMap<String,String>();
    private Set<String> mappedExceptions = new HashSet<String>();
 
-   // Features as represented by Constants
-   protected Map<String, Boolean> features = new HashMap<String, Boolean>();
-
-   /**
-    * Default ctr
-    */
-   public JavaToWSDLHelper(WSDLDefinitions wsdl, String wsdlNS)
+   protected void processTypes()
    {
-      this.wsdl = wsdl;
-      this.wsdlNamespace = wsdlNS;
+      // All type processing is done in processService()
+      wsdl.setWsdlTypes(new XSModelTypes());
    }
 
-   public void appendDefinitions(String targetNamespace, String bindingId)
+   @Override
+   protected void processOperation(WSDLInterface wsdlInterface, WSDLBinding wsdlBinding, OperationMetaData operation)
    {
-      wsdl.setTargetNamespace(targetNamespace);
-      wsdl.registerNamespaceURI(targetNamespace, Constants.PREFIX_TNS);
-      wsdl.registerNamespaceURI(Constants.NS_SCHEMA_XSD, Constants.PREFIX_XSD);
-      if (wsdlNamespace.equals(Constants.NS_WSDL11))
+      super.processOperation(wsdlInterface, wsdlBinding, operation);
+
+      try
       {
-         if (CommonSOAPBinding.SOAP11HTTP_BINDING.equals(bindingId))
-            wsdl.registerNamespaceURI(Constants.NS_SOAP11, Constants.PREFIX_SOAP11);
-         else if (CommonSOAPBinding.SOAP12HTTP_BINDING.equals(bindingId))
-            wsdl.registerNamespaceURI(Constants.NS_SOAP12, Constants.PREFIX_SOAP12);
+         //Generate Types for the individual parameters, faults and return value
+         for (ParameterMetaData paramMetaData : operation.getParameters())
+         {
+            generateTypesForXSD(paramMetaData);
+         }
+
+         for (FaultMetaData faultMetaData : operation.getFaults())
+         {
+            generateTypesForXSD(faultMetaData);
+         }
+
+         ParameterMetaData returnMetaData = operation.getReturnParameter();
+         if (returnMetaData != null)
+         {
+            generateTypesForXSD(returnMetaData);
+         }
       }
+      catch (IOException io)
+      {
+         throw new WSException(io);
+      }
    }
 
-
    public void generateTypesForXSD(ParameterMetaData pmd) throws IOException
    {
       //Types always deals with TypeNamespace
@@ -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;
    }
 
@@ -184,189 +181,19 @@
         generateType(xmlType ,fmd.getJavaType(), null);
    }
 
-   public void generateInterfaces(OperationMetaData op , String intfName)
+   public void processEndpoint(WSDLService service, EndpointMetaData endpoint)
    {
-      WSDLUtils utils = WSDLUtils.getInstance();
-      if(op == null)
-         throw new IllegalArgumentException("Illegal Null Argument: op");
+      super.processEndpoint(service, endpoint);
 
-      WSDLInterface wsdlInterface = wsdl.getInterface(new NCName(intfName));
-      if(wsdlInterface  == null)
-      {
-         wsdlInterface = new WSDLInterface(wsdl);
-         wsdlInterface.setName(new NCName(intfName));
-         wsdl.addInterface(wsdlInterface);
-      }
-
-      QName xmlName = op.getQName();
-      String opname = xmlName.getLocalPart();
-      if(opname == null || opname.length() == 0)
-         throw new WSException("opname is null or blank");
-      //Operation Level
-      WSDLInterfaceOperation wsdlInterfaceOperation = new WSDLInterfaceOperation(wsdlInterface);
-      wsdlInterfaceOperation.setName(new NCName( opname ));
-      wsdlInterface.addOperation(wsdlInterfaceOperation);
-      if (op.getStyle() == Style.DOCUMENT)
-         wsdlInterfaceOperation.setStyle(Constants.URI_STYLE_IRI);
-      else
-         wsdlInterfaceOperation.setStyle(Constants.URI_STYLE_RPC);
-
-      if (op.isOneWay())
-         wsdlInterfaceOperation.setPattern(Constants.WSDL20_PATTERN_IN_ONLY);
-      else
-         wsdlInterfaceOperation.setPattern(Constants.WSDL20_PATTERN_IN_OUT);
-
-      List<WSDLInterfaceOperationOutput> holderOuts = new ArrayList<WSDLInterfaceOperationOutput>();
-
-      //Parameter Level
-      List<ParameterMetaData> pmds = op.getParameters();
-      for(ParameterMetaData pmd : pmds)
-      {
-         if (pmd.getMode() != ParameterMode.IN)
-         {
-            if(op.isOneWay())
-               throw new WSException(opname + " is a oneway operation and" +
-               " defines a holder");
-
-            holderOuts.add(getWSDLInterfaceOperationOutput(wsdlInterfaceOperation, pmd));
-            if (pmd.getMode() == ParameterMode.INOUT)
-               wsdlInterfaceOperation.addInput(getWSDLInterfaceOperationInput(wsdlInterfaceOperation, pmd));
-         }
-         else
-         {
-            wsdlInterfaceOperation.addInput(getWSDLInterfaceOperationInput(wsdlInterfaceOperation, pmd));
-         }
-      }
-
-      //Deal with Return Type
-      ParameterMetaData retpmd = op.getReturnParameter();
-      Class returnType = retpmd != null ? retpmd.getClass() : void.class;
-
-      if (returnType != null && !(void.class == returnType) )
-      {
-         WSDLInterfaceOperationOutput returnOutput = getWSDLInterfaceOperationOutput(wsdlInterfaceOperation, retpmd);
-         returnOutput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_RETURN_PART, null));
-         wsdlInterfaceOperation.addOutput(returnOutput);
-      }
-      //Deal with the temporary arraylist for holders
-      for (WSDLInterfaceOperationOutput wo : holderOuts)
-         wsdlInterfaceOperation.addOutput(wo);
-
-      List<FaultMetaData> fmds = op.getFaults();
-      for(FaultMetaData fmd: fmds)
-      {
-         generateWSDLFaults(wsdlInterfaceOperation, fmd.getXmlName());
-      }
+      // build JAX-RPC mapping info
+      buildServiceMapping(endpoint);
    }
 
-   public void generateBindings(OperationMetaData op , String bindName)
-   {
-      WSDLUtils utils = WSDLUtils.getInstance();
-      String intfName = utils.chop(bindName, "Binding");
-
-      WSDLBinding wsdlBinding = wsdl.getBinding(new NCName(bindName));
-      if(wsdlBinding == null)
-      {
-         wsdlBinding = new WSDLBinding(wsdl);
-         wsdlBinding.setName(new NCName(bindName));
-         wsdlBinding.setInterfaceName(new QName(wsdl.getTargetNamespace(),intfName));
-         wsdl.addBinding(wsdlBinding);
-      }
-
-      String opname = op.getQName().getLocalPart();
-      //Operation Level
-      WSDLBindingOperation wsdlBindingOperation = new WSDLBindingOperation(wsdlBinding);
-      wsdlBindingOperation.setRef(new QName(wsdl.getTargetNamespace(), opname));
-      wsdlBindingOperation.setSOAPAction(op.getSOAPAction());
-      wsdlBinding.addOperation(wsdlBindingOperation);
-
-      //TODO:FIXME JBWS-269
-      //Parameter Level
-
-      List<ParameterMetaData> pmds = op.getInputParameters();
-      for(ParameterMetaData pmd : pmds)
-      {
-         WSDLBindingOperationInput wsdlBindingOperationInput = new WSDLBindingOperationInput(wsdlBindingOperation);
-         wsdlBindingOperationInput.setMessageLabel(new NCName(pmd.getXmlName().getLocalPart()) );
-         wsdlBindingOperation.addInput(wsdlBindingOperationInput);
-      }
-
-      //Deal with Return Type
-      ParameterMetaData retpmd = op.getReturnParameter();
-      Class returnType = retpmd != null ? retpmd.getClass() : void.class;
-
-      if (returnType != null && !(void.class == returnType) )
-      {
-         WSDLBindingOperationOutput wsdlBindingOperationOutput = new WSDLBindingOperationOutput(wsdlBindingOperation);
-         wsdlBindingOperationOutput.setMessageLabel(new NCName(retpmd.getXmlName().getLocalPart()));
-         wsdlBindingOperation.addOutput(wsdlBindingOperationOutput);
-      }
-// What was this for?
-//      if(void.class == returnType)
-//      {
-//         WSDLBindingOperationOutput wsdlBindingOperationOutput = new WSDLBindingOperationOutput(wsdlBindingOperation);
-//         wsdlBindingOperation.addOutput(wsdlBindingOperationOutput);
-//      }
-
-      pmds = op.getOutputParameters();
-      for(ParameterMetaData pmd : pmds)
-      {
-         WSDLBindingOperationOutput wsdlBindingOperationOutput = new WSDLBindingOperationOutput(wsdlBindingOperation);
-         wsdlBindingOperationOutput.setMessageLabel(new NCName(pmd.getXmlName().getLocalPart()) );
-         wsdlBindingOperation.addOutput(wsdlBindingOperationOutput);
-      }
-
-      List<FaultMetaData> fmds = op.getFaults();
-      for(FaultMetaData fmd: fmds)
-      {
-         WSDLBindingFault f = new WSDLBindingFault(wsdlBinding);
-         String faultName = fmd.getXmlName().getLocalPart();
-         WSDLInterfaceFault intFault = wsdl.getInterface(new NCName(intfName)).getFault(new NCName(faultName));
-         if(intFault == null)
-            throw new WSException("Fault in WSDLInterface for name=" + faultName + " not found");
-         QName fqname = new QName(wsdl.getTargetNamespace(), faultName );
-         f.setRef(fqname);
-      }
-   }
-
-   public void generateServices(EndpointMetaData endpoint, String intfName)
-   {
-      if(endpoint == null)
-         throw new WSException("Illegal Null Argument: endpt");
-      String serviceName = endpoint.getServiceMetaData().getQName().getLocalPart();
-
-      //Create a WSDLService
-      WSDLService wsdlService = new WSDLService(wsdl);
-      wsdlService.setName( new NCName(serviceName) );
-      wsdl.addService(wsdlService);
-
-      String portName = endpoint.getQName().getLocalPart();
-
-      WSDLInterface wsdlInterface = wsdl.getInterface(new NCName(intfName));
-      if(wsdlInterface == null)
-         throw new WSException("WSDL Interface for name = " + intfName + " is null");
-
-      QName seiQName = wsdlInterface.getQName();
-      WSDLBinding wsdlBinding = wsdl.getBindings()[0];
-      NCName bindingName = wsdlBinding.getName();
-      QName bindingQName = new QName(wsdl.getTargetNamespace(), bindingName.toString());
-
-      wsdlService.setInterfaceName(seiQName);
-
-      WSDLEndpoint wsdlEndpoint = new WSDLEndpoint(wsdlService);
-      wsdlEndpoint.setName(new NCName(portName));
-      wsdlEndpoint.setBinding(bindingQName);
-      wsdlEndpoint.setAddress("REPLACE_WITH_ACTUAL_URL");
-      wsdlService.addEndpoint(wsdlEndpoint);
-
-      buildServiceMapping(endpoint, intfName);
-   }
-
    /*
     * Currently we only handle 1 endpoint on 1 service, this is the way everything
     * else is handled anyway.
     */
-   private void buildServiceMapping(EndpointMetaData endpoint, String interfaceName)
+   private void buildServiceMapping(EndpointMetaData endpoint)
    {
       QName origQName = endpoint.getServiceMetaData().getQName();
       String serviceInterfaceName = endpoint.getServiceEndpointInterface().getPackage().getName() + "." + origQName.getLocalPart();
@@ -384,6 +211,7 @@
 
       javaWsdlMapping.addServiceInterfaceMappings(serviceMapping);
 
+      String interfaceName = endpoint.getInterfaceQName().getLocalPart();
       ServiceEndpointInterfaceMapping seiMapping = new ServiceEndpointInterfaceMapping(javaWsdlMapping);
       seiMapping.setServiceEndpointInterface(endpoint.getServiceEndpointInterfaceName());
       seiMapping.setWsdlPortType(new QName(wsdl.getTargetNamespace(), interfaceName, "portTypeNS"));
@@ -400,12 +228,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 +246,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
             {
@@ -529,16 +357,6 @@
       this.javaToXSD.setPackageNamespaceMap(map);
    }
 
-   public void setEndpoint(Class cls)
-   {
-      this.seiClass = cls;
-   }
-
-   public void setFeatures(Map<String, Boolean> features)
-   {
-      this.features = features;
-   }
-
    public void setJavaToXSD(JavaToXSDIntf jxsd)
    {
       this.javaToXSD = jxsd;
@@ -662,152 +480,4 @@
 
       wsdl.registerNamespaceURI(xmlName.getNamespaceURI(), null);
    }
-
-   protected String getXMLNameForArray(QName el)
-   {
-      WSDLUtils utils = WSDLUtils.getInstance();
-      String xmlName = "";
-      String localpart = el.getLocalPart();
-
-      while(localpart.lastIndexOf("Array") > -1)
-      {
-         xmlName += "arrayOf";
-         localpart = utils.chop(localpart, "Array");
-      }
-      xmlName += localpart;
-
-      return xmlName;
-   }
-
-
-   /**
-    * Given a Java class, return the XML Type
-    *
-    * @param javaType
-    * @return
-    */
-
-   protected QName getXMLSchemaType(Class javaType)
-   {
-      LiteralTypeMapping ty = javaToXSD.getSchemaCreator().getTypeMapping();
-      QName qn = ty.getXMLType(javaType);
-      if( qn != null && (qn.getPrefix() == null || qn.getPrefix().length() == 0) )
-      {
-         String prefix = wsdl.getPrefix(qn.getNamespaceURI());
-         if( prefix != null)
-            qn = new QName( qn.getNamespaceURI(),qn.getLocalPart(),prefix);
-      }
-      return qn;
-   }
-
-   /**
-    * Given a XML Type, return the Java class
-    *
-    * @param xmlType
-    * @return
-    */
-   protected Class getJavaType(QName xmlType)
-   {
-      LiteralTypeMapping ty = javaToXSD.getSchemaCreator().getTypeMapping();
-      return ty.getJavaType(xmlType);
-   }
-
-   //PRIVATE METHODS
-   private boolean needsToolsOverride(Class paramType)
-   {
-      if(ByteArrayHolder.class == paramType)
-         return true;
-      return false;
-   }
-
-   private QName getOverrideQName(Class paramType)
-   {
-      if(ByteArrayHolder.class == paramType)
-         return Constants.TYPE_LITERAL_BASE64BINARY;
-      throw new WSException("paramType not recognized");
-   }
-
-   private void generateWSDLFaults(WSDLInterfaceOperation op, QName xmlName)
-   {
-      /**
-       * Idea behind faults is that there is a fault at the interface level to aid reuse.
-       * Operations that define faults just hold a reference to the faults at the interface level.
-       */
-      WSDLInterface wsdlInterface  = op.getWsdlInterface();
-      //    Check if the fault has already been added to the interface
-      WSDLInterfaceFault fault = wsdlInterface.getFault(new NCName(xmlName.getLocalPart()));
-      if(fault == null)
-      {
-         //Add the fault to the interface
-         fault = new WSDLInterfaceFault(wsdlInterface);
-         fault.setName(new NCName(xmlName.getLocalPart()));
-         fault.setXmlName(xmlName);
-         wsdlInterface.addFault(fault);
-      }
-
-      //Now add a operation fault
-      WSDLInterfaceOperationOutfault outFault = new WSDLInterfaceOperationOutfault(op);
-      outFault.setRef(xmlName);
-      op.addOutfault(outFault);
-   }
-
-   private WSDLInterfaceOperationOutput getWSDLInterfaceOperationOutput(WSDLInterfaceOperation intf, ParameterMetaData pmd)
-   {
-      QName xmlType = pmd.getXmlType();
-      QName xmlName = pmd.getXmlName();
-
-      String prefix = wsdl.getPrefix(xmlType.getNamespaceURI());
-      WSDLProperty wprop = new WSDLProperty(Constants.WSDL_PROPERTY_RPC_XMLTYPE,
-            prefix + ":" + xmlType.getLocalPart());
-
-      WSDLInterfaceOperationOutput wsdlInterfaceOperationOutput = new WSDLInterfaceOperationOutput(intf);
-      wsdlInterfaceOperationOutput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_PART_NAME, xmlName.getLocalPart()));
-      wsdlInterfaceOperationOutput.setElement(xmlName);
-      wsdlInterfaceOperationOutput.setMessageLabel(new NCName("OUT"));
-      wsdlInterfaceOperationOutput.addProperty(wprop);
-
-      if (pmd.isInHeader())
-         wsdlInterfaceOperationOutput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA, null));
-
-      return wsdlInterfaceOperationOutput;
-   }
-
-   private WSDLInterfaceOperationInput getWSDLInterfaceOperationInput(WSDLInterfaceOperation intf, ParameterMetaData pmd)
-   {
-      QName xmlType = pmd.getXmlType();
-      QName xmlName = pmd.getXmlName();
-
-      WSDLInterfaceOperationInput wsdlInput = new WSDLInterfaceOperationInput(intf);
-      String prefix = wsdl.getPrefix(xmlType.getNamespaceURI());
-      //qn refers to the XMLType
-      WSDLProperty wsdlProperty = new WSDLProperty(Constants.WSDL_PROPERTY_RPC_XMLTYPE,
-                                    prefix + ":" + xmlType.getLocalPart());
-      wsdlInput.addProperty(wsdlProperty);
-      wsdlInput.setElement( xmlName );
-      //Plus add a property
-      wsdlInput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_PART_NAME,xmlName.getLocalPart()));
-      wsdlInput.setMessageLabel(new NCName("IN"));
-
-      if (pmd.isInHeader())
-         wsdlInput.addProperty(new WSDLProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA, null));
-
-      return wsdlInput;
-   }
-
-   private boolean checkAttachmentBasedOperation(OperationMetaData op)
-   {
-      boolean isAttach = false;
-
-      List<ParameterMetaData> params = op.getParameters();
-      for(ParameterMetaData param : params)
-      {
-         if(param.isSwA())
-         {
-            isAttach = true;
-            break;
-         }
-      }
-
-      return isAttach;
-   }
 }

Modified: trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -22,10 +22,11 @@
 package org.jboss.ws.tools.helpers;
 
 import java.beans.Introspector;
-import java.io.IOException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -65,11 +66,12 @@
 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.WSDLInterfaceMessageReference;
 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.WSDLProperty;
+import org.jboss.ws.metadata.wsdl.WSDLRPCPart;
 import org.jboss.ws.metadata.wsdl.WSDLService;
 import org.jboss.ws.metadata.wsdl.WSDLTypes;
 import org.jboss.ws.metadata.wsdl.WSDLUtils;
@@ -106,11 +108,6 @@
 
    private boolean unwrap = false;
 
-   /**
-    * A list of types that need java-xml type generation
-    */
-   private List<XSTypeDefinition> queueTypes = new ArrayList<XSTypeDefinition>();
-
    public MappingFileGeneratorHelper(WSDLDefinitions wsdl, String sname,
          String pname, Class seiClass, String tns,LiteralTypeMapping ltm, boolean unwrap)
    {
@@ -209,10 +206,6 @@
    public void constructServiceEndpointMethodMapping(
          ServiceEndpointInterfaceMapping seim, WSDLInterface intf )
    {
-
-      String portName = intf.getName().toString();
-      String targetNS = wsdlDefinitions.getTargetNamespace();
-
       WSDLInterfaceOperation[] wioparr = intf.getOperations();
       int len = 0;
       if (wioparr != null)
@@ -226,109 +219,127 @@
          semm.setWsdlOperation(opname);
          semm.setWrappedElement(shouldUnwrap());
 
-         constructMethodParamPartsMapping(semm,wiop );
+         if (isDocStyle())
+            constructDOCParameters(semm, wiop);
+         else
+            constructRPCParameters(semm, wiop);
 
          seim.addServiceEndpointMethodMapping(semm);
+      }
+   }
 
-         /**
-          * If there are multiple outputs, then the outputs that are after the first one
-          * are OUT holders. They are already handled in constructMethodParamPartsMapping.
-          * In this section, we have to just check if the first output is a holder. If it
-          * is, ignore generating a wsdlReturnValueMapping.
-          */
-         WSDLInterfaceOperationOutput[] wiopoutarr = wiop.getOutputs();
-         WSDLInterfaceOperationOutput wiout = null;
-         if (wiopoutarr != null && wiopoutarr.length > 0)
-            wiout = wiopoutarr[0];
+   private void constructDOCParameters(ServiceEndpointMethodMapping semm, WSDLInterfaceOperation wiop)
+   {
+      WSDLInterfaceOperationInput win = WSDLUtils.getWsdl11Input(wiop);
+      MethodParamPartsMapping mpin = null;
+      String partName = win.getPartName();
+      if (win != null)
+      {
+         QName xmlName = win.getElement();
+         QName xmlType = win.getXMLType();
+         String wsdlMessageName = win.getMessageName().getLocalPart();
 
-         if (wiout != null)
+         if (shouldUnwrap())
          {
-            QName xmlName = wiout.getElement();
-            QName xmlType = wiout.getXMLType();
+            JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
+            XSTypeDefinition xt = schemaModel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
+            unwrapRequest(semm, wsdlMessageName, xt);
+         }
+         else
+         {
+            mpin = getMethodParamPartsMapping(semm,xmlName, xmlType, 0, wsdlMessageName, "IN", partName, false, true);
+            semm.addMethodParamPartsMapping(mpin);
+         }
+      }
 
-            WSDLProperty wprop = wiout.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME);
-            QName messageName = new QName(targetNS, wprop.getValue(), WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_WSDL_MESSAGE_NS);
+      WSDLInterfaceOperationOutput output = WSDLUtils.getWsdl11Output(wiop);
+      if (output != null)
+      {
+         QName xmlType = output.getXMLType();
 
-            if (shouldUnwrap())
-            {
-               JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
-               XSTypeDefinition xt = schemaModel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
-               unwrapResponse(semm, messageName, xt);
-
-               continue;
-            }
-
-            //Check it is a holder. If it is, return
-            if( wiop.getInputByPartName(xmlName.getLocalPart()) != null)
-               continue;
-
-            String javaType = getJavaTypeAsString(xmlName,xmlType, false, true);
-
-            if(isDocStyle() == false && "void".equals(javaType))
-               continue;
-
+         QName messageName = output.getMessageName();
+         if (shouldUnwrap())
+         {
+            JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
+            XSTypeDefinition xt = schemaModel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
+            unwrapResponse(semm, messageName, xt);
+         }
+         else if (partName != null && partName.equals(output.getPartName()))
+         {
+            mpin.getWsdlMessageMapping().setParameterMode("INOUT");
+         }
+         else
+         {
             WsdlReturnValueMapping wrvm = new WsdlReturnValueMapping(semm);
-            wrvm.setMethodReturnValue(javaType);
-            wrvm.setWsdlMessage(messageName);
-            wprop = wiout.getProperty(Constants.WSDL_PROPERTY_PART_NAME);
-            wrvm.setWsdlMessagePartName(wprop.getValue());
+            wrvm.setMethodReturnValue(getJavaTypeAsString(output.getElement(), output.getXMLType(), false, true));
+            wrvm.setWsdlMessage(new QName(messageName.getNamespaceURI(), messageName.getLocalPart(),  WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_WSDL_MESSAGE_NS));
+            wrvm.setWsdlMessagePartName(output.getPartName());
             semm.setWsdlReturnValueMapping(wrvm);
          }
       }
    }
 
-   public void constructMethodParamPartsMapping(ServiceEndpointMethodMapping semm,
-         WSDLInterfaceOperation wiop)
+   private void constructRPCParameters(ServiceEndpointMethodMapping semm, WSDLInterfaceOperation wiop)
    {
-      String portName = wiop.getWsdlInterface().getName().toString();
-      String opname = wiop.getName().toString();
-      WSDLInterfaceOperationInput[] wiopinarr = wiop.getInputs();
-      int lenwiopin = wiopinarr != null ? wiopinarr.length : 0;
+      WSDLInterfaceOperationInput win = WSDLUtils.getWsdl11Input(wiop);
+      if (win == null)
+         throw new WSException("RPC endpoints require an input message");
+      String wsdlMessageName = win.getMessageName().getLocalPart();
 
-      for (int k = 0; k < lenwiopin; k++)
+      HashMap<String, MethodParamPartsMapping> map = new HashMap<String, MethodParamPartsMapping>();
       {
-         WSDLInterfaceOperationInput win = wiopinarr[k];
-         QName xmlName = win.getElement();
-         QName xmlType = win.getXMLType();
-         String wsdlMessageName = "";
-         wsdlMessageName = win.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME).getValue();
-         String partName = win.getProperty(Constants.WSDL_PROPERTY_PART_NAME).getValue();
+         int i = 0;
+         for (WSDLRPCPart part : win.getChildParts())
+         {
+            QName xmlName = new QName(part.getName());
+            QName xmlType = part.getType();
+            String partName = part.getName();
 
-         String paramMode = "";
 
-         if(wiop.getOutputByPartName(partName) != null)
-            paramMode = WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_IN_OUT_HOLDER_PARAM_MODE;
-         else
-            paramMode = WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_IN_PARAM_MODE;
+            MethodParamPartsMapping mpin = getMethodParamPartsMapping(semm,xmlName, xmlType,
+                  i++, wsdlMessageName, "IN", partName, false, true);
 
-         if (shouldUnwrap())
-         {
-            JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
-            XSTypeDefinition xt = schemaModel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
-            unwrapRequest(semm, wsdlMessageName, xt);
-            break;
+            map.put(partName, mpin);
+            semm.addMethodParamPartsMapping(mpin);
          }
-
-         MethodParamPartsMapping mpin = getMethodParamPartsMapping(semm,xmlName, xmlType,
-               k, wsdlMessageName, paramMode, partName, false, true);
-         semm.addMethodParamPartsMapping(mpin);
       }
-      //Take care of out holders
-      WSDLInterfaceOperationOutput[] outs = wiop.getOutputs();
-      int lenOuts = outs != null ? outs.length : 0;
-      if(lenOuts > 1)
-         for(int m = 1; m < lenOuts; m++)
+
+      WSDLInterfaceOperationOutput output = WSDLUtils.getWsdl11Output(wiop);
+      if (output != null)
+      {
+         int i = 0;
+         boolean first = true;
+         for (WSDLRPCPart part : output.getChildParts())
          {
-            WSDLInterfaceOperationOutput out = outs[m];
-            if(this.isInOutHolder(out))
+            QName xmlName = new QName(part.getName());
+            QName xmlType = part.getType();
+            String partName = part.getName();
+
+            MethodParamPartsMapping mapping = map.get(partName);
+            if (mapping != null)
+            {
+               mapping.getWsdlMessageMapping().setParameterMode("INOUT");
                continue;
-            QName xmlName = out.getElement();
-            QName xmlType = out.getXMLType();
-            MethodParamPartsMapping mpm = getMethodParamPartsMapping(semm,xmlName, xmlType,
-                  lenwiopin + m -1, out.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME).getValue(),
-                  WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_OUT_HOLDER_PARAM_MODE, xmlName.getLocalPart(), false, true);
-            semm.addMethodParamPartsMapping(mpm);
+            }
+
+            // The first OUT param is our return value
+            if (first)
+            {
+               WsdlReturnValueMapping wrvm = new WsdlReturnValueMapping(semm);
+               wrvm.setMethodReturnValue(getJavaTypeAsString(xmlName, xmlType, false, true));
+               QName messageName = output.getMessageName();
+               wrvm.setWsdlMessage(new QName(messageName.getNamespaceURI(), messageName.getLocalPart(),  WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_WSDL_MESSAGE_NS));
+               wrvm.setWsdlMessagePartName(partName);
+               semm.setWsdlReturnValueMapping(wrvm);
+               first = false;
+            }
+            else
+            {
+               mapping = getMethodParamPartsMapping(semm, xmlName, xmlType, i++, wsdlMessageName, "OUT", partName, false, true);
+               semm.addMethodParamPartsMapping(mapping);
+            }
          }
+      }
    }
 
 
@@ -343,31 +354,39 @@
          int lenOps = ops.length;
          for (int j = 0; j < lenOps; j++)
          {
-            JavaXmlTypeMapping jxtm = null;
-
             WSDLInterfaceOperation op  = ops[j];
-            WSDLInterfaceOperationInput[] inputs  = op.getInputs();
-            int lenin  = inputs.length;
-            for (int k = 0; k < lenin ; k++)
+            for (WSDLInterfaceOperationInput input : op.getInputs())
             {
-               WSDLInterfaceOperationInput input = inputs[k];
-               XSTypeDefinition xt = getXSType( input );
-               addJavaXMLTypeMap(xt, input.getElement().getLocalPart(), jwm, !isDocStyle());
+               if (isDocStyle())
+               {
+                  XSTypeDefinition xt = getXSType( input );
+                  addJavaXMLTypeMap(xt, input.getElement().getLocalPart(), jwm, false);
+               }
+               else
+               {
+                  for (WSDLRPCPart part : input.getChildParts())
+                     addJavaXMLTypeMap(getXSType(part.getType()), "", jwm, true);
+               }
             }
 
-            WSDLInterfaceOperationOutput[] outputs  = op.getOutputs();
-            int lenout = outputs.length;
-            for(int k=0; k < lenout; k++)
+            for (WSDLInterfaceOperationOutput output : op.getOutputs())
             {
-               WSDLInterfaceOperationOutput output = outputs[k];
-               XSTypeDefinition xt = getXSType(output);
-               addJavaXMLTypeMap(xt, output.getElement().getLocalPart(), jwm, !isDocStyle());
+               if (isDocStyle())
+               {
+                  XSTypeDefinition xt = getXSType( output );
+                  addJavaXMLTypeMap(xt, output.getElement().getLocalPart(), jwm, false);
+               }
+               else
+               {
+                  for (WSDLRPCPart part : output.getChildParts())
+                     addJavaXMLTypeMap(getXSType(part.getType()), "", jwm, true);
+               }
             }
 
             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);
@@ -468,7 +487,7 @@
 
             WsdlReturnValueMapping wrvm = new WsdlReturnValueMapping(methodMapping);
             wrvm.setMethodReturnValue(javaType);
-            wrvm.setWsdlMessage(messageName);
+            wrvm.setWsdlMessage(new QName(messageName.getNamespaceURI(), messageName.getLocalPart(), WSToolsConstants.WSTOOLS_CONSTANT_MAPPING_WSDL_MESSAGE_NS));
             wrvm.setWsdlMessagePartName(xmlName.getLocalPart());
             methodMapping.setWsdlReturnValueMapping(wrvm);
 
@@ -487,7 +506,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();
@@ -508,6 +527,13 @@
       return xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
    }
 
+   private XSTypeDefinition getXSType(QName xmlType)
+   {
+      WSDLTypes types = wsdlDefinitions.getWsdlTypes();
+      JBossXSModel xsmodel = WSDLUtils.getSchemaModel(types);
+      return xsmodel.getTypeDefinition(xmlType.getLocalPart(),xmlType.getNamespaceURI());
+   }
+
    private void addJavaXMLTypeMap(XSTypeDefinition xt, String containingElement, JavaWsdlMapping jwm, boolean skipWrapperArray)
    {
       JavaXmlTypeMapping jxtm = null;
@@ -642,23 +668,6 @@
       }
    }
 
-   private Method[] getMethodsGivenOperationName(Class clazz, String opname)
-   {
-      ArrayList<Method> alist= new ArrayList<Method>();
-      Method[] methodz = clazz.getDeclaredMethods();
-      int len = methodz.length;
-
-      for(int i = 0 ; i < len ; i++)
-      {
-         Method m = methodz[i];
-         if(opname.equals(m.getName()))
-            alist.add(m);
-      }
-      Method[] marr = new Method[alist.size()];
-      alist.toArray(marr);
-      return marr;
-   }
-
    private String getJavaTypeAsString(QName xmlName, QName xmlType, boolean array, boolean primitive)
    {
       String jtype = null;
@@ -725,20 +734,6 @@
       return Constants.DOCUMENT_LITERAL.equals(wsdlStyle);
    }
 
-
-   private boolean isPublicField( Class javaType, String fieldname)
-   {
-      Field[] fldarr = utils.getPublicFields(javaType);
-      int len = fldarr != null ? fldarr.length : 0;
-
-      for(int i = 0 ; i < len ; i++)
-      {
-         Field fld = fldarr[i];
-         if(fieldname.equals(fld.getName())) return true;
-      }
-      return false;
-   }
-
    /**
     * Checks whether the type represents an array type
     *
@@ -796,16 +791,6 @@
       return unwrap && Constants.DOCUMENT_LITERAL.equals(wsdlStyle);
    }
 
-   private boolean isInOutHolder(WSDLInterfaceOperationOutput wout)
-   {
-      //Now check if the part exists in both input and output => Need Holder
-      WSDLInterfaceOperation op =  wout.getWsdlOperation();
-      QName el = wout.getElement();
-
-      WSDLInterfaceOperationInput inp = op.getInput(el);
-      return inp != null;
-   }
-
    private MethodParamPartsMapping getMethodParamPartsMapping(ServiceEndpointMethodMapping semm,
          QName xmlName, QName xmlType,
          int paramPosition, String wsdlMessageName, String paramMode, String wsdlMessagePartName, boolean array, boolean primitive)

Modified: trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -0,0 +1,86 @@
+/*
+* 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.WSException;
+import org.jboss.ws.metadata.wsdl.DOMTypes;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.sun.xml.bind.api.JAXBRIContext;
+
+
+public class JAXBWSDLGenerator extends WSDLGenerator
+{
+   private JAXBRIContext ctx;
+
+   public JAXBWSDLGenerator(JAXBRIContext ctx)
+   {
+      super();
+      this.ctx = ctx;
+   }
+
+   protected void processTypes()
+   {
+      // 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
+            {
+               // JAXB creates an empty namespace due to type references, ignore it
+               if (namespace == null || namespace.length() == 0)
+                  return null;
+
+               DOMResult result = new DOMResult(element);
+               result.setSystemId(namespace);
+               return result;
+            }
+         });
+
+         wsdl.setWsdlTypes(types);
+      }
+      catch (Exception exception)
+      {
+         throw new WSException("Could not generate schema: " + exception.getMessage(), exception);
+      }
+   }
+}


Property changes on: 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: trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/jaxws/WSDLGenerator.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -0,0 +1,321 @@
+/*
+ * 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 abstract class WSDLGenerator
+{
+   protected WSDLDefinitions wsdl;
+
+   protected abstract void processTypes();
+
+   protected void processEndpoint(WSDLService service, EndpointMetaData endpoint)
+   {
+      WSDLEndpoint wsdlEndpoint = new WSDLEndpoint(service);
+      wsdlEndpoint.setQName(endpoint.getQName());
+      wsdlEndpoint.setName(new NCName(endpoint.getQName().getLocalPart()));
+      wsdlEndpoint.setAddress(endpoint.getEndpointAddress());
+      service.addEndpoint(wsdlEndpoint);
+
+      WSDLInterface wsdlInterface = new WSDLInterface(wsdl);
+      QName interfaceQName = endpoint.getInterfaceQName();
+      wsdlInterface.setQName(interfaceQName);
+      wsdlInterface.setName(new NCName(interfaceQName));
+      wsdl.addInterface(wsdlInterface);
+
+      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);
+      wsdl.addBinding(wsdlBinding);
+      wsdlEndpoint.setBinding(bindingQName);
+
+      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.isOneWay() ? 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);
+
+      WSDLInterfaceOperationOutput output = null;
+      WSDLBindingOperationOutput bindingOutput = null;
+
+      boolean twoWay = !operation.isOneWay();
+      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());
+               input.setPartName(param.getPartName());
+            }
+            if (twoWay && param.getMode() != ParameterMode.IN)
+            {
+               output.setElement(param.getXmlName());
+               output.setPartName(param.getPartName());
+            }
+         }
+         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.isOneWay();
+      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();
+         processEndpoint(wsdlService, endpoint);
+      }
+
+      if (endpoint == null)
+         throw new IllegalStateException("A service must have an endpoint");
+
+      wsdlService.setInterfaceName(endpoint.getQName());
+   }
+
+   /**
+    * 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)
+   {
+      // 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");
+      wsdl.registerNamespaceURI(Constants.NS_SOAP11, "soap");
+      wsdl.registerNamespaceURI(Constants.NS_SCHEMA_XSD, "xsd");
+
+      processTypes();
+      processService(service);
+
+      return wsdl;
+   }
+}
\ No newline at end of file


Property changes on: 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: trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/metadata/ReflectiveMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsEndpointMetaData.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -37,9 +37,10 @@
 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);
    }
    
    @Override

Modified: trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/utils/HolderUtils.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/utils/IOUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/IOUtils.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/utils/IOUtils.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -72,16 +72,30 @@
       }
    }
 
+   public static String printArray(Object[] val)
+   {
+      if (val == null)
+         return "null";
+      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: trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/utils/JavaUtils.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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: trunk/src/main/java/org/jboss/ws/utils/JavassistUtils.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: trunk/src/test/etc/log4j.xml
===================================================================
--- trunk/src/test/etc/log4j.xml	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/etc/log4j.xml	2006-10-05 17:48:45 UTC (rev 1145)
@@ -53,7 +53,7 @@
   <!-- ================ -->
 
   <category name="org.jboss.ws">
-    <priority value="DEBUG"/>
+    <priority value="TRACE" class="org.jboss.logging.XLevel"/>
   </category>
 
    <category name="org.jboss.remoting">

Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webservice/JSEBean01.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webservice/JSEBean01.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webservice/JSEBean01.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -23,7 +23,7 @@
 
 import javax.jws.WebMethod;
 import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding; 
+import javax.jws.soap.SOAPBinding;
 
 /**
  * Test the JSR-181 annotation: javax.jws.WebService

Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181ejb/EJB3Bean01.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181ejb/EJB3Bean01.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181ejb/EJB3Bean01.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -25,6 +25,8 @@
 import javax.ejb.Remote;
 import javax.ejb.Stateless;
 import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
 import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
 
@@ -55,7 +57,8 @@
 public class EJB3Bean01 implements EJB3RemoteInterface
 {
    @WebMethod
-   public String echo(String input)
+   @WebResult(name = "result")
+   public String echo(@WebParam(name = "String_1") String input)
    {
       return input;
    }

Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181pojo/JSEBean01.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181pojo/JSEBean01.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jsr181pojo/JSEBean01.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -22,6 +22,8 @@
 package org.jboss.test.ws.jaxws.samples.jsr181pojo;
 
 import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
 import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
 
@@ -36,7 +38,8 @@
 public class JSEBean01
 {
    @WebMethod
-   public String echo(String input)
+   @WebResult(name="result")
+   public String echo(@WebParam(name="String_1") String input)
    {
       return input;
    }

Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpoint.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpoint.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpoint.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -26,6 +26,15 @@
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 
+import javax.jws.HandlerChain;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.ws.annotation.PortComponent;
+
 /**
  * WS-Addressing stateful service endpoint interface
  *
@@ -33,11 +42,16 @@
  *
  * @since 24-Nov-2005
  */
+ at WebService(name = "StatefulEndpoint", targetNamespace = "http://org.jboss.ws/samples/wsaddressing", serviceName = "TestService")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
 public interface StatefulEndpoint extends Remote
 {
+   @WebMethod
    public void addItem(String item) throws RemoteException;
 
+   @WebMethod
    public void checkout() throws RemoteException;
 
+   @WebMethod
    public String getItems() throws RemoteException;
 }

Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java	2006-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -31,6 +31,7 @@
 import javax.annotation.Resource;
 import javax.jws.HandlerChain;
 import javax.jws.WebMethod;
+import javax.jws.WebParam;
 import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
 import javax.xml.namespace.QName;
@@ -59,7 +60,7 @@
 
    // The state map for all clients
    private static Map<String, List<String>> clientStateMap = new HashMap<String, List<String>>();
-   
+
    private String clientid;
    private static List<String> items;
    private WebServiceContext context;
@@ -101,7 +102,7 @@
       clientid = (String)msgContext.get("clientid");
       if (clientid == null)
          throw new IllegalStateException("Cannot obtain clientid");
-      
+
       // Get the client's items
       items = clientStateMap.get(clientid);
       if (items == null)

Modified: 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-10-05 12:24:43 UTC (rev 1144)
+++ trunk/src/test/java/org/jboss/test/ws/tools/validation/WSDL11Validator.java	2006-10-05 17:48:45 UTC (rev 1145)
@@ -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