You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2006/12/29 11:05:43 UTC

svn commit: r490973 [2/3] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/core/src/main/java/org/apache/cxf/wsdl11/ rt/core/src/test/java/org/apache/cxf/wsdl11/ rt/frontend...

Copied: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java (from r490267, incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java?view=diff&rev=490973&p1=incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java&r1=490267&p2=incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java&r2=490973
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java (original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java Fri Dec 29 02:05:41 2006
@@ -17,74 +17,63 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.wsdl2java.processor.internal;
+package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import javax.jws.soap.SOAPBinding;
-import javax.wsdl.Definition;
-import javax.wsdl.Message;
-import javax.wsdl.Part;
+import javax.wsdl.OperationType;
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.xml.sax.SAXException;
-
 import com.sun.codemodel.JType;
 import com.sun.tools.xjc.api.Property;
 
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.common.WSDLConstants;
-import org.apache.cxf.tools.common.model.JavaAnnotation;
 import org.apache.cxf.tools.common.model.JavaMethod;
 import org.apache.cxf.tools.common.model.JavaParameter;
 import org.apache.cxf.tools.common.model.JavaReturn;
 import org.apache.cxf.tools.common.model.JavaType;
-import org.apache.cxf.tools.util.ProcessorUtil;
+import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
+import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebParamAnnotator;
+import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.ParameterMapper;
 
 public class ParameterProcessor extends AbstractProcessor {
     
-    private Map<String, Element> wsdlElementMap = new HashMap<String, Element>();
-    private Map<String, String>  wsdlLoc = new HashMap<String, String>();
+    private DataBindingProfile dataBinding;
     
     @SuppressWarnings("unchecked")
     public ParameterProcessor(ToolContext penv) {
         super(penv);
-        Definition definition = (Definition)penv.get(ToolConstants.WSDL_DEFINITION);
-        wsdlLoc.put(definition.getTargetNamespace(), definition.getDocumentBaseURI());
-        List<Definition> defs = (List<Definition>)penv.get(ToolConstants.IMPORTED_DEFINITION);
-        for (Definition def : defs) {
-            wsdlLoc.put(def.getTargetNamespace(), def.getDocumentBaseURI());
-        }
+        dataBinding = context.get(DataBindingProfile.class);
     }
 
-    public void process(JavaMethod method, Message inputMessage, Message outputMessage,
-                        boolean isRequestResponse, List<String> parameterOrder) throws ToolException {     
-        boolean parameterOrderPresent = false;
-
-        if (parameterOrder != null && !parameterOrder.isEmpty()) {
-            parameterOrderPresent = true;
-        }
+    private boolean isRequestResponse(JavaMethod method) {
+        return method.getStyle() == OperationType.REQUEST_RESPONSE;
+    }
 
-        if (parameterOrderPresent && isValidOrdering(parameterOrder, inputMessage, outputMessage)
+    public void process(JavaMethod method,
+                        MessageInfo inputMessage,
+                        MessageInfo outputMessage,
+                        List<String> parameterOrder) throws ToolException {
+        
+        if (!StringUtils.isEmpty(parameterOrder)
+            && isValidOrdering(parameterOrder, inputMessage, outputMessage)
             && !method.isWrapperStyle()) {
-            buildParamModelsWithOrdering(method, inputMessage, outputMessage, isRequestResponse,
+            
+            buildParamModelsWithOrdering(method,
+                                         inputMessage,
+                                         outputMessage,
                                          parameterOrder);
         } else {
-            buildParamModelsWithoutOrdering(method, inputMessage, outputMessage, isRequestResponse);
+            buildParamModelsWithoutOrdering(method,
+                                            inputMessage,
+                                            outputMessage);
         }
     }
 
@@ -97,74 +86,26 @@
      * @param style
      * @throws ToolException
      */
-    public JavaParameter addParameterFromBinding(JavaMethod method, Part part, JavaType.Style style)
+    public JavaParameter addParameterFromBinding(JavaMethod method,
+                                                 MessagePartInfo part,
+                                                 JavaType.Style style)
         throws ToolException {
-        return addParameter(method, getParameterFromPart(method, part, style));
+        return addParameter(method, getParameterFromPart(part, style));
     }
 
-    private JavaParameter getParameterFromPart(JavaMethod method, Part part, JavaType.Style style) {
-        String name = ProcessorUtil.resolvePartName(part);
-        String namespace = ProcessorUtil.resolvePartNamespace(part);
-        String type = ProcessorUtil.resolvePartType(part, this.env);
-
-        JavaParameter parameter = new JavaParameter(name, type, namespace);
-        parameter.setPartName(part.getName());
-        parameter.setQName(ProcessorUtil.getElementName(part));
-
-        parameter.setClassName(ProcessorUtil.getFullClzName(part, env, this.collector, false));
-
-        if (style == JavaType.Style.INOUT || style == JavaType.Style.OUT) {
-            parameter.setHolder(true);
-            parameter.setHolderName(javax.xml.ws.Holder.class.getName());
-            
-            parameter.setHolderClass(ProcessorUtil.getFullClzName(part, env, this.collector, true));
-        }
-        parameter.setStyle(style);
-        return parameter;
+    private JavaParameter getParameterFromPart(MessagePartInfo part, JavaType.Style style) {
+        return ParameterMapper.map(part, style, context);
     }
 
     private JavaParameter addParameter(JavaMethod method, JavaParameter parameter) throws ToolException {
-        JavaAnnotation webParamAnnotation = new JavaAnnotation("WebParam");
-        String name = parameter.getName();
-        String targetNamespace = method.getInterface().getNamespace();
-        String partName = null;
-
-        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
-            targetNamespace = parameter.getTargetNamespace();
-            if (parameter.getQName() != null) {
-                name = parameter.getQName().getLocalPart();
-            }
-            if (!method.isWrapperStyle()) {
-                partName = parameter.getPartName();
-            }
-        }
-
-        if (method.getSoapStyle() == SOAPBinding.Style.RPC) {
-            name = parameter.getPartName();
-            partName = parameter.getPartName();
-        }
-
-        if (partName != null) {
-            webParamAnnotation.addArgument("partName", partName);
-        }
-        if (parameter.getStyle() == JavaType.Style.OUT || parameter.getStyle() == JavaType.Style.INOUT) {
-            webParamAnnotation.addArgument("mode", "Mode." + parameter.getStyle().toString(), "");
-        }
-        webParamAnnotation.addArgument("name", name);
-        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
-            webParamAnnotation.addArgument("targetNamespace", targetNamespace);
-        }
-
-        parameter.setAnnotation(webParamAnnotation);
-
+        new WebParamAnnotator().annotate(method, parameter);
         method.addParameter(parameter);
-
         return parameter;
     }
 
-    private void processReturn(JavaMethod method, Part part) {
-        String name = part == null ? "return" : part.getName();
-        String type = part == null ? "void" : ProcessorUtil.resolvePartType(part, this.env);
+    private void processReturn(JavaMethod method, MessagePartInfo part) {
+        String name = part == null ? "return" : part.getName().getLocalPart();
+        String type = part == null ? "void" : ProcessorUtil.resolvePartType(part, context);
  
         String namespace = part == null ? null : ProcessorUtil.resolvePartNamespace(part);
               
@@ -172,134 +113,56 @@
         returnType.setQName(ProcessorUtil.getElementName(part));
         returnType.setStyle(JavaType.Style.OUT);
         if (namespace != null && type != null && !"void".equals(type)) {
-            returnType.setClassName(ProcessorUtil.getFullClzName(part, env, this.collector, false));
+            returnType.setClassName(ProcessorUtil.getFullClzName(part, context, false));
         }
         method.setReturn(returnType);
     }
 
     @SuppressWarnings("unchecked")
-    private void processInput(JavaMethod method, Message inputMessage) throws ToolException {
-        List<Part> inputParts = getDefaultOrderParts(inputMessage);
-        for (Part part : inputParts) {
-            addParameter(method, getParameterFromPart(method, part, JavaType.Style.IN));
+    private void processInput(JavaMethod method, MessageInfo inputMessage) throws ToolException {
+        for (MessagePartInfo part : inputMessage.getMessageParts()) {
+            addParameter(method, getParameterFromPart(part, JavaType.Style.IN));
         }
     }
     
     @SuppressWarnings("unchecked")
-    private List<Part> getDefaultOrderParts(Message message) {
-        Map<String, Part> partsMap = message.getParts();
-        List<Part> parts = new ArrayList<Part>();
-        if (message.getParts().size() > 1) {
-            List<String> paraOrder = getDefaultOrderPartNameList(message);
-            parts = message.getOrderedParts(paraOrder);
-        } else {
-            Collection<Part> partsValues = partsMap.values();
-            for (Part part : partsValues) {
-                parts.add(part);
-            }
-        }
-        return parts;
-    }
-    
-    
-    private Element getWSDLElement(Message message) {
-        String ns = message.getQName().getNamespaceURI();
-        String wsdlLocation = wsdlLoc.get(ns);
-        Element wsdlElement = wsdlElementMap.get(ns);
-        if (wsdlElementMap.get(ns) == null) {
-            Document doc = null;
-            try {
-                doc = DOMUtils.createDocumentBuilder().parse(wsdlLocation);
-                wsdlElement = doc.getDocumentElement();
-                wsdlElementMap.put(ns, wsdlElement);
-            } catch (SAXException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            } catch (IOException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
-        }
-        return wsdlElement;
-    }
-    
-    
-    private List<String> getDefaultOrderPartNameList(Message message) {
-        List<String> nameList = new ArrayList<String>(); 
-        Element wsdlElement = getWSDLElement(message);     
-        NodeList messageNodeList = wsdlElement.getElementsByTagNameNS(message.getQName().getNamespaceURI(),
-                                   WSDLConstants.QNAME_MESSAGE.getLocalPart());       
-        Node messageNode = null;
-        
-        for (int i = 0; i < messageNodeList.getLength(); i++) {
-            Node node = messageNodeList.item(i);
-            if (DOMUtils.getAttribute(node, 
-                                      WSDLConstants.ATTR_NAME).
-                                          equals(message.getQName().getLocalPart())) {
-                messageNode = node;
-                break;
-            }
-        }
-        if (messageNode == null) {
-            return null;
-        }
-        Node partNode = DOMUtils.getChild(messageNode, Node.ELEMENT_NODE);
-        nameList.add(DOMUtils.getAttribute(partNode, WSDLConstants.ATTR_NAME));
-        while (partNode.getNextSibling() != null) {
-            partNode = partNode.getNextSibling();
-            if (partNode.getNodeType() == Node.ELEMENT_NODE) {
-                nameList.add(DOMUtils.getAttribute(partNode, WSDLConstants.ATTR_NAME));
-            }
-        }
-        
-        
-        return nameList;
+    private void processWrappedInput(JavaMethod method, MessageInfo inputMessage) throws ToolException {
+        List<MessagePartInfo> inputParts = inputMessage.getMessageParts();
         
-        
-    }
-    
-
-    @SuppressWarnings("unchecked")
-    private void processWrappedInput(JavaMethod method, Message inputMessage) throws ToolException {
-        Map<String, Part> inputPartsMap = inputMessage.getParts();
-        Collection<Part> inputParts = inputPartsMap.values();
         if (inputParts.size() > 1) {
             processInput(method, inputMessage);
             return;
         } else if (inputParts.isEmpty()) {
             return;
         }
-        Part part = inputParts.iterator().next();
+        MessagePartInfo part = inputParts.iterator().next();
         
-        List<? extends Property> block = dataBinder.getBlock(part);
-        if (block != null) {
-            if (block.size() == 0) {
-                // complete
-            }
-            for (Property item : block) {
-                addParameter(method, getParameterFromProperty(item, JavaType.Style.IN, part));
-            }
+        List<? extends Property> block = dataBinding.getBlock(part);
+        if (block == null || block.size() == 0) {
+            return;
+        }
+        for (Property item : block) {
+            addParameter(method, getParameterFromProperty(item, JavaType.Style.IN, part));
         }
     }
 
     @SuppressWarnings("unchecked")
-    private void processOutput(JavaMethod method, Message inputMessage, Message outputMessage,
-                               boolean isRequestResponse) throws ToolException {
-        Map<String, Part> inputPartsMap = 
-            inputMessage == null ? new HashMap<String, Part>() : inputMessage.getParts();
-        List<Part> outputParts = 
-            outputMessage == null ? new ArrayList<Part>() : this.getDefaultOrderParts(outputMessage);
+    private void processOutput(JavaMethod method, MessageInfo inputMessage, MessageInfo outputMessage)
+        throws ToolException {
+        Map<QName, MessagePartInfo> inputPartsMap = inputMessage.getMessagePartsMap();
+        List<MessagePartInfo> outputParts = 
+            outputMessage == null ? new ArrayList<MessagePartInfo>() : outputMessage.getMessageParts();
         // figure out output parts that are not present in input parts
-        List<Part> outParts = new ArrayList<Part>();
-        if (isRequestResponse) {
+        List<MessagePartInfo> outParts = new ArrayList<MessagePartInfo>();
+        if (isRequestResponse(method)) {
 
-            for (Part outpart : outputParts) {
-                Part inpart = inputPartsMap.get(outpart.getName());
+            for (MessagePartInfo outpart : outputParts) {
+                MessagePartInfo inpart = inputPartsMap.get(outpart.getName());
                 if (inpart == null) {
                     outParts.add(outpart);
                     continue;
                 } else if (isSamePart(inpart, outpart)) {
-                    addParameter(method, getParameterFromPart(method, outpart, JavaType.Style.INOUT));
+                    addParameter(method, getParameterFromPart(outpart, JavaType.Style.INOUT));
                     continue;
                 } else if (!isSamePart(inpart, outpart)) {
                     outParts.add(outpart);
@@ -309,32 +172,29 @@
             }
         }
 
-        if (isRequestResponse && outParts.size() == 1) {
+        if (isRequestResponse(method) && outParts.size() == 1) {
             processReturn(method, outParts.get(0));
             return;
         } else {
             processReturn(method, null);
         }
-        if (isRequestResponse) {
-            for (Part part : outParts) {
-                addParameter(method, getParameterFromPart(method, part, JavaType.Style.OUT));
+        if (isRequestResponse(method)) {
+            for (MessagePartInfo part : outParts) {
+                addParameter(method, getParameterFromPart(part, JavaType.Style.OUT));
             }
         }
     }
 
     @SuppressWarnings("unchecked")
-    private void processWrappedOutput(JavaMethod method, Message inputMessage, Message outputMessage,
-                                      boolean isRequestResponse) throws ToolException {
+    private void processWrappedOutput(JavaMethod method,
+                                      MessageInfo inputMessage,
+                                      MessageInfo outputMessage) throws ToolException {
         
-        Map<String, Part> inputPartsMap = 
-            inputMessage == null ? new HashMap<String, Part>() : inputMessage.getParts();
-        Map<String, Part> outputPartsMap = 
-            outputMessage == null ? new HashMap<String, Part>() : outputMessage.getParts();
-        Collection<Part> outputParts = outputPartsMap.values();
-        Collection<Part> inputParts = inputPartsMap.values();
+        List<MessagePartInfo> outputParts = outputMessage.getMessageParts();
+        List<MessagePartInfo> inputParts = inputMessage.getMessageParts();
 
-        if (inputPartsMap.size() > 1 || outputPartsMap.size() > 1) {
-            processOutput(method, inputMessage, outputMessage, isRequestResponse);
+        if (inputParts.size() > 1 || outputParts.size() > 1) {
+            processOutput(method, inputMessage, outputMessage);
             return;
         }
         if (outputParts.size() == 0) {
@@ -342,18 +202,18 @@
             return;
         }
         
-        Part inputPart = inputParts.size() > 0 ? inputParts.iterator().next() : null;
-        Part outputPart = outputParts.size() > 0 ? outputParts.iterator().next() : null;
+        MessagePartInfo inputPart = inputParts.size() > 0 ? inputParts.iterator().next() : null;
+        MessagePartInfo outputPart = outputParts.size() > 0 ? outputParts.iterator().next() : null;
         
         List<? extends Property> inputBlock = null;
         List<? extends Property> outputBlock = null;
         
         if (inputPart != null) {
-            inputBlock = dataBinder.getBlock(inputPart);
+            inputBlock = dataBinding.getBlock(inputPart);
         }       
         
         if (outputPart != null) {
-            outputBlock = dataBinder.getBlock(outputPart);
+            outputBlock = dataBinding.getBlock(outputPart);
         }
 
         if (outputBlock == null || outputBlock.size() == 0) {
@@ -429,24 +289,13 @@
         return true;
     }
 
-    private JavaParameter getParameterFromProperty(Property property, JavaType.Style style, Part part) {
-        JType t = property.type();
-        String targetNamespace = ProcessorUtil.resolvePartNamespace(part);
-        if (targetNamespace == null) {
-            targetNamespace = property.elementName().getNamespaceURI();
-        }
-        JavaParameter parameter = new JavaParameter(property.name(), t.fullName(), targetNamespace);
-        parameter.setStyle(style);
-        parameter.setQName(property.elementName());
-        if (style == JavaType.Style.OUT || style == JavaType.Style.INOUT) {
-            parameter.setHolder(true);
-            parameter.setHolderName(javax.xml.ws.Holder.class.getName());
-            parameter.setHolderClass(t.boxify().fullName());
-        }
-        return parameter;
+    private JavaParameter getParameterFromProperty(Property property,
+                                                   JavaType.Style style,
+                                                   MessagePartInfo part) {
+        return ParameterMapper.map(property, style, part);
     }
 
-    private JavaReturn getReturnFromProperty(Property property, Part part) {
+    private JavaReturn getReturnFromProperty(Property property, MessagePartInfo part) {
         JType t = property.type();
         String targetNamespace = ProcessorUtil.resolvePartNamespace(part);
         if (targetNamespace == null) {
@@ -458,9 +307,9 @@
         return returnType;
     }
 
-    private void buildParamModelsWithoutOrdering(JavaMethod method, Message inputMessage,
-                                                 Message outputMessage, boolean isRequestResponse)
-        throws ToolException {
+    private void buildParamModelsWithoutOrdering(JavaMethod method,
+                                                 MessageInfo inputMessage,
+                                                 MessageInfo outputMessage) throws ToolException {
         if (inputMessage != null) {
             if (method.isWrapperStyle()) {
                 processWrappedInput(method, inputMessage);
@@ -472,38 +321,38 @@
             processReturn(method, null);
         } else {
             if (method.isWrapperStyle()) {
-                processWrappedOutput(method, inputMessage, outputMessage, isRequestResponse);
+                processWrappedOutput(method, inputMessage, outputMessage);
             } else {
-                processOutput(method, inputMessage, outputMessage, isRequestResponse);
+                processOutput(method, inputMessage, outputMessage);
             }
         }
     }
 
     @SuppressWarnings("unchecked")
-    private void buildParamModelsWithOrdering(JavaMethod method, Message inputMessage, Message outputMessage,
-                                              boolean isRequestResponse, List<String> parameterList)
-        throws ToolException {
-        Map<String, Part> inputPartsMap = 
-            inputMessage == null ? new HashMap<String, Part>() : inputMessage.getParts();
-        Map<String, Part> outputPartsMap = 
-            outputMessage == null ? new HashMap<String, Part>() : outputMessage.getParts();
+    private void buildParamModelsWithOrdering(JavaMethod method,
+                                              MessageInfo inputMessage,
+                                              MessageInfo outputMessage,
+                                              List<String> parameterList) throws ToolException {
+
+        Map<QName, MessagePartInfo> inputPartsMap = inputMessage.getMessagePartsMap();
+        Map<QName, MessagePartInfo> outputPartsMap = outputMessage.getMessagePartsMap();
 
-        Collection<Part> inputParts = inputPartsMap.values();
-        Collection<Part> outputParts = outputPartsMap.values();
+        List<MessagePartInfo> inputParts = inputMessage.getMessageParts();
+        List<MessagePartInfo> outputParts = outputMessage.getMessageParts();
 
-        List<Part> inputUnlistedParts = new ArrayList<Part>();
-        List<Part> outputUnlistedParts = new ArrayList<Part>();
+        List<MessagePartInfo> inputUnlistedParts = new ArrayList<MessagePartInfo>();
+        List<MessagePartInfo> outputUnlistedParts = new ArrayList<MessagePartInfo>();
 
-        for (Part part : inputParts) {
-            if (!parameterList.contains(part.getName())) {
+        for (MessagePartInfo part : inputParts) {
+            if (!parameterList.contains(part.getName().getLocalPart())) {
                 inputUnlistedParts.add(part);
             }
         }
 
-        if (isRequestResponse) {
-            for (Part part : outputParts) {
+        if (isRequestResponse(method)) {
+            for (MessagePartInfo part : outputParts) {
                 if (!parameterList.contains(part.getName())) {
-                    Part inpart = inputMessage.getPart(part.getName());
+                    MessagePartInfo inpart = inputMessage.getMessagePart(part.getName());
                     if (inpart == null || (inpart != null && !isSamePart(inpart, part))) {
                         outputUnlistedParts.add(part);
                     }
@@ -525,7 +374,7 @@
         int size = parameterList.size();
         while (index < size) {
             String partName = parameterList.get(index);
-            Part part = inputPartsMap.get(partName);
+            MessagePartInfo part = inputPartsMap.get(partName);
             JavaType.Style style = JavaType.Style.IN;
             if (part == null) {
                 part = outputPartsMap.get(partName);
@@ -535,28 +384,28 @@
                 style = JavaType.Style.INOUT;
             }
             if (part != null) {
-                addParameter(method, getParameterFromPart(method, part, style));
+                addParameter(method, getParameterFromPart(part, style));
             }
             index++;
         }
         // now from unlisted input parts
-        for (Part part : inputUnlistedParts) {
-            addParameter(method, getParameterFromPart(method, part, JavaType.Style.IN));
+        for (MessagePartInfo part : inputUnlistedParts) {
+            addParameter(method, getParameterFromPart(part, JavaType.Style.IN));
         }
         // now from unlisted output parts
-        for (Part part : outputUnlistedParts) {
-            addParameter(method, getParameterFromPart(method, part, JavaType.Style.INOUT));
+        for (MessagePartInfo part : outputUnlistedParts) {
+            addParameter(method, getParameterFromPart(part, JavaType.Style.INOUT));
         }
     }
 
-    private boolean isSamePart(Part part1, Part part2) {
-        QName qname1 = part1.getElementName();
-        QName qname2 = part2.getElementName();
+    private boolean isSamePart(MessagePartInfo part1, MessagePartInfo part2) {
+        QName qname1 = part1.getElementQName();
+        QName qname2 = part2.getElementQName();
         if (qname1 != null && qname2 != null) {
             return qname1.equals(qname2);
         }
-        qname1 = part1.getTypeName();
-        qname2 = part2.getTypeName();
+        qname1 = part1.getTypeQName();
+        qname2 = part2.getTypeQName();
         if (qname1 != null && qname2 != null) {
             return qname1.equals(qname2);
         }
@@ -565,27 +414,27 @@
 
     @SuppressWarnings("unchecked")
     private boolean isValidOrdering(List<String> parameterOrder, 
-                                    Message inputMessage, Message outputMessage) {
+                                    MessageInfo inputMessage, MessageInfo outputMessage) {
         Iterator<String> params = parameterOrder.iterator();
 
-        Collection<Part> inputParts = inputMessage.getParts().values();
-        Collection<Part> outputParts = outputMessage.getParts().values();
+        List<MessagePartInfo> inputParts = inputMessage.getMessageParts();
+        List<MessagePartInfo> outputParts = outputMessage.getMessageParts();
 
         boolean partFound = false;
 
         while (params.hasNext()) {
             String param = params.next();
             partFound = false;
-            for (Part part : inputParts) {
-                if (param.equals(part.getName())) {
+            for (MessagePartInfo part : inputParts) {
+                if (param.equals(part.getName().getLocalPart())) {
                     partFound = true;
                     break;
                 }
             }
             // if not found, check output parts
             if (!partFound) {
-                for (Part part : outputParts) {
-                    if (param.equals(part.getName())) {
+                for (MessagePartInfo part : outputParts) {
+                    if (param.equals(part.getName().getLocalPart())) {
                         partFound = true;
                         break;
                     }

Copied: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java (from r490267, incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/PortTypeProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java?view=diff&rev=490973&p1=incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/PortTypeProcessor.java&r1=490267&p2=incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java&r2=490973
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/PortTypeProcessor.java (original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java Fri Dec 29 02:05:41 2006
@@ -17,78 +17,59 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.wsdl2java.processor.internal;
+package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal;
 
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
+import javax.xml.namespace.QName;
 
-import javax.wsdl.Operation;
-import javax.wsdl.PortType;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.common.extensions.jaxws.CustomizationParser;
-import org.apache.cxf.tools.common.extensions.jaxws.JAXWSBinding;
 import org.apache.cxf.tools.common.model.JavaInterface;
 import org.apache.cxf.tools.common.model.JavaModel;
-import org.apache.cxf.tools.util.ProcessorUtil;
+import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.InterfaceMapper;
 
 public class PortTypeProcessor extends AbstractProcessor {
-    private List<String> operationMap = new ArrayList<String>();
-    
-    public PortTypeProcessor(ToolContext penv) {
-        super(penv);
+    private List<QName> operationMap = new ArrayList<QName>();
+
+    public PortTypeProcessor(ToolContext c) {
+        super(c);
     }
     
-    public void process(JavaModel jmodel, PortType portType) throws ToolException {
+    public void process(ServiceInfo serviceInfo) throws ToolException {
         operationMap.clear();
-        JavaInterface intf = new JavaInterface(jmodel);
-        intf.setJAXWSBinding(customizing(jmodel, portType));
-        intf.setHandlerChains(CustomizationParser.getInstance().getHandlerChains());
-        
-        String namespace = portType.getQName().getNamespaceURI();
-        String packageName = ProcessorUtil.parsePackageName(namespace, env.mapPackageName(namespace));
+        JavaModel jmodel = context.get(JavaModel.class);
 
-        String location = (String)env.get(ToolConstants.CFG_WSDLURL);
-        String urlLocation;
-        try {
-            location = ProcessorUtil.getAbsolutePath(location);
-            urlLocation = ProcessorUtil.getWSDLURL(location).toString();
-            
-        } catch (Exception ioe) {
-            Message msg = new Message("CANNOT_FIND_WSDL", LOG, env.get(ToolConstants.CFG_WSDLURL));
-            throw new ToolException(msg, ioe);
-        }
-        String serviceName = portType.getQName().getLocalPart();
-        intf.setWebServiceName(serviceName);
-        intf.setName(ProcessorUtil.mangleNameToClassName(serviceName));
-        intf.setNamespace(namespace);
-        intf.setPackageName(packageName);
-        intf.setLocation(urlLocation);
+        // TODO: add cusomizing
+        //intf.setJAXWSBinding(customizing(jmodel, portType));
+        //intf.setHandlerChains(CustomizationParser.getInstance().getHandlerChains());
+
+        InterfaceInfo interfaceInfo = serviceInfo.getInterface();
 
-        List operations = portType.getOperations();
+        JavaInterface intf = new InterfaceMapper(context).map(interfaceInfo);
+        intf.setJavaModel(jmodel);
+        
+        Collection<OperationInfo> operations = interfaceInfo.getOperations();
        
-        for (Iterator iter = operations.iterator(); iter.hasNext();) {
-           
-            Operation operation = (Operation)iter.next();
+        for (OperationInfo operation : operations) {
             if (isOverloading(operation.getName())) {
                 LOG.log(Level.WARNING, "SKIP_OVERLOADED_OPERATION", operation.getName()); 
                 continue;
             }
-            OperationProcessor operationProcessor = new OperationProcessor(env);
+            OperationProcessor operationProcessor = new OperationProcessor(context);
             operationProcessor.process(intf, operation);
         }
         //Fixed issue 305772
-        jmodel.setLocation(urlLocation);
+        jmodel.setLocation(intf.getLocation());
         jmodel.addInterface(intf.getName(), intf);
-       
     }
 
-    private boolean isOverloading(String operationName) {
+    private boolean isOverloading(QName operationName) {
         if (operationMap.contains(operationName)) {
             return true;
         } else {
@@ -97,16 +78,17 @@
         return false;
     }
 
-    private JAXWSBinding customizing(JavaModel jmodel, PortType portType) {
-        String portTypeName = portType.getQName().getLocalPart();
-        JAXWSBinding bindings = CustomizationParser.getInstance().getPortTypeExtension(portTypeName);
-        if (bindings != null) {
-            return bindings;
-        } else if (jmodel.getJAXWSBinding() != null) {
-            return jmodel.getJAXWSBinding();
-        } else {
-            // TBD: There is no extensibilityelement in port type
-            return new JAXWSBinding();
-        }
-    }
+    // TODO: add cusomizing
+    //     private JAXWSBinding customizing(JavaModel jmodel, PortType portType) {
+    //         String portTypeName = portType.getQName().getLocalPart();
+    //         JAXWSBinding bindings = CustomizationParser.getInstance().getPortTypeExtension(portTypeName);
+    //         if (bindings != null) {
+    //             return bindings;
+    //         } else if (jmodel.getJAXWSBinding() != null) {
+    //             return jmodel.getJAXWSBinding();
+    //         } else {
+    //             // TBD: There is no extensibilityelement in port type
+    //             return new JAXWSBinding();
+    //         }
+    //     }
 }

Copied: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java (from r490267, incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ProcessorUtil.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java?view=diff&rev=490973&p1=incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ProcessorUtil.java&r1=490267&p2=incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java&r2=490973
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/ProcessorUtil.java (original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java Fri Dec 29 02:05:41 2006
@@ -17,19 +17,13 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.util;
+package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal;
 
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.StringTokenizer;
-
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Part;
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.DOMException;
@@ -42,63 +36,49 @@
 
 import org.apache.cxf.helpers.JavaUtils;
 import org.apache.cxf.jaxb.JAXBUtils;
-import org.apache.cxf.tools.common.DataBindingGenerator;
-import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.service.model.MessagePartInfo;
+
 import org.apache.cxf.tools.common.ToolContext;
-import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.util.ClassCollector;
+import org.apache.cxf.tools.util.URIParserUtil;
+import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 
 public final class ProcessorUtil {
-    //private static final Logger LOG = LogUtils.getL7dLogger(ProcessorUtil.class);
     private static final String KEYWORDS_PREFIX = "_";
     
     private ProcessorUtil() {
     }
 
-    public static String resolvePartName(Part part) {
-        return mangleNameToVariableName(part.getName());
+    public static String resolvePartName(MessagePartInfo part) {
+        return mangleNameToVariableName(part.getName().getLocalPart());
     }
 
-    public static String getPartType(Part part) {
-        String typeName;
-        if (part.getElementName() != null) {
-            typeName = part.getElementName().getLocalPart();
-        } else if (part.getTypeName() != null) {
-            typeName = part.getTypeName().getLocalPart();
-        } else {
-            typeName = "BadType";
-        }
-        return typeName;
+    public static String getPartType(MessagePartInfo part) {
+        return part.getConcreteName().getLocalPart();
     }
 
-    public static String resolvePartType(Part part) {
+    public static String resolvePartType(MessagePartInfo part) {
         return mangleNameToClassName(getPartType(part));
     }
     
-    public static String getType(Part part, ToolContext env, boolean fullname) {
-        DataBindingGenerator dataBinder = (DataBindingGenerator)env.get(ToolConstants.BINDING_GENERATOR);
-        String type = dataBinder.getType(getElementName(part), fullname);
+    public static String getType(MessagePartInfo part, ToolContext context, boolean fullname) {
+        DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
+        String type = dataBinding.getType(getElementName(part), fullname);
         if (type == null) {
             type = resolvePartType(part);
         }
         return type;
     }
     
-    public static QName getElementName(Part part) {
-        if (part == null) {
-            return null;
-        }
-        QName elementName = part.getElementName();
-        if (elementName == null) {
-            elementName = part.getTypeName();
-        }
-        return elementName;
+    public static QName getElementName(MessagePartInfo part) {
+        return part == null ? null : part.getConcreteName();
     }
 
     //
     // support multiple -p options
     // if user change the package name through -p namespace=package name
     //
-    public static QName getMappedElementName(Part part, ToolContext env) {
+    public static QName getMappedElementName(MessagePartInfo part, ToolContext env) {
         QName origin = getElementName(part);
         if (origin == null) {
             return null;
@@ -109,7 +89,7 @@
         return new QName(env.getCustomizedNS(origin.getNamespaceURI()), origin.getLocalPart());
     }
 
-    public static String resolvePartType(Part part, ToolContext env) {
+    public static String resolvePartType(MessagePartInfo part, ToolContext env) {
         if (env != null) {
             return resolvePartType(part, env, false);
         } else {
@@ -117,21 +97,17 @@
         }
     }
 
-   /* public static String resolvePartType(Part part, ProcessorEnvironment env) {
-        return resolvePartType(part, env, false);
-    }*/
-
-    public static String resolvePartType(Part part, ToolContext env, boolean fullName) {
-        DataBindingGenerator binder = (DataBindingGenerator)env.get(ToolConstants.BINDING_GENERATOR);
-        if (binder == null) {
-            String primitiveType = JAXBUtils.builtInTypeToJavaType(part.getTypeName().getLocalPart());
-            if (part.getTypeName() != null &&  primitiveType != null) {
+    public static String resolvePartType(MessagePartInfo part, ToolContext context, boolean fullName) {
+        DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
+        if (dataBinding == null) {
+            String primitiveType = JAXBUtils.builtInTypeToJavaType(part.getTypeQName().getLocalPart());
+            if (part.getTypeQName() != null &&  primitiveType != null) {
                 return primitiveType;
             } else {
                 return resolvePartType(part);
             }
         }
-        String name = binder.getType(getElementName(part), fullName);
+        String name = dataBinding.getType(getElementName(part), fullName);
         if (name == null) {
             return resolvePartType(part);
         }
@@ -139,16 +115,8 @@
        
     }
 
-    public static String resolvePartNamespace(Part part) {
-        QName qname = part.getElementName();
-        if (qname == null) {
-            qname = part.getTypeName();
-        }
-        if (qname != null) {
-            return qname.getNamespaceURI();
-        } else {
-            return null;
-        }
+    public static String resolvePartNamespace(MessagePartInfo part) {
+        return part.getConcreteName().getNamespaceURI();
     }
 
     public static String mangleNameToClassName(String clzName) {
@@ -231,27 +199,21 @@
     //
     // the non-wrapper style will get the type info from the part directly
     //
-    public static String getFullClzName(Part part, ToolContext env,
-                                        ClassCollector collector, boolean boxify) {
-        DataBindingGenerator dataBindingGenerator = (DataBindingGenerator)env
-            .get(ToolConstants.BINDING_GENERATOR);
+    public static String getFullClzName(MessagePartInfo part, ToolContext context, boolean boxify) {
+        DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
         String jtype = null;
         QName xmlTypeName = getElementName(part);
-        if (xmlTypeName == null) {
-            xmlTypeName = part.getTypeName();
-           
-        }
 
         // if this flag  is true , mapping to java Type first;
         // if not found , findd the primitive type : int ,long 
         // if not found,  find in the generated class
        
             
-        if (boxify && dataBindingGenerator != null) {
-            jtype = dataBindingGenerator.getJavaType(xmlTypeName, true);
+        if (boxify && dataBinding != null) {
+            jtype = dataBinding.getJavaType(xmlTypeName, true);
         } 
         
-        if (boxify && dataBindingGenerator == null) {
+        if (boxify && dataBinding == null) {
             Class holderClass = JAXBUtils.holderClass(xmlTypeName.getLocalPart());
             jtype = holderClass == null ? null : holderClass.getName();
             if (jtype == null) {
@@ -260,26 +222,26 @@
                        
         }
         
-        if (!boxify && dataBindingGenerator != null) {
-            jtype = dataBindingGenerator.getJavaType(xmlTypeName, false);
+        if (!boxify && dataBinding != null) {
+            jtype = dataBinding.getJavaType(xmlTypeName, false);
         }
         
-        if (!boxify && dataBindingGenerator == null) {
+        if (!boxify && dataBinding == null) {
             jtype = JAXBUtils.builtInTypeToJavaType(xmlTypeName.getLocalPart());
         }
             
-        
         String namespace = xmlTypeName.getNamespaceURI();
-        String type = resolvePartType(part, env, true);
-        String userPackage = env.mapPackageName(namespace);
+        String type = resolvePartType(part, context, true);
+        String userPackage = context.mapPackageName(namespace);
 
+        ClassCollector collector = context.get(ClassCollector.class);
         if (jtype == null) {
-            jtype = collector.getTypesFullClassName(parsePackageName(namespace, userPackage), type);        
+            jtype = collector.getTypesFullClassName(parsePackageName(namespace, userPackage), type);
         }
 
         if (jtype == null) {
             if (!type.equals(resolvePartType(part))) {
-                jtype = resolvePartType(part, env, true);
+                jtype = resolvePartType(part, context, true);
             } else {
                 jtype = parsePackageName(namespace, userPackage) + "." + type;
             }          
@@ -333,76 +295,6 @@
 
    
 
-    @SuppressWarnings("unchecked")
-    public static boolean isWrapperStyle(Operation operation, ToolContext env) throws ToolException {
-
-        Message inputMessage = operation.getInput() == null ? null : operation.getInput().getMessage();
-        Message outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
-
-        Map<String, Part> inputParts = new HashMap<String, Part>();
-        Map<String, Part> outputParts = new HashMap<String, Part>();
-
-        if (inputMessage != null) {
-            inputParts = inputMessage.getParts();
-        }
-        if (outputMessage != null) {
-            outputParts = outputMessage.getParts();
-        }
-
-        //
-        // RULE No.1:
-        // The operation's input and output message (if present) each contain
-        // only a single part
-        //
-        if (inputParts.size() > 1 || outputParts.size() > 1) {
-            return false;
-        }
-
-        //
-        // RULE No.2:
-        // The input message part refers to a global element decalration whose
-        // localname
-        // is equal to the operation name
-        //
-        Part inputPart = null;
-        if (inputParts.size() == 1) {
-            inputPart = inputParts.values().iterator().next();
-            if (inputPart != null) {
-                QName inputElement = inputPart.getElementName();
-                if (inputElement == null) {
-                    return false;
-                } else if (!operation.getName().equals(inputElement.getLocalPart())) {
-                    return false;
-                }
-            }
-        }
-        //
-        // RULE No.3:
-        // The output message part refers to a global element decalration
-        //
-        Part outputPart = null;
-        if (outputParts.size() == 1) {
-            outputPart = outputParts.values().iterator().next();
-            if (outputPart != null) {
-                QName outputElement = outputPart.getElementName();
-                if (outputElement == null) {
-                    return false;
-                }
-            }
-        }
-
-        //
-        // RULE No.4 and No5:
-        // wrapper element should be pure complex type
-        //
-        DataBindingGenerator databinder = (DataBindingGenerator)env.get(ToolConstants.BINDING_GENERATOR);
-        if (databinder.getBlock(inputPart) == null
-            || databinder.getBlock(outputPart) == null) {
-            return false;
-        }
-
-        return true;
-    }
     public static Node cloneNode(Document document, Node node, boolean deep) throws DOMException {
         if (document == null || node == null) {
             return null;

Copied: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/SEIAnnotationProcessor.java (from r490267, incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/SEIAnnotationProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/SEIAnnotationProcessor.java?view=diff&rev=490973&p1=incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/SEIAnnotationProcessor.java&r1=490267&p2=incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/SEIAnnotationProcessor.java&r2=490973
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/SEIAnnotationProcessor.java (original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/SEIAnnotationProcessor.java Fri Dec 29 02:05:41 2006
@@ -17,12 +17,12 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.wsdl2java.processor.internal;
+package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal;
 
 import java.util.*;
 import javax.jws.soap.SOAPBinding;
-import javax.wsdl.Definition;
 
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.model.JavaAnnotation;
 import org.apache.cxf.tools.common.model.JavaInterface;
@@ -36,7 +36,8 @@
         super(penv);
     }
     
-    public void process(JavaModel javaModel, Definition def) {
+    public void process(ServiceInfo service) {
+        JavaModel javaModel = context.get(JavaModel.class);
         Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
         for (Iterator iter = interfaces.keySet().iterator(); iter.hasNext();) {
             String interfaceName = (String)iter.next();
@@ -49,7 +50,7 @@
 
             intf.addAnnotation(serviceAnnotation.toString());
             
-            if (def.getBindings().size() == 0) {
+            if (service.getBindings().size() == 0) {
                 return;
             }
             if (processBinding(intf)) {

Copied: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java (from r490267, incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java?view=diff&rev=490973&p1=incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java&r1=490267&p2=incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java&r2=490973
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java (original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java Fri Dec 29 02:05:41 2006
@@ -17,39 +17,30 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.wsdl2java.processor.internal;
+package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal;
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Logger;
 
-import javax.wsdl.Binding;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Part;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
-import javax.wsdl.Service;
-import javax.wsdl.extensions.http.HTTPAddress;
+import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.http.HTTPBinding;
 import javax.wsdl.extensions.mime.MIMEMultipartRelated;
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.common.extensions.jaxws.CustomizationParser;
-import org.apache.cxf.tools.common.extensions.jaxws.JAXWSBinding;
-import org.apache.cxf.tools.common.extensions.jms.JMSAddress;
-import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
 import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
 import org.apache.cxf.tools.common.extensions.soap.SoapBody;
 import org.apache.cxf.tools.common.extensions.soap.SoapHeader;
@@ -62,20 +53,17 @@
 import org.apache.cxf.tools.common.model.JavaPort;
 import org.apache.cxf.tools.common.model.JavaServiceClass;
 import org.apache.cxf.tools.common.model.JavaType;
-import org.apache.cxf.tools.common.toolspec.parser.CommandLineParser;
+
+import org.apache.cxf.tools.util.ClassCollector;
 import org.apache.cxf.tools.util.ProcessorUtil;
 import org.apache.cxf.tools.util.SOAPBindingUtil;
 
 public class ServiceProcessor extends AbstractProcessor {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(CommandLineParser.class);
-
     private String soapOPAction = "SOAPACTION";
 
     private String soapOPStyle = "STYLE";
 
-    private Definition definition;
-
     private BindingType bindingType;
 
     private final int inHEADER = 1;
@@ -87,152 +75,107 @@
     private final int noHEADER = 0;
 
     private Object bindingObj;
+    private ServiceInfo service;
 
     public ServiceProcessor(ToolContext penv) {
         super(penv);
     }
 
-    public ServiceProcessor(ToolContext penv, Definition def) {
-        super(penv);
-        this.definition = def;
-    }
-
-    public void process(JavaModel model) throws ToolException {
-
-        Collection services = definition.getServices().values();
-        if (services.size() == 0) {
-            Iterator bindingIte = definition.getBindings().values().iterator();
-            while (bindingIte.hasNext()) {
-                Binding binding = (Binding)bindingIte.next();
-                Iterator bopIte = binding.getBindingOperations().iterator();
-                while (bopIte.hasNext()) {
-                    BindingOperation bop = (BindingOperation)bopIte.next();
-                    processOperation(model, bop, binding);
-                }
-            }
-            return;
-        }
-        Iterator ite = services.iterator();
-        while (ite.hasNext()) {
-            Service service = (Service)ite.next();
-            processService(model, service);
-        }
+    public void process(ServiceInfo si) throws ToolException {
+        this.service = si;
+        processService(context.get(JavaModel.class));
+        
     }
 
     private boolean isNameCollision(String packageName, String className) {
-        if (env.optionSet(ToolConstants.CFG_GEN_OVERWRITE)) {
+        if (context.optionSet(ToolConstants.CFG_GEN_OVERWRITE)) {
             return false;
         }
+        ClassCollector collector = context.get(ClassCollector.class);
         return collector.containTypesClass(packageName, className)
                || collector.containSeiClass(packageName, className)
                || collector.containExceptionClass(packageName, className);
     }
 
-    private void processService(JavaModel model, Service service) throws ToolException {
+    private void processService(JavaModel model) throws ToolException {
         JavaServiceClass sclz = new JavaServiceClass(model);
-        String name = ProcessorUtil.mangleNameToClassName(service.getQName().getLocalPart());
-        String namespace = service.getQName().getNamespaceURI();
-        String packageName = ProcessorUtil.parsePackageName(namespace, env.mapPackageName(namespace));
+        String name = ProcessorUtil.mangleNameToClassName(service.getName().getLocalPart());
+        String namespace = service.getName().getNamespaceURI();
+        String packageName = ProcessorUtil.parsePackageName(namespace, context.mapPackageName(namespace));
 
         while (isNameCollision(packageName, name)) {
             name = name + "_Service";
         }
 
         sclz.setName(name);
-        sclz.setServiceName(service.getQName().getLocalPart());
+        sclz.setServiceName(service.getName().getLocalPart());
         sclz.setNamespace(namespace);
         sclz.setPackageName(packageName);
 
-        Map ports = service.getPorts();
+        Collection<EndpointInfo> ports = service.getEndpoints();
 
-        for (Iterator ite = ports.values().iterator(); ite.hasNext();) {
-            Port port = (Port)ite.next();
+        for (EndpointInfo port : ports) {
             JavaPort javaport = processPort(model, port);
             sclz.addPort(javaport);
         }
         model.addServiceClass(name, sclz);
     }
 
-    private JavaPort processPort(JavaModel model, Port port) throws ToolException {
-        JavaPort jport = new JavaPort(ProcessorUtil.mangleNameToClassName(port.getName()));
-        jport.setPortName(port.getName());
-        Binding binding = port.getBinding();
-        // TODO: extend other bindings
-        jport.setBindingAdress(getPortAddress(port));
-        jport.setBindingName(binding.getQName().getLocalPart());
-       
+    private JavaPort processPort(JavaModel model, EndpointInfo port) throws ToolException {
+        JavaPort jport = new JavaPort(ProcessorUtil.mangleNameToClassName(port.getName().getLocalPart()));
+        jport.setPortName(port.getName().getLocalPart());
+        BindingInfo binding = port.getBinding();
+        jport.setBindingAdress(port.getAddress());
+        jport.setBindingName(binding.getName().getLocalPart());
         
-        String namespace = binding.getPortType().getQName().getNamespaceURI();
-        String packageName = ProcessorUtil.parsePackageName(namespace, env.mapPackageName(namespace));
+        String namespace = binding.getInterface().getName().getNamespaceURI();
+        String packageName = ProcessorUtil.parsePackageName(namespace, context.mapPackageName(namespace));
         jport.setPackageName(packageName);
 
-        String portType = binding.getPortType().getQName().getLocalPart();
+        String portType = binding.getInterface().getName().getLocalPart();
         jport.setPortType(portType);
         jport.setInterfaceClass(ProcessorUtil.mangleNameToClassName(portType));
 
-        bindingType = getBindingType(binding);
 
+        bindingType = getBindingType(binding);
+        
         if (bindingType == null) {
             org.apache.cxf.common.i18n.Message msg = 
                 new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL",
-                                                             LOG, 
-                                                             binding.getQName());
+                                                       LOG, 
+                                                       binding.getName());
             throw new ToolException(msg);
         }
 
         if (isSoapBinding()) {
             SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj);
-            jport.setStyle(getSoapStyle(spbd.getStyle()));
+            jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle()));
             jport.setTransURI(spbd.getTransportURI());
         }
 
-        /*
-         * if (bindingType.name().equals("HTTPBinding")) { // TBD }
-         */
-
-        Iterator ite = binding.getBindingOperations().iterator();
-        while (ite.hasNext()) {
-            BindingOperation bop = (BindingOperation)ite.next();
+        Collection<BindingOperationInfo> operations = binding.getOperations();
+        for (BindingOperationInfo bop : operations) {
             processOperation(model, bop, binding);
         }
         return jport;
     }
 
-    private javax.jws.soap.SOAPBinding.Style getSoapStyle(String soapStyle) {
-        if ("".equals(soapStyle)) {
-            return null;
-        } else if ("RPC".equalsIgnoreCase(soapStyle)) {
-            return javax.jws.soap.SOAPBinding.Style.RPC;
-        } else {
-            return javax.jws.soap.SOAPBinding.Style.DOCUMENT;
-        }
-    }
-
-    private javax.jws.soap.SOAPBinding.Use getSoapUse(String soapUse) {
-
-        if ("".equals(soapUse)) {
-            return null;
-        } else if ("ENCODED".equalsIgnoreCase(soapUse)) {
-            return javax.jws.soap.SOAPBinding.Use.ENCODED;
-        } else {
-            return javax.jws.soap.SOAPBinding.Use.LITERAL;
-        }
-
-    }
-
-    private void processOperation(JavaModel model, BindingOperation bop, Binding binding)
+    private void processOperation(JavaModel model, BindingOperationInfo bop, BindingInfo binding)
         throws ToolException {
         String portType = ProcessorUtil
-            .mangleNameToClassName(binding.getPortType().getQName().getLocalPart());
+            .mangleNameToClassName(binding.getInterface().getName().getLocalPart());
         JavaInterface jf = model.getInterfaces().get(portType);
         // TODO: extend other bindings
-        doCustomizeBinding(model, jf, binding);
+
+        // TODO: add customize here
+        //doCustomizeBinding(model, jf, binding);
+        
         if (isSoapBinding()) {
             SoapBinding soapBinding = (SoapBinding)bindingObj;
-            if (getSoapStyle(soapBinding.getStyle()) == null) {
+            if (SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()) == null) {
                 jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
             } else {
-                jf.setSOAPStyle(getSoapStyle(soapBinding.getStyle()));
+                jf.setSOAPStyle(SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()));
             }
         } else {
             // REVISIT: fix for xml binding
@@ -242,23 +185,24 @@
         Object[] methods = jf.getMethods().toArray();
         for (int i = 0; i < methods.length; i++) {
             JavaMethod jm = (JavaMethod)methods[i];
-            if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName())) {
+            if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName().getLocalPart())) {
                 if (isSoapBinding()) {
-                    doCustomizeOperation(jf, jm, bop);
+                    // TODO: add customize here
+                    //doCustomizeOperation(jf, jm, bop);
                     Map prop = getSoapOperationProp(bop);
                     String soapAction = prop.get(soapOPAction) == null ? "" : (String)prop.get(soapOPAction);
                     String soapStyle = prop.get(soapOPStyle) == null ? "" : (String)prop.get(soapOPStyle);
                     jm.setSoapAction(soapAction);
-                    if (getSoapStyle(soapStyle) == null && this.bindingObj == null) {
+                    if (SOAPBindingUtil.getSoapStyle(soapStyle) == null && this.bindingObj == null) {
                         org.apache.cxf.common.i18n.Message msg = 
                             new  org.apache.cxf.common.i18n.Message("BINDING_STYLE_NOT_DEFINED",
                                                                          LOG);
                         throw new ToolException(msg);
                     }
-                    if (getSoapStyle(soapStyle) == null) {
+                    if (SOAPBindingUtil.getSoapStyle(soapStyle) == null) {
                         jm.setSoapStyle(jf.getSOAPStyle());
                     } else {
-                        jm.setSoapStyle(getSoapStyle(soapStyle));
+                        jm.setSoapStyle(SOAPBindingUtil.getSoapStyle(soapStyle));
                     }
                 } else {
                     // REVISIT: fix for xml binding
@@ -269,7 +213,7 @@
                     jm.getAnnotationMap().remove("SOAPBinding");
                 }
 
-                OperationProcessor processor = new OperationProcessor(env);
+                OperationProcessor processor = new OperationProcessor(context);
 
                 int headerType = isNonWrappable(bop);
 
@@ -277,12 +221,12 @@
                     // changed wrapper style
 
                     jm.setWrapperStyle(false);
-                    processor.processMethod(jm, bop.getOperation());
+                    processor.processMethod(jm, bop.getOperationInfo());
                     jm.getAnnotationMap().remove("ResponseWrapper");
                     jm.getAnnotationMap().remove("RequestWrapper");
 
                 } else {
-                    processor.processMethod(jm, bop.getOperation());
+                    processor.processMethod(jm, bop.getOperationInfo());
 
                 }
 
@@ -302,25 +246,23 @@
         parameter.getAnnotation().addArgument("header", "true", "");
     }
 
-    private void processParameter(JavaMethod jm, BindingOperation operation) throws ToolException {
+    private void processParameter(JavaMethod jm, BindingOperationInfo operation) throws ToolException {
 
         // process input
         
-        Iterator inbindings = null;
-        if (operation.getBindingInput() != null) {
-            inbindings = operation.getBindingInput().getExtensibilityElements().iterator();
+        List<ExtensibilityElement> inbindings = null;
+        if (operation.getInput() != null) {
+            inbindings = operation.getInput().getExtensors(ExtensibilityElement.class);
         }
         String use = null;
-        while (inbindings != null && inbindings.hasNext()) {
-            Object obj = inbindings.next();
-            
-            if (SOAPBindingUtil.isSOAPBody(obj)) {
-                SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
+        for (ExtensibilityElement ext : inbindings) {
+            if (SOAPBindingUtil.isSOAPBody(ext)) {
+                SoapBody soapBody = SOAPBindingUtil.getSoapBody(ext);
                 use = soapBody.getUse();
             }            
             
-            if (SOAPBindingUtil.isSOAPHeader(obj)) {
-                SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(obj);
+            if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
                 boolean found = false;
                 for (JavaParameter parameter : jm.getParameters()) {
                     if (soapHeader.getPart().equals(parameter.getPartName())) {
@@ -328,17 +270,18 @@
                         found = true;
                     }
                 }
-                if (Boolean.valueOf((String)env.get(ToolConstants.CFG_EXTRA_SOAPHEADER)).booleanValue()
+                if (Boolean.valueOf((String)context.get(ToolConstants.CFG_EXTRA_SOAPHEADER)).booleanValue()
                     && !found) {
                     // Header can't be found in java method parameters, in
                     // different message
                     // other than messages used in porttype operation
-                    ParameterProcessor processor = new ParameterProcessor(this.env);
-                    Part exPart = this.definition.getMessage(soapHeader.getMessage()).getPart(
-                                                                                              soapHeader
-                                                                                                  .getPart());
+                    ParameterProcessor processor = new ParameterProcessor(context);
+                    MessagePartInfo exPart = service.getMessage(soapHeader.getMessage())
+                        .getMessagePart(new QName(soapHeader.getMessage().getNamespaceURI(),
+                                                  soapHeader.getPart()));
+                        
                     JavaType.Style jpStyle = JavaType.Style.IN;
-                    if (isInOutParam(soapHeader.getPart(), operation.getBindingOutput())) {
+                    if (isInOutParam(soapHeader.getPart(), operation.getOutput())) {
                         jpStyle = JavaType.Style.INOUT;
                     }
                     JavaParameter jp = processor.addParameterFromBinding(jm, exPart, jpStyle);
@@ -348,24 +291,23 @@
                     setParameterAsHeader(jp);
                 }
             }
-            if (obj instanceof MIMEMultipartRelated && jm.getBindingExt().isEnableMime()) {
+            if (ext instanceof MIMEMultipartRelated && jm.getBindingExt().isEnableMime()) {
                 // Commented for future use
                 LOG.warning("The MIME content in wsdl file will be ignored, "
                             + "current version does not support MIME content");
-                // MIMEProcessor mimeProcessor = new MIMEProcessor(this.env);
+                // MIMEProcessor mimeProcessor = new MIMEProcessor(context);
                 // mimeProcessor.process(jm, (MIMEMultipartRelated)obj,
                 // JavaType.Style.IN);
             }
         }
 
         // process output
-        if (operation.getBindingOutput() != null) {
-            Iterator outbindings = operation.getBindingOutput().getExtensibilityElements().iterator();
-            while (outbindings.hasNext()) {
-                Object obj = outbindings.next();
-                
-                if (SOAPBindingUtil.isSOAPHeader(obj)) {         
-                    SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(obj);
+        if (operation.getOutput() != null) {
+            List<ExtensibilityElement> outbindings =
+                operation.getOutput().getExtensors(ExtensibilityElement.class);
+            for (ExtensibilityElement ext : outbindings) {
+                if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                    SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
                     boolean found = false;
                     for (JavaParameter parameter : jm.getParameters()) {
                         if (soapHeader.getPart().equals(parameter.getPartName())) {
@@ -376,24 +318,25 @@
                     if (jm.getReturn().getName().equals(soapHeader.getPart())) {
                         found = true;
                     }
-                    if (Boolean.valueOf((String)env.get(ToolConstants.CFG_EXTRA_SOAPHEADER)).booleanValue()
+                    if (Boolean.valueOf((String)context.get(ToolConstants.CFG_EXTRA_SOAPHEADER))
                         && !found) {
                         // Header can't be found in java method parameters, in
                         // different message
                         // other than messages used in porttype operation
-                        ParameterProcessor processor = new ParameterProcessor(this.env);
-                        Part exPart = this.definition.getMessage(soapHeader.getMessage())
-                            .getPart(soapHeader.getPart());
+                        ParameterProcessor processor = new ParameterProcessor(context);
+                        MessagePartInfo exPart = service.getMessage(soapHeader.getMessage())
+                            .getMessagePart(new QName(soapHeader.getMessage().getNamespaceURI(),
+                                                      soapHeader.getPart()));
                         JavaParameter jp = processor.addParameterFromBinding(jm, exPart, JavaType.Style.OUT);
                         setParameterAsHeader(jp);
                     }
                 }
-                if (obj instanceof MIMEMultipartRelated && jm.getBindingExt().isEnableMime()) {
+                if (ext instanceof MIMEMultipartRelated && jm.getBindingExt().isEnableMime()) {
                     // Commented for future use
                     LOG.warning("The MIME content in wsdl file will be ignored, "
                                 + "current version does not support MIME content");
                     // MIMEProcessor mimeProcessor = new
-                    // MIMEProcessor(this.env);
+                    // MIMEProcessor(context);
                     // mimeProcessor.process(jm, (MIMEMultipartRelated)obj,
                     // JavaType.Style.OUT);
 
@@ -401,7 +344,7 @@
             }
         }
 
-        jm.setSoapUse(getSoapUse(use));
+        jm.setSoapUse(SOAPBindingUtil.getSoapUse(use));
         if (javax.jws.soap.SOAPBinding.Style.RPC == jm.getSoapStyle()
             && javax.jws.soap.SOAPBinding.Use.ENCODED == jm.getSoapUse()) {
             System.err.println("** Unsupported RPC-Encoded Style Use **");
@@ -416,69 +359,39 @@
         }
     }
 
-    private Map getSoapOperationProp(BindingOperation bop) {
+    private Map getSoapOperationProp(BindingOperationInfo bop) {
         Map<String, Object> soapOPProp = new HashMap<String, Object>();
 
-        if (bop.getExtensibilityElements() != null) {
-            Iterator ite = bop.getExtensibilityElements().iterator();
-            while (ite.hasNext()) {
-                Object obj = ite.next();
-                
-                if (SOAPBindingUtil.isSOAPOperation(obj)) {
-                    SoapOperation soapOP = SOAPBindingUtil.getSoapOperation(obj);
-                    soapOPProp.put(this.soapOPAction, soapOP.getSoapActionURI());
-                    soapOPProp.put(this.soapOPStyle, soapOP.getStyle());
-                }
+        for (ExtensibilityElement ext : bop.getExtensors(ExtensibilityElement.class)) {
+            if (SOAPBindingUtil.isSOAPOperation(ext)) {
+                SoapOperation soapOP = SOAPBindingUtil.getSoapOperation(ext);
+                soapOPProp.put(this.soapOPAction, soapOP.getSoapActionURI());
+                soapOPProp.put(this.soapOPStyle, soapOP.getStyle());
             }
         }
         return soapOPProp;
     }
 
-    private String getPortAddress(Port port) {
-        Iterator it = port.getExtensibilityElements().iterator();
-        String address = null;
-        while (it.hasNext()) {
-            Object obj = it.next();
-                        
-            if (SOAPBindingUtil.isSOAPAddress(obj)) {
-                SoapAddress soapAddress = SOAPBindingUtil.getSoapAddress(obj);
-                address = soapAddress.getLocationURI();
-            }
-            if (obj instanceof JMSAddress) {
-                address = ((JMSAddress)obj).getAddress();
-            }
-
-            if (obj instanceof HTTPAddress) {
-                address = ((HTTPAddress)obj).getLocationURI();
-            }
-
-        }
-        return address;
-    }
-
-    private BindingType getBindingType(Binding binding) {
-        Iterator it = binding.getExtensibilityElements().iterator();
-        while (it.hasNext()) {
-            Object obj = it.next();
-            
-            if (SOAPBindingUtil.isSOAPBinding(obj)) {
-                bindingObj = SOAPBindingUtil.getSoapBinding(obj);
+    private BindingType getBindingType(BindingInfo binding) {
+        for (ExtensibilityElement ext : binding.getExtensors(ExtensibilityElement.class)) {
+            if (SOAPBindingUtil.isSOAPBinding(ext)) {
+                bindingObj = SOAPBindingUtil.getSoapBinding(ext);
                 return BindingType.SOAPBinding;
             }
-            if (obj instanceof HTTPBinding) {
-                bindingObj = (HTTPBinding)obj;
+            if (ext instanceof HTTPBinding) {
+                bindingObj = (HTTPBinding)ext;
                 return BindingType.HTTPBinding;
             }
             // TBD XMLBinding
             return BindingType.XMLBinding;
-
+            
         }
         return null;
     }
-
-    private int isNonWrappable(BindingOperation bop) {
-        String operationName = bop.getName();
-        Message bodyMessage = null;
+    
+    private int isNonWrappable(BindingOperationInfo bop) {
+        QName operationName = bop.getName();
+        MessageInfo bodyMessage = null;
         QName headerMessage = null;
         SoapHeader header = null;
         boolean containParts = false;
@@ -488,15 +401,13 @@
         int result = this.noHEADER;
 
         // begin process input
-        if (bop.getBindingInput() != null) {
-            Iterator ite = bop.getBindingInput().getExtensibilityElements().iterator();
-            while (ite.hasNext()) {
-                Object obj = ite.next();
-                if (SOAPBindingUtil.isSOAPBody(obj)) {
+        if (bop.getInput() != null) {
+            for (ExtensibilityElement ext : bop.getInput().getExtensors(ExtensibilityElement.class)) {
+                if (SOAPBindingUtil.isSOAPBody(ext)) {
                     bodyMessage = getMessage(operationName, true);
                 }
-                if (SOAPBindingUtil.isSOAPHeader(obj)) {
-                    header = SOAPBindingUtil.getSoapHeader(obj);
+                if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                    header = SOAPBindingUtil.getSoapHeader(ext);
                     headerMessage = header.getMessage();
                     if (header.getPart().length() > 0) {
                         containParts = true;
@@ -505,8 +416,8 @@
             }
 
             if (headerMessage != null && bodyMessage != null
-                && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getQName().getNamespaceURI())
-                && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getQName().getLocalPart())) {
+                && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI())
+                && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
                 isSameMessage = true;
             }
 
@@ -520,15 +431,13 @@
         containParts = false;
 
         // process output
-        if (bop.getBindingOutput() != null) {
-            Iterator ite1 = bop.getBindingOutput().getExtensibilityElements().iterator();
-            while (ite1.hasNext()) {
-                Object obj = ite1.next();
-                if (SOAPBindingUtil.isSOAPBody(obj)) {
+        if (bop.getOutput() != null) {
+            for (ExtensibilityElement ext : bop.getOutput().getExtensors(ExtensibilityElement.class)) {
+                if (SOAPBindingUtil.isSOAPBody(ext)) {
                     bodyMessage = getMessage(operationName, false);
                 }
-                if (SOAPBindingUtil.isSOAPHeader(obj)) {
-                    header = SOAPBindingUtil.getSoapHeader(obj);
+                if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                    header = SOAPBindingUtil.getSoapHeader(ext);
                     headerMessage = header.getMessage();
                     if (header.getPart().length() > 0) {
                         containParts = true;
@@ -536,10 +445,10 @@
                 }
             }
             if (headerMessage != null && bodyMessage != null
-                && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getQName().getNamespaceURI())
-                && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getQName().getLocalPart())) {
+                && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI())
+                && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
                 isSameMessage = true;
-                if (bodyMessage.getParts().size() == 1) {
+                if (bodyMessage.getMessageParts().size() == 1) {
                     allPartsHeader = true;
                 }
 
@@ -554,103 +463,92 @@
         }
 
         return result;
-
-    }
-
-    private Message getMessage(String operationName, boolean isIn) {
-        Iterator ite = definition.getPortTypes().values().iterator();
-        Message msg = null;
-        while (ite.hasNext()) {
-            PortType portType = (PortType)ite.next();
-            Iterator ite1 = portType.getOperations().iterator();
-            while (ite1.hasNext()) {
-                Operation op = (Operation)ite1.next();
-                if (operationName.equals(op.getName())) {
-                    if (isIn) {
-                        msg = op.getInput().getMessage();
-                    } else {
-                        msg = op.getOutput().getMessage();
-                    }
-                    break;
-                }
-            }
-        }
-
-        return msg;
     }
 
-    private void doCustomizeBinding(JavaModel jmodel, JavaInterface ji, Binding binding) {
-        JAXWSBinding bindingExt = null;
-        List extElements = binding.getExtensibilityElements();
-        if (extElements.size() > 0) {
-            Iterator iterator = extElements.iterator();
-            while (iterator.hasNext()) {
-                Object obj = iterator.next();
-                if (obj instanceof JAXWSBinding) {
-                    bindingExt = (JAXWSBinding)obj;
-                    ji.setBindingExt(bindingExt);
-                    return;
-                }
-            }
-        }
-        String portTypeName = binding.getPortType().getQName().getLocalPart();
-        bindingExt = CustomizationParser.getInstance().getPortTypeExtension(portTypeName);
-        if (bindingExt != null) {
-            if (!bindingExt.isSetMimeEnable() && jmodel.getJAXWSBinding().isSetMimeEnable()
-                && jmodel.getJAXWSBinding().isEnableMime()) {
-                bindingExt.setSetMimeEnable(true);
-                bindingExt.setEnableMime(true);
-            }
-        } else if (jmodel.getJAXWSBinding() != null) {
-            bindingExt = new JAXWSBinding();
-            if (jmodel.getJAXWSBinding().isSetMimeEnable() && jmodel.getJAXWSBinding().isEnableMime()) {
-                bindingExt.setSetMimeEnable(true);
-                bindingExt.setEnableMime(true);
+    private MessageInfo getMessage(QName operationName, boolean isIn) {
+        for (OperationInfo operation : service.getInterface().getOperations()) {
+            if (operationName.equals(operation.getName()) && isIn) {
+                return operation.getInput();
+            } else {
+                return operation.getOutput();
             }
-        } else {
-            // TBD: There is no extensibilityelement in port type
-            bindingExt = new JAXWSBinding();
         }
-
-        ji.setBindingExt(bindingExt);
+        return null;
     }
 
-    private void doCustomizeOperation(JavaInterface ji, JavaMethod jm, BindingOperation bo) {
-        JAXWSBinding bindingExt = null;
-        List extElements = bo.getExtensibilityElements();
-        if (extElements.size() > 0) {
-            Iterator iterator = extElements.iterator();
-            while (iterator.hasNext()) {
-                Object obj = iterator.next();
-                if (obj instanceof JAXWSBinding) {
-                    bindingExt = (JAXWSBinding)obj;
-                    jm.setBindingExt(bindingExt);
-                    return;
-                }
-            }
-        }
-        String portTypeName = ji.getWebServiceName();
-        String operationName = bo.getName();
-        bindingExt = CustomizationParser.getInstance().getPortTypeOperationExtension(portTypeName,
-                                                                                     operationName);
-        if (bindingExt != null) {
-            if (!bindingExt.isSetMimeEnable() && ji.getBindingExt() != null
-                && ji.getBindingExt().isSetMimeEnable() && ji.getBindingExt().isEnableMime()) {
-                bindingExt.setSetMimeEnable(true);
-                bindingExt.setEnableMime(true);
-            }
-        } else if (ji.getBindingExt() != null) {
-            bindingExt = new JAXWSBinding();
-            if (ji.getBindingExt().isSetMimeEnable() && ji.getBindingExt().isEnableMime()) {
-                bindingExt.setSetMimeEnable(true);
-                bindingExt.setEnableMime(true);
-            }
-        } else {
-            // TBD: There is no extensibilityelement in port type
-            bindingExt = new JAXWSBinding();
-        }
-        jm.setBindingExt(bindingExt);
-    }
+    // TODO: enable customize
+//     private void doCustomizeBinding(JavaModel jmodel, JavaInterface ji, Binding binding) {
+//         JAXWSBinding bindingExt = null;
+//         List extElements = binding.getExtensibilityElements();
+//         if (extElements.size() > 0) {
+//             Iterator iterator = extElements.iterator();
+//             while (iterator.hasNext()) {
+//                 Object obj = iterator.next();
+//                 if (obj instanceof JAXWSBinding) {
+//                     bindingExt = (JAXWSBinding)obj;
+//                     ji.setBindingExt(bindingExt);
+//                     return;
+//                 }
+//             }
+//         }
+//         String portTypeName = binding.getPortType().getQName().getLocalPart();
+//         bindingExt = CustomizationParser.getInstance().getPortTypeExtension(portTypeName);
+//         if (bindingExt != null) {
+//             if (!bindingExt.isSetMimeEnable() && jmodel.getJAXWSBinding().isSetMimeEnable()
+//                 && jmodel.getJAXWSBinding().isEnableMime()) {
+//                 bindingExt.setSetMimeEnable(true);
+//                 bindingExt.setEnableMime(true);
+//             }
+//         } else if (jmodel.getJAXWSBinding() != null) {
+//             bindingExt = new JAXWSBinding();
+//             if (jmodel.getJAXWSBinding().isSetMimeEnable() && jmodel.getJAXWSBinding().isEnableMime()) {
+//                 bindingExt.setSetMimeEnable(true);
+//                 bindingExt.setEnableMime(true);
+//             }
+//         } else {
+//             // TBD: There is no extensibilityelement in port type
+//             bindingExt = new JAXWSBinding();
+//         }
+
+//         ji.setBindingExt(bindingExt);
+//     }
+
+//     private void doCustomizeOperation(JavaInterface ji, JavaMethod jm, BindingOperation bo) {
+//         JAXWSBinding bindingExt = null;
+//         List extElements = bo.getExtensibilityElements();
+//         if (extElements.size() > 0) {
+//             Iterator iterator = extElements.iterator();
+//             while (iterator.hasNext()) {
+//                 Object obj = iterator.next();
+//                 if (obj instanceof JAXWSBinding) {
+//                     bindingExt = (JAXWSBinding)obj;
+//                     jm.setBindingExt(bindingExt);
+//                     return;
+//                 }
+//             }
+//         }
+//         String portTypeName = ji.getWebServiceName();
+//         String operationName = bo.getName();
+//         bindingExt = CustomizationParser.getInstance().getPortTypeOperationExtension(portTypeName,
+//                                                                                      operationName);
+//         if (bindingExt != null) {
+//             if (!bindingExt.isSetMimeEnable() && ji.getBindingExt() != null
+//                 && ji.getBindingExt().isSetMimeEnable() && ji.getBindingExt().isEnableMime()) {
+//                 bindingExt.setSetMimeEnable(true);
+//                 bindingExt.setEnableMime(true);
+//             }
+//         } else if (ji.getBindingExt() != null) {
+//             bindingExt = new JAXWSBinding();
+//             if (ji.getBindingExt().isSetMimeEnable() && ji.getBindingExt().isEnableMime()) {
+//                 bindingExt.setSetMimeEnable(true);
+//                 bindingExt.setEnableMime(true);
+//             }
+//         } else {
+//             // TBD: There is no extensibilityelement in port type
+//             bindingExt = new JAXWSBinding();
+//         }
+//         jm.setBindingExt(bindingExt);
+//     }
 
     public enum BindingType {
         HTTPBinding, SOAPBinding, XMLBinding
@@ -661,12 +559,10 @@
 
     }
 
-    private boolean isInOutParam(String inPartName, BindingOutput bop) {
-        Iterator it = bop.getExtensibilityElements().iterator();
-        while (it.hasNext()) {
-            Object obj = it.next();
-            if (SOAPBindingUtil.isSOAPHeader(obj)) {
-                String outPartName = (SOAPBindingUtil.getSoapHeader(obj)).getPart();
+    private boolean isInOutParam(String inPartName, BindingMessageInfo messageInfo) {
+        for (ExtensibilityElement ext : messageInfo.getExtensors(ExtensibilityElement.class)) {
+            if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                String outPartName = (SOAPBindingUtil.getSoapHeader(ext)).getPart();
                 if (inPartName.equals(outPartName)) {
                     return true;
                 }