You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2005/02/02 21:36:54 UTC

svn commit: r151046 - incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java

Author: mmerz
Date: Wed Feb  2 12:36:53 2005
New Revision: 151046

URL: http://svn.apache.org/viewcvs?view=rev&rev=151046
Log:
Added support for Arrays in the WSDL processing.

Contributor:  Daryoush Mehrtash


Modified:
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java?view=diff&r1=151045&r2=151046
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java Wed Feb  2 12:36:53 2005
@@ -80,739 +80,641 @@
  */
 public class XmlBeanWSDLProcessor implements WSDLProcessor {
 
-    private TypeMappingUtil mTmu;
+  private TypeMappingUtil mTmu;
 
-    public Jsr181TypeMetadata createObjectModel(InputStream wsdlStream)
-        throws Exception {
-        
-        DefinitionsDocument defDoc = parseWSDL(wsdlStream);
-        return toWebServiceMetadata(defDoc);
-        
-    }
-
-    public void setTypeMappingUtil(TypeMappingUtil tmu) {
-        mTmu = tmu;
-    }
-
-    public TypeMappingUtil getTypeMappingUtil() {
-        if (mTmu == null) {
-            mTmu = new XmlBeanTypeMappingUtil();
-        }
-        return mTmu;
-    }
-
-    public static final String TRANSPORT =
-            "http://schemas.xmlsoap.org/soap/http";
-
-    public static final String SOAPENCODING =
-            "http://schemas.xmlsoap.org/soap/encoding/";
-
-    public static final String WSDLNS = "http://schemas.xmlsoap.org/wsdl/soap/";
-
-    public static final String WSDLSOAPNS =
-            "http://schemas.xmlsoap.org/wsdl/soap/";
-
-    public Jsr181TypeMetadata toWebServiceMetadata
-        (DefinitionsDocument defDoc)
-        throws Exception {
-        Jsr181TypeMetadata wsm = new Jsr181TypeMetadataImpl();
-        Map<String, Jsr181MethodMetadata> methodMap =
-                new HashMap<String, Jsr181MethodMetadata>();
-        TDefinitions defs = defDoc.getDefinitions();
-        wsm.setWsTargetNamespace(defs.getTargetNamespace());
-        Map<String, TPart[]> messageMap = new HashMap<String, TPart[]>();
-        
-        if (defs.sizeOfServiceArray() > 0) {
-            wsm.setWsServiceName(defs.getServiceArray(0).getName());
-        }
-
-        if (defs.sizeOfMessageArray() > 0) {
-            TMessage[] messages = defs.getMessageArray();
-            for (TMessage msg : messages) {
-                messageMap.put(msg.getName(), msg.getPartArray());
-            }
-        }
-
-        TBinding tBind = null;
-        if (defs.sizeOfBindingArray() > 0) {
-            tBind = defs.getBindingArray(0);
-            processTBinding(tBind, wsm);
-        }
+  public Jsr181TypeMetadata createObjectModel(InputStream wsdlStream)
+      throws Exception {
 
-        if (defs.sizeOfPortTypeArray() > 0) {
-            TPortType tP = defs.getPortTypeArray(0);
-            wsm.setWsName(tP.getName());
-            TOperation[] operations = tP.getOperationArray();
-            TTypes types = null;
-            if (defs.sizeOfTypesArray() > 0) {
-                types = defs.getTypesArray(0);
-            }
-            
-            for (TOperation op : operations) {
+    DefinitionsDocument defDoc = parseWSDL(wsdlStream);
+    return toWebServiceMetadata(defDoc);
 
-                processTOperation(op,
-                                  wsm,
-                                  methodMap,
-                                  messageMap,
-                                  types);
-            }
+  }
+
+  public void setTypeMappingUtil(TypeMappingUtil tmu) {
+    mTmu = tmu;
+  }
+
+  public TypeMappingUtil getTypeMappingUtil() {
+    if (mTmu == null) {
+      mTmu = new XmlBeanTypeMappingUtil();
+    }
+    return mTmu;
+  }
+
+  public static final String TRANSPORT = "http://schemas.xmlsoap.org/soap/http";
+
+  public static final String SOAPENCODING = "http://schemas.xmlsoap.org/soap/encoding/";
+
+  public static final String WSDLNS = "http://schemas.xmlsoap.org/wsdl/soap/";
+
+  public static final String WSDLSOAPNS = "http://schemas.xmlsoap.org/wsdl/soap/";
+
+  public Jsr181TypeMetadata toWebServiceMetadata(DefinitionsDocument defDoc)
+      throws Exception {
+    Jsr181TypeMetadata wsm = new Jsr181TypeMetadataImpl();
+    Map<String, Jsr181MethodMetadata> methodMap = new HashMap<String, Jsr181MethodMetadata>();
+    TDefinitions defs = defDoc.getDefinitions();
+    wsm.setWsTargetNamespace(defs.getTargetNamespace());
+    Map<String, TPart[]> messageMap = new HashMap<String, TPart[]>();
+
+    if (defs.sizeOfServiceArray() > 0) {
+      wsm.setWsServiceName(defs.getServiceArray(0).getName());
+    }
+
+    if (defs.sizeOfMessageArray() > 0) {
+      TMessage[] messages = defs.getMessageArray();
+      for (TMessage msg : messages) {
+        messageMap.put(msg.getName(), msg.getPartArray());
+      }
+    }
+
+    TBinding tBind = null;
+    if (defs.sizeOfBindingArray() > 0) {
+      tBind = defs.getBindingArray(0);
+      processTBinding(tBind, wsm);
+    }
+
+    if (defs.sizeOfPortTypeArray() > 0) {
+      TPortType tP = defs.getPortTypeArray(0);
+      wsm.setWsName(tP.getName());
+      TOperation[] operations = tP.getOperationArray();
+      TTypes types = null;
+      if (defs.sizeOfTypesArray() > 0) {
+        types = defs.getTypesArray(0);
+      }
+
+      for (TOperation op : operations) {
+
+        processTOperation(op, wsm, methodMap, messageMap, types);
+      }
+    }
+
+    if (tBind != null) {
+      processTBindingOperation(tBind, wsm, methodMap);
+    }
+    return wsm;
+  }
+
+  /*
+   * public static DefinitionsDocument fromWebServiceMetadata
+   * (WebServiceTYPEMetadata wsm) throws Exception { String ns =
+   * wsm.getWsTargetNamespace(); DefinitionsDocument defDoc =
+   * DefinitionsDocument.Factory.newInstance(); TDefinitions tDefs =
+   * defDoc.addNewDefinitions(); TPortType tPT = tDefs.addNewPortType();
+   * tPT.setName(wsm.getWsName()); TBinding tBind = tDefs.addNewBinding();
+   * tBind.setName(tPT.getName() + "Binding"); tBind.setType(new QName(ns,
+   * tPT.getName())); org.xmlsoap.schemas.wsdl.soap.BindingDocument bindDoc =
+   * org.xmlsoap.schemas.wsdl.soap.BindingDocument.Factory.newInstance();
+   * org.xmlsoap.schemas.wsdl.soap.TBinding tSoapBind = bindDoc
+   * .addNewBinding(); if
+   * (SOAPBinding.Style.DOCUMENT.equals(wsm.getSoapBinding().getStyle())) {
+   * tSoapBind.setStyle(TStyleChoice.DOCUMENT); } else {
+   * tSoapBind.setStyle(TStyleChoice.RPC); } tSoapBind.setTransport(TRANSPORT);
+   * insertChild(tBind, bindDoc); processMethodMetadata(wsm.getMethods(), tDefs,
+   * tPT, tBind, ns); TService tServ = tDefs.addNewService();
+   * tServ.setName(wsm.getWsServiceName()); TPort tPort = tServ.addNewPort();
+   * tPort.setName(wsm.getWsName()); tPort.setBinding(new QName(ns,
+   * tBind.getName())); org.xmlsoap.schemas.wsdl.soap.AddressDocument addrDoc =
+   * org.xmlsoap.schemas.wsdl.soap.AddressDocument.Factory.newInstance();
+   * org.xmlsoap.schemas.wsdl.soap.TAddress tAddr = addrDoc.addNewAddress();
+   * tAddr.setLocation("fake://FAKEURL"); insertChild(tPort, tAddr); return
+   * defDoc; }
+   */
+
+  private void processTOperation(TOperation op, Jsr181TypeMetadata wsm,
+      Map<String, Jsr181MethodMetadata> methodMap,
+      Map<String, TPart[]> messageMap, TTypes types) throws Exception {
+    String opName = op.getName();
+    TParam outputParam = op.getOutput();
+
+    Map<String, Jsr181ParameterMetadata> outParamMap = null;
+
+    Jsr181ParameterMetadata[] paraMeta = processParameters(outputParam, types,
+        messageMap, wsm);
+    Class returnType;
+    QName returnXMLType;
+
+    if (paraMeta == null) {
+      // Should not happen, may be need to send runtime exception, or
+      // define a new type of exception!
+      throw new Exception("Can't resolve the return type");
+    } else if (paraMeta.length == 1) {
+      returnType = paraMeta[0].getJavaType();
+      returnXMLType = paraMeta[0].getXmlType();
+    } else {
+      // either there is no return value or there are multiple so make
+      // this a
+      // void function and later set OUT parameters if needed.
+      returnType = Void.TYPE;
+      returnXMLType = null;
+      if (paraMeta.length > 1) {
+        outParamMap = new HashMap<String, Jsr181ParameterMetadata>(
+            paraMeta.length);
+        boolean returnIsSet = false;
+        for (Jsr181ParameterMetadata cpm : paraMeta) {
+          outParamMap.put(cpm.getWpName(), cpm);
+        }
+      }
+    }
+    Jsr181MethodMetadata wmm = new Jsr181MethodMetadataImpl(opName, returnType,
+        returnXMLType);
+
+    wmm.setWmOperationName(opName);
+    // FIXME jcolwell@bea.com 2004-Nov-10 --
+    // do something better with the action
+    wmm.setWmAction(opName);
+    if (Void.TYPE.equals(returnType)) {
+
+      if (paraMeta.length == 0) {
+        // FIXME jcolwell@bea.com 2004-Nov-22 --
+        // also check for faults before setting as oneway.
+        wmm.setOneWay(true);
+      }
+    } else {
+      wmm.setWrName(paraMeta[0].getWpName());
+      wmm.setWrTargetNamespace(paraMeta[0].getWpTargetNamespace());
+    }
+
+    methodMap.put(opName, wmm);
+
+    List paramOrder = op.getParameterOrder(); // this is the one used by
+    // rpc wsdls.
+    TParam inputParam = op.getInput();
+    if (inputParam != null) {
+
+      Jsr181ParameterMetadata[] params = processParameters(inputParam, types,
+          messageMap, wsm);
+
+      if (paramOrder != null) { // walk the parameters according to
+        // order
+        // if they exist.
+        // note that the Jsr181MethodMetadata
+        // needs correct order of the parameters
+        // (simnilar reflection of method).
+
+        // TODO: Paramorder is only used for rpc. This code should be
+        // modified so that in/out parameters are all handled in one
+        // place.
+        // if there is a paramoder then order the parameters, then all
+        // the parameters and look at in/out flag.
+        for (Object ord : paramOrder) {
+          for (Jsr181ParameterMetadata wpm : params) {
+            if (ord.equals(wpm.getWpName())) {
+
+              wpm.setWpMode(WebParam.Mode.IN); // THIUS MAY BE
+              // BUG... WE NEED
+              // TO MAKE SURE TO
+              // HANDLE THE OUT
+              // PARAMTERS ALSO
+              // (like the code
+              // for below)
+              wmm.addParam(wpm);
+              break;
+            }
+          }
+        }
+      } else if (params.length > 0) {
+        for (Jsr181ParameterMetadata wpm : params) {
+          // FIXME jcolwell@bea.com 2005-Jan-04 --
+          // Double check DOC/Lit rules
+          if (outParamMap != null && outParamMap.containsKey(wpm.getWpName())) {
+            outParamMap.remove(wpm.getWpName()); // important...
+            // if
+            // this param is
+            // in.out it was
+            // in the out list
+            // also, so remove
+            // it.
+            wpm.setWpMode(WebParam.Mode.INOUT);
+          } else {
+            wpm.setWpMode(WebParam.Mode.IN);
+          }
+          wmm.addParam(wpm);
+        }
+      }
+    }
+
+    // do the pure out parameters.
+    if (outParamMap != null && outParamMap.size() > 0) {
+      if (outParamMap.size() == 1) {
+        Jsr181ParameterMetadata wpm = outParamMap.values().iterator().next();
+        wmm.setXmlReturnType(wpm.getXmlType());
+        wmm.setReturnType(wpm.getJavaType());
+        wmm.setOneWay(false);
+      } else {
+        for (Jsr181ParameterMetadata wpm : outParamMap.values()) {
+          wpm.setWpMode(WebParam.Mode.OUT);
+          wmm.addParam(wpm);
         }
-
-        if (tBind != null) {
-            processTBindingOperation(tBind, wsm, methodMap);
-        }
-        return wsm;
+      }
     }
 
+    List<Jsr181ParameterMetadata> params = wmm.getParams();
     /*
-     * public static DefinitionsDocument fromWebServiceMetadata
-     * (WebServiceTYPEMetadata wsm) throws Exception { String ns =
-     * wsm.getWsTargetNamespace(); DefinitionsDocument defDoc =
-     * DefinitionsDocument.Factory.newInstance(); TDefinitions tDefs =
-     * defDoc.addNewDefinitions(); TPortType tPT = tDefs.addNewPortType();
-     * tPT.setName(wsm.getWsName()); TBinding tBind = tDefs.addNewBinding();
-     * tBind.setName(tPT.getName() + "Binding"); tBind.setType(new QName(ns,
-     * tPT.getName())); org.xmlsoap.schemas.wsdl.soap.BindingDocument bindDoc =
-     * org.xmlsoap.schemas.wsdl.soap.BindingDocument.Factory.newInstance();
-     * org.xmlsoap.schemas.wsdl.soap.TBinding tSoapBind = bindDoc
-     * .addNewBinding(); if
-     * (SOAPBinding.Style.DOCUMENT.equals(wsm.getSoapBinding().getStyle())) {
-     * tSoapBind.setStyle(TStyleChoice.DOCUMENT); } else {
-     * tSoapBind.setStyle(TStyleChoice.RPC); }
-     * tSoapBind.setTransport(TRANSPORT); insertChild(tBind, bindDoc);
-     * processMethodMetadata(wsm.getMethods(), tDefs, tPT, tBind, ns); TService
-     * tServ = tDefs.addNewService(); tServ.setName(wsm.getWsServiceName());
-     * TPort tPort = tServ.addNewPort(); tPort.setName(wsm.getWsName());
-     * tPort.setBinding(new QName(ns, tBind.getName()));
-     * org.xmlsoap.schemas.wsdl.soap.AddressDocument addrDoc =
-     * org.xmlsoap.schemas.wsdl.soap.AddressDocument.Factory.newInstance();
-     * org.xmlsoap.schemas.wsdl.soap.TAddress tAddr = addrDoc.addNewAddress();
-     * tAddr.setLocation("fake://FAKEURL"); insertChild(tPort, tAddr); return
-     * defDoc; }
-     */
-
-    private void processTOperation(TOperation op,
-                                   Jsr181TypeMetadata wsm,
-                                   Map<String,
-                                   Jsr181MethodMetadata> methodMap,
-                                   Map<String, TPart[]> messageMap,
-                                   TTypes types) throws Exception {
-        String opName = op.getName();
-        TParam outputParam = op.getOutput();
-
-        Map<String,Jsr181ParameterMetadata> outParamMap = null;
-
-        Jsr181ParameterMetadata[] paraMeta = 
-            processParameters(outputParam, types, messageMap, wsm);
-        Class returnType;
-        QName returnXMLType;
-        
-        if(paraMeta == null) {
-            // Should not happen, may be need to send runtime exception, or
-            // define a new type of exception!
-            throw new Exception("Can't resolve the return type");
-        } else if (paraMeta.length == 1 ) {
-            returnType = paraMeta[0].getJavaType();
-            returnXMLType = paraMeta[0].getXmlType();
-        } else {
-            // either there is no return value or there are multiple so make
-            // this a
-            // void function and later set OUT parameters if needed.
-            returnType=Void.TYPE;
-            returnXMLType = null;  
-            if (paraMeta.length > 1) {
-                outParamMap = new HashMap<String, Jsr181ParameterMetadata>(paraMeta.length);
-                boolean returnIsSet = false;
-                for (Jsr181ParameterMetadata cpm : paraMeta) {
-                		outParamMap.put(cpm.getWpName(), cpm);
-                }
-            }
-        }
-        Jsr181MethodMetadata wmm =
-            new Jsr181MethodMetadataImpl(opName,
-                                         returnType,
-                                         returnXMLType);
-        
-        wmm.setWmOperationName(opName);
-        // FIXME jcolwell@bea.com 2004-Nov-10 --
-        // do something better with the action
-        wmm.setWmAction(opName);
-        if (Void.TYPE.equals(returnType)) {
-
-            if (paraMeta.length == 0) {
-                // FIXME jcolwell@bea.com 2004-Nov-22 --
-                // also check for faults before setting as oneway.
-                wmm.setOneWay(true);
-            }
-        }
-        else {
-            wmm.setWrName(paraMeta[0].getWpName());
-            wmm.setWrTargetNamespace(paraMeta[0].getWpTargetNamespace());
-        }
-        
-        methodMap.put(opName, wmm);
-            
-        List paramOrder = op.getParameterOrder();  // this is the one used by
-                                                   // rpc wsdls.
-        TParam inputParam = op.getInput();
-        if (inputParam != null) {
-            
-            Jsr181ParameterMetadata[] params = 
-                processParameters(inputParam, types, messageMap, wsm);
-                
-            if (paramOrder != null) {  // walk the parameters according to order
-                                       // if they exist.
-            						   // note that the Jsr181MethodMetadata
-                                       // needs correct order of the parameters
-                                       // (simnilar reflection of method).
-            	
-            	// TODO: Paramorder is only used for rpc. This code should be
-                // modified so that in/out parameters are all handled in one
-                // place.
-            	// if there is a paramoder then order the parameters, then all
-                // the parameters and look at in/out flag.
-                for (Object ord : paramOrder) {  
-                    for (Jsr181ParameterMetadata wpm : params) {
-                        if (ord.equals(wpm.getWpName())) {
-                                
-                            wpm.setWpMode(WebParam.Mode.IN);  //THIUS MAY BE
-                                                              // BUG... WE NEED
-                                                              // TO MAKE SURE TO
-                                                              // HANDLE THE OUT
-                                                              // PARAMTERS ALSO
-                                                              // (like the code
-                                                              // for below)
-                            wmm.addParam(wpm);
-                            break;
-                        }
-                    }
-                }
-            }        
-            else if (params.length > 0) {
-                for (Jsr181ParameterMetadata wpm : params) {
-                    // FIXME jcolwell@bea.com 2005-Jan-04 --
-                    // Double check DOC/Lit rules
-                    if (outParamMap != null && outParamMap.containsKey(wpm.getWpName())) {
-                        outParamMap.remove(wpm.getWpName());  // important... if
-                                                              // this param is
-                                                              // in.out it was
-                                                              // in the out list
-                                                              // also, so remove
-                                                              // it.
-                        wpm.setWpMode(WebParam.Mode.INOUT);
-                    }
-                    else {
-                        wpm.setWpMode(WebParam.Mode.IN);
-                    }
-                    wmm.addParam(wpm);
-                }
-            }
-        }
-
-        // do the pure out parameters.
-        if (outParamMap != null && outParamMap.size() > 0) {
-        	if( outParamMap.size() == 1)  {
-        		Jsr181ParameterMetadata wpm = outParamMap.values().iterator().next();
-        		wmm.setXmlReturnType(wpm.getXmlType());
-        		wmm.setReturnType(wpm.getJavaType());
-        		wmm.setOneWay(false);        		 
-        	} else {
-	            for (Jsr181ParameterMetadata wpm : outParamMap.values()) {
-	                wpm.setWpMode(WebParam.Mode.OUT);
-	                wmm.addParam(wpm);
-	            }
-        	}
-        }
-            
-        List<Jsr181ParameterMetadata> params = wmm.getParams();
-        /*
-         * System.out.println("adding method " + wmm.getWmOperationName() + "
-         * returning " + wmm.getJavaReturnType() + " with the following " +
-         * params.size() + " parameters");
-         * 
-         * for (Jsr181ParameterMetadata wpm : params) {
-         * System.out.println(wpm.getWpName() + ':' + wpm.getJavaType()); }
-         */   
-        wsm.addMethod(wmm);
-        
-    }
-
-    private Jsr181ParameterMetadata[] 
-        processParameters(TParam parameter,
-                          TTypes types,
-                          Map<String, TPart[]> messageMap,
-                          Jsr181TypeMetadata wsm) {
-        
-        if (parameter != null) {
-            TPart[] messageParts = messageMap
-                .get(parameter.getMessage().getLocalPart());
-
-            List<Jsr181ParameterMetadata> paramList = 
-                new ArrayList<Jsr181ParameterMetadata>(messageParts.length);
-            int j = 0;
-            for (TPart messagePart : messageParts) {
-
-            
-                QName paramXmlType;                
-                if (messagePart.isSetElement()) { // if element attribute is set
-                                                  // we are looking at document
-                                                  // style
-                	                              // in case of rpc message part
-                                                  // would look something like:
-                                                  // <part name="key"
-                                                  // type="xsd:string"/>
-                	                              // otherwise it case of
-                                                  // document it looks liek
-                                                  // <part element="xxxx"
-                                                  // name="parameters">
-                	// we know we are document, and thus literal. and most
-                    // likely using xml beans, but can use axis too.
-                    QName element = messagePart.getElement();
-                    Class javaType = getTypeMappingUtil().q2Class(element); 
-                    // in case of xmlbeans(or other registered types) we don't need
-                    // to dig any further
-                    String name = messagePart.getName();
-                    if (0 == "parameters".compareTo(name)) {  
-                        // if q2class fails,it reutrns an object.
-                    	// we know document, literal, there are no reguistered
-                        // types for the messasge.
-                    	// system needs to wrap/unwrap the messages. Thus the
-                        // method metadata must reflect this.
-                    	// Also if name="parameters" we need to unwarp the message/
-                        
-
-                    	
-                        if (types != null) {  // if there are some type
-                            try {
-                                Schema[] schemas = selectChildren(types,
-                                                                  Schema.class); 
-                                // We are  looking at schemas that are defined in
-                               // this schema.
-                               //----  // THIS WOULD NOT RECOGNIZE IMPORTED SCHEMAS.
-
-                                for (Schema s : schemas) {
-                                    if (s.getTargetNamespace()
-                                        .equals(element.getNamespaceURI())) {  // if
-                                                                               // namespace
-                                                                               // matched
-                                                                               // the
-                                                                               // element.
-                                        Element[] elements = s.getElementArray();
-                                        for (Element e : elements) {
-                                            if (e.getName()
-                                                .equals(element.getLocalPart())) {
-                                         
-                                                if (e.isSetType()) {  // simple
-                                                                      // type,
-                                                                      // element
-                                                                      // has
-                                                                      // name
-                                                                      // and
-                                                                      // type in
-                                                                      // same
-                                                                      // node
-                                                                      // for
-                                                                      // complex
-                                                                      // type it
-                                                                      // is only
-                                                                      // name
-                                                                      // and
-                                                                      // type is
-                                                                      // defined
-                                                                      // as
-                                                                      // <complexType>
-                                                                      // child./
-                                                    Jsr181ParameterMetadata wpm =
-                                                        new Jsr181ParameterMetadataImpl();
-                                         
-                                                    wpm.setWpName(e.getName());
-                                                    // FIXME jcolwell@bea.com
-                                                    // 2004-Nov-09 -- double
-                                                    // check the namespace stuff
-                                                    wpm.setWpTargetNamespace
-                                                        (s.getTargetNamespace());
-                                                    QName type = e.getType();
-                                                    wpm.setXmlType(type);
-                                                    wpm.setJavaType(getTypeMappingUtil()
-                                                                    .q2Class(type));
-
-                                                    /*
-                                                     * System.out.println(wpm.getWpName() + " of
-                                                     * type " + wpm.getJavaType());
-                                                     */
-                                                    paramList.add(wpm);
-                                                }
-                                                else {
-                                                    // we have <element
-                                                    // name=xxx> and its child
-                                                    // must be comlexType, or
-                                                    // somethig is wrong
-
-                                                    ComplexType ct = e.getComplexType();
-                                                    if (ct != null
-                                                        && ct.isSetSequence()) {
-                                                        // DOC/LIT WSDL
-                                                        Group g = ct.getSequence();  // NOTE
-                                                                                     // there
-                                                                                     // may
-                                                                                     // other
-                                                                                     // groupings
-                                                                                     // also
-                                                                                     // here
-                                                                                     // (e.g.
-                                                                                     // for
-                                                                                     // arrays)
-                                                                                     // that
-                                                                                     // we
-                                                                                     // are
-                                                                                     // not
-                                                                                     // handling
-                                                                                     // correctly.
-                                                        // its child is
-                                                           // either <element
-                                                           // name="xxxx"
-                                                           // type="xxx" /> or
-                                                        //<element ref="xxx />
-
-                                                        for (Element el : g.getElementArray()) {
-
-                                                            Jsr181ParameterMetadata wpm =
-                                                                new Jsr181ParameterMetadataImpl();
-
-                                                            // FIXME
-                                                            // jcolwell@bea.com
-                                                            // 2004-Nov-09
-                                                            // double check the
-                                                            // namespace stuff
-                                                            wpm.setWpTargetNamespace
-                                                                (s.getTargetNamespace());
-
-                                                            if (el.isSetName()
-                                                                && el.isSetType()) {
-
-                                                                wpm.setWpName(el.getName());
-                                                            
-                                                                QName type = el.getType();
-                                                                wpm.setXmlType(type);
-                                                                wpm.setJavaType(getTypeMappingUtil().q2Class(type));
-                                                                /*
-                                                                 * System.out.println(wpm
-                                                                 * .getWpName() + " of type " +
-                                                                 * wpm.getJavaType());
-                                                                 */
-                                                                paramList.add(wpm);
-                                                            }
-                                                            else if (el.isSetRef()) {
-                                                                QName ref = el.getRef();
-                                                                /*
-                                                                 * System.out.println ("ref is set
-                                                                 * to: " + ref);
-                                                                 */
-                                                                wpm.setWpName(ref.getLocalPart());
-                                                                wpm.setXmlType(ref);
-                                                                Class cl = getTypeMappingUtil()
-                                                                    .q2Class(ref);
-                                                                /*
-                                                                 * System.out.println ("resulting
-                                                                 * java type: " + cl.getName());
-                                                                 */
-                                                                wpm.setJavaType(cl);
-
-                                                                paramList.add(wpm);
-                                                            }
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            }
-                                        }
-                                        break;
-                                    }
-                                }
-                            }
-                            catch (Exception e) {
-                                e.printStackTrace();
-                            }                      }
-                    }
-                    else {  
-                        // if we did find object form qname. also we know
-                            // that there are xml-aware classes that can decode
-                            // the xml we let them do the
-                    	// processing.
-
-                        // NOTE jcolwell@bea.com 2005-Jan-07 -- Doc/Lit Bare
-                        wsm.getSoapBinding().setParameterStyle(SOAPBinding.ParameterStyle.BARE);
-
-                        Jsr181ParameterMetadata wpm =
-                            new Jsr181ParameterMetadataImpl();
-                    
-                        wpm.setWpTargetNamespace(element.getNamespaceURI());
-                        wpm.setWpName(element.getLocalPart());
-                        wpm.setXmlType(element);
-                        wpm.setJavaType(javaType);
-                        paramList.add(wpm);
-                    }
-                }
-                else {  // this is an rpc and with no element attribute
-                    Jsr181ParameterMetadata wpm =
-                        new Jsr181ParameterMetadataImpl();
-                    // FIXME jcolwell@bea.com 2004-Nov-09 -- figure out where
-                    // RPC parameter namespaces should be specified in the WSDL.
-                    wpm.setWpTargetNamespace(wsm.getWsTargetNamespace());
-                    wpm.setWpName(messagePart.getName());
-                    QName type = messagePart.getType();
-                    wpm.setXmlType(type);
-                    wpm.setJavaType(getTypeMappingUtil().q2Class(type));
-                    /*
-                     * System.out.println(wpm.getWpName() + " of type " +
-                     * wpm.getJavaType());
-                     */
-                    paramList.add(wpm);
-                }
-            }
-            return paramList
-                .toArray(new Jsr181ParameterMetadata[paramList.size()]);
-        }
-        return new Jsr181ParameterMetadata[0];
-    }
-
-    /**
-     * @param types
+     * System.out.println("adding method " + wmm.getWmOperationName() + "
+     * returning " + wmm.getJavaReturnType() + " with the following " +
+     * params.size() + " parameters");
+     * 
+     * for (Jsr181ParameterMetadata wpm : params) {
+     * System.out.println(wpm.getWpName() + ':' + wpm.getJavaType()); }
      */
-    private void doUnknownTypes(TTypes types) {
-        // sections.
+    wsm.addMethod(wmm);
 
-    }
+  }
 
-    private void processTBinding(TBinding tBind,
-                                 Jsr181TypeMetadata wsm)
-        throws IllegalAccessException, NoSuchFieldException {
-        
-        org.xmlsoap.schemas.wsdl.soap.TBinding[] soapBinding =
-            getSOAPBinding(tBind);
-        SOAPBindingInfo soapInfo = new SOAPBindingInfo();
-        if (soapBinding != null && soapBinding.length > 0) {
-            if (TStyleChoice.RPC.equals(soapBinding[0].getStyle())) {
-                soapInfo.setStyle(SOAPBinding.Style.RPC);
-            }
-            wsm.setSoapBinding(soapInfo);
-        }
-    }
+  private Jsr181ParameterMetadata[] processParameters(TParam parameter,
+      TTypes types, Map<String, TPart[]> messageMap, Jsr181TypeMetadata wsm) {
 
-    private void processTBindingOperation(TBinding tBind,
-                                          Jsr181TypeMetadata wsm,
-                                          Map<String,
-                                          Jsr181MethodMetadata> methodMap)
-        throws IllegalAccessException, NoSuchFieldException {
-
-        TBindingOperation[] tBops = tBind.getOperationArray();
-        for (TBindingOperation tBop : tBops) {
-            Jsr181MethodMetadata wmm = methodMap.get(tBop.getName());
-            if (wmm != null) {
-                org.xmlsoap.schemas.wsdl.soap.TOperation[] soapOperations =
-                    getSOAPOperations(tBop);
-                if (soapOperations!= null && soapOperations.length > 0) {
-                    wmm.setWmAction(soapOperations[0].getSoapAction());
-                }
-                TBindingOperationMessage tbMsg = tBop.getInput();
-                if (tbMsg == null) {
-                    tbMsg = tBop.getOutput();
-                }
-                if (tbMsg != null) {
-                    org.xmlsoap.schemas.wsdl.soap.TBody[] bodies =
-                        getSOAPBody(tbMsg);
-                    if (bodies.length > 0) {
-                        if (wsm.getWsTargetNamespace() == null) {
-                            wsm.setWsTargetNamespace(bodies[0]
-                                                     .getNamespace());
-                        }
-                        SOAPBindingInfo soapInfo = wsm.getSoapBinding();
-                        if (UseChoice.ENCODED.equals(bodies[0].getUse())) {
-                            soapInfo.setUse(SOAPBinding.Use.ENCODED);
+    if (parameter != null) {
+      TPart[] messageParts = messageMap.get(parameter.getMessage()
+          .getLocalPart());
+
+      List<Jsr181ParameterMetadata> paramList = new ArrayList<Jsr181ParameterMetadata>(
+          messageParts.length);
+      int j = 0;
+      for (TPart messagePart : messageParts) {
+        QName paramXmlType;
+        // if element attribute is set we are looking at document style
+        // in case of rpc message part would look something like:
+        // <part name="key type="xsd:string"/>
+        // otherwise it case of document it looks liek
+        // <part element="xxxx" name="parameters">
+        if (messagePart.isSetElement()) {
+          // we know we are document, and thus literal. and most
+          // likely using xml beans, but can use axis too.
+          QName element = messagePart.getElement();
+          Class javaType = getTypeMappingUtil().q2Class(element);
+          // in case of xmlbeans(or other registered types) we don't
+          // need
+          // to dig any further
+          String name = messagePart.getName();
+          // if name is "parameters" then we need to unwrap the type
+          // and the service is doc/literal wrapped./
+          if (0 == "parameters".compareTo(name)) {
+            if (types != null) { // if there are some type
+              try {
+                Schema[] schemas = selectChildren(types, Schema.class);
+                // We are looking at schemas that are defined in
+                // this schema.
+                // ---- // THIS WOULD NOT RECOGNIZE IMPORTED
+                // SCHEMAS.
+
+                for (Schema s : schemas) {
+                  if (!s.getTargetNamespace().equals(element.getNamespaceURI()))
+                    continue;
+                  Element[] elements = s.getElementArray();
+                  for (Element e : elements) {
+                    if (!e.getName().equals(element.getLocalPart()))
+                      continue;
+
+                    if (e.isSetType()) {
+                      /*
+                       * simple type, element has name and type in same node.
+                       * complextype   only  has name and type is defined as
+                       * <complexType> child
+                       */
+                      paramList.add(elementToParamMetaData(s
+                          .getTargetNamespace(), e));
+                    } else {
+                      // we have <element
+                      // name=xxx> and its child
+                      // must be comlexType, or
+                      // somethig is wrong
+
+                      ComplexType ct = e.getComplexType();
+                      if (ct != null && ct.isSetSequence()) {
+                        // DOC/LIT WSDL
+                        /* NOTE: There may be other groupings that this code needs
+                         * to understand also.  At this point we expect:
+                         * <element name="xxx" type="yyy">
+                         * or <element ref="zzz">
+                         */
+                        Group g = ct.getSequence(); 
+                        for (Element el : g.getElementArray()) {
+                          paramList.add(elementToParamMetaData(s
+                              .getTargetNamespace(), el));
                         }
+                      }
                     }
+                    break;
+                  }
+                  break;
                 }
-            }
-        }
+              } catch (Exception e) {
+                e.printStackTrace();
+              }
+            }
+          } else {
+            // if we did find object form qname we know
+            // that there are xml-aware classes that can decode
+            // the xml we let them do the
+            // processing.
+
+           wsm.getSoapBinding().setParameterStyle(
+                SOAPBinding.ParameterStyle.BARE);
+
+            Jsr181ParameterMetadata wpm = new Jsr181ParameterMetadataImpl();
+
+            wpm.setWpTargetNamespace(element.getNamespaceURI());
+            wpm.setWpName(element.getLocalPart());
+            wpm.setXmlType(element);
+            wpm.setJavaType(javaType);
+            paramList.add(wpm);
+          }
+        } else { // this is an rpc and with no element attribute
+          Jsr181ParameterMetadata wpm = new Jsr181ParameterMetadataImpl();
+          // FIXME jcolwell@bea.com 2004-Nov-09 -- figure out where
+          // RPC parameter namespaces should be specified in the WSDL.
+          wpm.setWpTargetNamespace(wsm.getWsTargetNamespace());
+          wpm.setWpName(messagePart.getName());
+          QName type = messagePart.getType();
+          wpm.setXmlType(type);
+          wpm.setJavaType(getTypeMappingUtil().q2Class(type));
+          /*
+           * System.out.println(wpm.getWpName() + " of type " +
+           * wpm.getJavaType());
+           */
+          paramList.add(wpm);
+        }
+      }
+      return paramList.toArray(new Jsr181ParameterMetadata[paramList.size()]);
+    }
+    return new Jsr181ParameterMetadata[0];
+  }
+
+  /**
+   * @param paramList
+   * @param s
+   * @param el
+   */
+  private Jsr181ParameterMetadata elementToParamMetaData(
+      String targetNamespace, Element el) {
+    Jsr181ParameterMetadata wpm = new Jsr181ParameterMetadataImpl();
+    // FIXME
+    // jcolwell@bea.com
+    // 2004-Nov-09
+    // double check the
+    // namespace stuff
+    wpm.setWpTargetNamespace(targetNamespace);
+    boolean isArray = false;
+    if (el.isSetMaxOccurs()) {
+      if (0 != "1".compareTo(el.getMaxOccurs().toString()))
+        isArray = true;
+    } else if (el.isSetMinOccurs()) {
+      String minOccur = el.getMinOccurs().toString();
+      // If minoccur is other than 0, or 1 then it is array also
+      if ("0" != minOccur && "1" != minOccur)
+        isArray = true;
+    }
+
+    String name = null;
+    QName xmlType = null;
+    if (el.isSetName() && el.isSetType()) {
+
+      name = el.getName();
+
+      xmlType = el.getType();
+
+    } else if (el.isSetRef()) {
+      QName ref = el.getRef();
+      name = ref.getLocalPart();
+      xmlType = ref;
+
+    } else
+      throw new RuntimeException("invalid element: " + el);
+    Class javaType = getTypeMappingUtil().q2Class(xmlType);
+    if (isArray) {
+      // create an array of the type, then get its type.
+      Object realType = Array.newInstance(javaType, 1);
+      javaType = realType.getClass();
+    }
+    wpm.setWpName(name);
+    wpm.setXmlType(xmlType);
+    wpm.setJavaType(javaType);
+    return wpm;
+  }
+
+  /**
+   * @param types
+   */
+  private void doUnknownTypes(TTypes types) {
+    // sections.
+
+  }
+
+  private void processTBinding(TBinding tBind, Jsr181TypeMetadata wsm)
+      throws IllegalAccessException, NoSuchFieldException {
+
+    org.xmlsoap.schemas.wsdl.soap.TBinding[] soapBinding = getSOAPBinding(tBind);
+    SOAPBindingInfo soapInfo = new SOAPBindingInfo();
+    if (soapBinding != null && soapBinding.length > 0) {
+      if (TStyleChoice.RPC.equals(soapBinding[0].getStyle())) {
+        soapInfo.setStyle(SOAPBinding.Style.RPC);
+      }
+      wsm.setSoapBinding(soapInfo);
+    }
+  }
+
+  private void processTBindingOperation(TBinding tBind, Jsr181TypeMetadata wsm,
+      Map<String, Jsr181MethodMetadata> methodMap)
+      throws IllegalAccessException, NoSuchFieldException {
+
+    TBindingOperation[] tBops = tBind.getOperationArray();
+    for (TBindingOperation tBop : tBops) {
+      Jsr181MethodMetadata wmm = methodMap.get(tBop.getName());
+      if (wmm != null) {
+        org.xmlsoap.schemas.wsdl.soap.TOperation[] soapOperations = getSOAPOperations(tBop);
+        if (soapOperations != null && soapOperations.length > 0) {
+          wmm.setWmAction(soapOperations[0].getSoapAction());
+        }
+        TBindingOperationMessage tbMsg = tBop.getInput();
+        if (tbMsg == null) {
+          tbMsg = tBop.getOutput();
+        }
+        if (tbMsg != null) {
+          org.xmlsoap.schemas.wsdl.soap.TBody[] bodies = getSOAPBody(tbMsg);
+          if (bodies.length > 0) {
+            if (wsm.getWsTargetNamespace() == null) {
+              wsm.setWsTargetNamespace(bodies[0].getNamespace());
+            }
+            SOAPBindingInfo soapInfo = wsm.getSoapBinding();
+            if (UseChoice.ENCODED.equals(bodies[0].getUse())) {
+              soapInfo.setUse(SOAPBinding.Use.ENCODED);
+            }
+          }
+        }
+      }
+    }
+  }
+
+  /*
+   * private static void processMethodMetadata (Collection
+   * <WebServiceMETHODMetadata> methods, TDefinitions defs, TPortType portType,
+   * TBinding bind, String namespace) { for (WebServiceMETHODMetadata op :
+   * methods) { String operationName = op.getWmOperationName(); String request =
+   * operationName + "Request"; String response = operationName + "Response";
+   * TMessage tMsg = defs.addNewMessage(); tMsg.setName(request); List <String>
+   * paramOrder = new ArrayList <String>();
+   * processParameterMetadata(op.getParams(), paramOrder, tMsg); if
+   * (!op.isOneWay()) { tMsg = defs.addNewMessage(); tMsg.setName(response);
+   * TPart tPart = tMsg.addNewPart(); tPart.setName(op.getWrName());
+   * tPart.setType(class2QName(op.getJavaReturnType())); //tPart.setElement(new
+   * QName("some", "element"); } TOperation tOp = portType.addNewOperation();
+   * tOp.setName(operationName); tOp.setParameterOrder(paramOrder); TParam input =
+   * tOp.addNewInput(); TParam output = tOp.addNewOutput();
+   * input.setName(request); input.setMessage(new QName(namespace, request)); if
+   * (!op.isOneWay()) { output.setName(response); output.setMessage(new
+   * QName(namespace, response)); }
+   * processBindingOperationMetadata(bind.addNewOperation(), op, namespace,
+   * operationName, request, response); } }
+   * 
+   * private static void processParameterMetadata (Collection
+   * <WebServicePARAMETERMetadata> params, List <String> paramOrder, TMessage
+   * msg) { for (WebServicePARAMETERMetadata param : params) { TPart tPart =
+   * msg.addNewPart(); tPart.setName(param.getWpName());
+   * tPart.setType(class2QName(param.getJavaType()));
+   * paramOrder.add(param.getWpName()); } }
+   * 
+   * private static void processBindingOperationMetadata(TBindingOperation tBop,
+   * WebServiceMETHODMetadata op, String namespace, String operationName, String
+   * request, String response) { tBop.setName(operationName);
+   * org.xmlsoap.schemas.wsdl.soap.OperationDocument opDoc =
+   * org.xmlsoap.schemas.wsdl.soap.OperationDocument.Factory .newInstance();
+   * org.xmlsoap.schemas.wsdl.soap.TOperation tSoapOperation =
+   * opDoc.addNewOperation(); tSoapOperation.setSoapAction(op.getWmAction()); //
+   * SOAPBindingInfo sb = op.getSoapBinding(); // if (sb != null &&
+   * SOAPBinding.Style.DOCUMENT.equals(sb.getStyle())) { //
+   * tSoapOperation.setStyle(TStyleChoice.DOCUMENT); // } // else { //
+   * tSoapOperation.setStyle(TStyleChoice.RPC); // } insertChild(tBop, opDoc);
+   * TBindingOperationMessage inBom = tBop.addNewInput();
+   * TBindingOperationMessage outBom = tBop.addNewOutput();
+   * inBom.setName(request); outBom.setName(response);
+   */
+  /*
+   * NOTE jcolwell@bea.com 2004-Aug-31 -- Using the same body for both the input
+   * and output, this may need to be changed.
+   */
+  /*
+   * org.xmlsoap.schemas.wsdl.soap.BodyDocument bodDoc =
+   * org.xmlsoap.schemas.wsdl.soap.BodyDocument.Factory.newInstance();
+   * org.xmlsoap.schemas.wsdl.soap.TBody tBod = bodDoc.addNewBody(); // if (sb !=
+   * null && SOAPBinding.Use.LITERAL.equals(sb.getUse())) { //
+   * tBod.setUse(UseChoice.LITERAL); // } // else { //
+   * tBod.setUse(UseChoice.ENCODED); // }
+   */
+  /*
+   * NOTE jcolwell@bea.com 2004-Aug-31 -- not sure what parts get set here.
+   */
+  // tBod.setParts(?);
+  /*
+   * tBod.setNamespace(namespace); List <String> encodingStyles = new ArrayList
+   * <String>(); encodingStyles.add(SOAPENCODING);
+   * tBod.setEncodingStyle(encodingStyles); insertChild(inBom, bodDoc);
+   * insertChild(outBom, bodDoc); }
+   * 
+   * 
+   * public static boolean insertChild(XmlObject parent, XmlObject child) { //
+   * might need to use copyXmlContents() instead if copyXml copies too much
+   * XmlCursor kidCursor = child.newCursor(); XmlCursor parentCursor =
+   * parent.newCursor(); parentCursor.toFirstContentToken();
+   * //parentCursor.toNextToken(); kidCursor.toNextToken(); return
+   * kidCursor.copyXml(parentCursor); }
+   */
+
+  public Jsr181TypeMetadata loadWebServiceMetadataFromWSDL(String wsdlLocation)
+      throws Exception {
+    return toWebServiceMetadata(parseWSDL(wsdlLocation));
+  }
+
+  public static DefinitionsDocument parseWSDL(String wsdlLocation)
+      throws IOException, MalformedURLException, XmlException {
+    if (wsdlLocation.indexOf("://") > 2) {
+      return parseWSDL(new URL(wsdlLocation));
+    } else {
+      return parseWSDL(new File(wsdlLocation));
+    }
+  }
+
+  public static DefinitionsDocument parseWSDL(File wsdlFile)
+      throws IOException, XmlException {
+    return DefinitionsDocument.Factory.parse(wsdlFile);
+  }
+
+  public static DefinitionsDocument parseWSDL(URL wsdlURL) throws IOException,
+      MalformedURLException, XmlException {
+    return DefinitionsDocument.Factory.parse(wsdlURL);
+  }
+
+  public static DefinitionsDocument parseWSDL(InputStream wsdlStream)
+      throws IOException, MalformedURLException, XmlException {
+    return DefinitionsDocument.Factory.parse(wsdlStream);
+  }
+
+  public static org.xmlsoap.schemas.wsdl.soap.TOperation[] getSOAPOperations(
+      TBindingOperation bo) throws IllegalAccessException, NoSuchFieldException {
+    return selectChildren(bo, org.xmlsoap.schemas.wsdl.soap.TOperation.class);
+  }
+
+  public static org.xmlsoap.schemas.wsdl.soap.TBinding[] getSOAPBinding(
+      TBinding b) throws IllegalAccessException, NoSuchFieldException {
+    XmlObject[] kids = b.selectChildren(new QName(
+        "http://schemas.xmlsoap.org/wsdl/soap/", "binding"));
+
+    org.xmlsoap.schemas.wsdl.soap.TBinding[] res = new org.xmlsoap.schemas.wsdl.soap.TBinding[kids.length];
+    for (int i = 0; i < kids.length; i++)
+      res[i] = (org.xmlsoap.schemas.wsdl.soap.TBinding) kids[i];
+
+    return res;
+  }
+
+  public static org.xmlsoap.schemas.wsdl.soap.TBody[] getSOAPBody(
+      TBindingOperationMessage bom) throws IllegalAccessException,
+      NoSuchFieldException {
+    return selectChildren(bom, org.xmlsoap.schemas.wsdl.soap.TBody.class);
+  }
+
+  public static org.xmlsoap.schemas.wsdl.soap.TAddress[] getSOAPAddress(
+      TPort port) throws IllegalAccessException, NoSuchFieldException {
+    return selectChildren(port, org.xmlsoap.schemas.wsdl.soap.TAddress.class);
+  }
+
+  private static <T extends XmlObject> T[] selectChildren(XmlObject parent,
+      Class<T> childClass) throws IllegalAccessException, NoSuchFieldException {
+    // retrieve the SchemaType from the static type field
+    SchemaType st = (SchemaType) childClass.getField("type").get(null);
+    SchemaType originalType = null;
+    QName element;
+    if (st.isAnonymousType()) {
+      originalType = st;
+      st = st.getOuterType();
+    }
+    if (st.isDocumentType()) {
+      element = st.getDocumentElementName();
+      if (originalType != null) {
+        st = originalType;
+      }
+    } else {
+      element = st.getName();
     }
-
-    /*
-     * private static void processMethodMetadata (Collection
-     * <WebServiceMETHODMetadata> methods, TDefinitions defs, TPortType
-     * portType, TBinding bind, String namespace) { for
-     * (WebServiceMETHODMetadata op : methods) { String operationName =
-     * op.getWmOperationName(); String request = operationName + "Request";
-     * String response = operationName + "Response"; TMessage tMsg =
-     * defs.addNewMessage(); tMsg.setName(request); List <String> paramOrder =
-     * new ArrayList <String>(); processParameterMetadata(op.getParams(),
-     * paramOrder, tMsg); if (!op.isOneWay()) { tMsg = defs.addNewMessage();
-     * tMsg.setName(response); TPart tPart = tMsg.addNewPart();
-     * tPart.setName(op.getWrName());
-     * tPart.setType(class2QName(op.getJavaReturnType()));
-     * //tPart.setElement(new QName("some", "element"); } TOperation tOp =
-     * portType.addNewOperation(); tOp.setName(operationName);
-     * tOp.setParameterOrder(paramOrder); TParam input = tOp.addNewInput();
-     * TParam output = tOp.addNewOutput(); input.setName(request);
-     * input.setMessage(new QName(namespace, request)); if (!op.isOneWay()) {
-     * output.setName(response); output.setMessage(new QName(namespace,
-     * response)); } processBindingOperationMetadata(bind.addNewOperation(), op,
-     * namespace, operationName, request, response); } }
-     * 
-     * private static void processParameterMetadata (Collection
-     * <WebServicePARAMETERMetadata> params, List <String> paramOrder, TMessage
-     * msg) { for (WebServicePARAMETERMetadata param : params) { TPart tPart =
-     * msg.addNewPart(); tPart.setName(param.getWpName());
-     * tPart.setType(class2QName(param.getJavaType()));
-     * paramOrder.add(param.getWpName()); } }
-     * 
-     * private static void processBindingOperationMetadata(TBindingOperation
-     * tBop, WebServiceMETHODMetadata op, String namespace, String
-     * operationName, String request, String response) {
-     * tBop.setName(operationName);
-     * org.xmlsoap.schemas.wsdl.soap.OperationDocument opDoc =
-     * org.xmlsoap.schemas.wsdl.soap.OperationDocument.Factory .newInstance();
-     * org.xmlsoap.schemas.wsdl.soap.TOperation tSoapOperation =
-     * opDoc.addNewOperation(); tSoapOperation.setSoapAction(op.getWmAction()); //
-     * SOAPBindingInfo sb = op.getSoapBinding(); // if (sb != null &&
-     * SOAPBinding.Style.DOCUMENT.equals(sb.getStyle())) { //
-     * tSoapOperation.setStyle(TStyleChoice.DOCUMENT); // } // else { //
-     * tSoapOperation.setStyle(TStyleChoice.RPC); // } insertChild(tBop, opDoc);
-     * TBindingOperationMessage inBom = tBop.addNewInput();
-     * TBindingOperationMessage outBom = tBop.addNewOutput();
-     * inBom.setName(request); outBom.setName(response);
-     */
-        /*
-         * NOTE jcolwell@bea.com 2004-Aug-31 -- Using the same body for both the
-         * input and output, this may need to be changed.
-         */
     /*
-     * org.xmlsoap.schemas.wsdl.soap.BodyDocument bodDoc =
-     * org.xmlsoap.schemas.wsdl.soap.BodyDocument.Factory.newInstance();
-     * org.xmlsoap.schemas.wsdl.soap.TBody tBod = bodDoc.addNewBody(); // if (sb !=
-     * null && SOAPBinding.Use.LITERAL.equals(sb.getUse())) { //
-     * tBod.setUse(UseChoice.LITERAL); // } // else { //
-     * tBod.setUse(UseChoice.ENCODED); // }
+     * System.out.println("Selecting children " + element +" of class " +
+     * st.getJavaClass());
      */
-        /*
-         * NOTE jcolwell@bea.com 2004-Aug-31 -- not sure what parts get set
-         * here.
-         */
-        // tBod.setParts(?);
-    /*
-     * tBod.setNamespace(namespace); List <String> encodingStyles = new
-     * ArrayList <String>(); encodingStyles.add(SOAPENCODING);
-     * tBod.setEncodingStyle(encodingStyles); insertChild(inBom, bodDoc);
-     * insertChild(outBom, bodDoc); }
-     * 
-     * 
-     * public static boolean insertChild(XmlObject parent, XmlObject child) { //
-     * might need to use copyXmlContents() instead if copyXml copies too much
-     * XmlCursor kidCursor = child.newCursor(); XmlCursor parentCursor =
-     * parent.newCursor(); parentCursor.toFirstContentToken();
-     * //parentCursor.toNextToken(); kidCursor.toNextToken(); return
-     * kidCursor.copyXml(parentCursor); }
-     */
-
-    public Jsr181TypeMetadata loadWebServiceMetadataFromWSDL
-            (String wsdlLocation)
-            throws Exception {
-        return toWebServiceMetadata(parseWSDL(wsdlLocation));
-    }
-    
-    public static DefinitionsDocument parseWSDL(String wsdlLocation)
-            throws IOException, MalformedURLException, XmlException {
-        if (wsdlLocation.indexOf("://") > 2) {
-            return parseWSDL(new URL(wsdlLocation));
-        } else {
-            return parseWSDL(new File(wsdlLocation));
-        }
-    }
-
-    public static DefinitionsDocument parseWSDL(File wsdlFile)
-            throws IOException, XmlException {
-        return DefinitionsDocument.Factory.parse(wsdlFile);
-    }
-
-    public static DefinitionsDocument parseWSDL(URL wsdlURL)
-            throws IOException, MalformedURLException, XmlException {
-        return DefinitionsDocument.Factory.parse(wsdlURL);
-    }
-    
-    public static DefinitionsDocument parseWSDL(InputStream wsdlStream)
-            throws IOException, MalformedURLException, XmlException {
-        return DefinitionsDocument.Factory.parse(wsdlStream);
-    }
-
-    public static org.xmlsoap.schemas.wsdl.soap.TOperation[]
-            getSOAPOperations(TBindingOperation bo)
-            throws IllegalAccessException, NoSuchFieldException {
-        return selectChildren(bo, org.xmlsoap.schemas.wsdl.soap.TOperation.class);
-    }
-
-    public static org.xmlsoap.schemas.wsdl.soap.TBinding[]
-            getSOAPBinding(TBinding b)
-            throws IllegalAccessException, NoSuchFieldException {
-    	XmlObject[] kids =  b.selectChildren(new QName("http://schemas.xmlsoap.org/wsdl/soap/", "binding"));
-
-  		org.xmlsoap.schemas.wsdl.soap.TBinding[] res = new org.xmlsoap.schemas.wsdl.soap.TBinding[kids.length];
-  		for(int i=0; i<kids.length; i++) res[i]=(org.xmlsoap.schemas.wsdl.soap.TBinding) kids[i];
-  	
-    	 return res;
-    }
+    XmlObject[] kids = parent.selectChildren(element);
 
-    public static org.xmlsoap.schemas.wsdl.soap.TBody[]
-            getSOAPBody(TBindingOperationMessage bom)
-            throws IllegalAccessException, NoSuchFieldException {
-        return selectChildren(bom, org.xmlsoap.schemas.wsdl.soap.TBody.class);
-    }
+    T[] castKids = (T[]) Array.newInstance(childClass, kids.length);
+    for (int j = 0; j < castKids.length; j++) {
 
-    public static org.xmlsoap.schemas.wsdl.soap.TAddress[]
-            getSOAPAddress(TPort port)
-            throws IllegalAccessException, NoSuchFieldException {
-        return selectChildren(port, org.xmlsoap.schemas.wsdl.soap.TAddress.class);
-    }
-
-    private static <T extends XmlObject> T[] selectChildren(XmlObject parent,
-                                                            Class<T> childClass)
-            throws IllegalAccessException, NoSuchFieldException {
-        // retrieve the SchemaType from the static type field
-        SchemaType st = (SchemaType) childClass.getField("type").get(null);
-        SchemaType originalType = null;
-        QName element;
-        if (st.isAnonymousType()) {
-            originalType = st;
-            st = st.getOuterType();
-        }
-        if (st.isDocumentType()) {
-            element = st.getDocumentElementName();
-            if (originalType != null) {
-                st = originalType;
-            }
-        }
-        else {
-            element = st.getName();
-        }
-        /*
-         * System.out.println("Selecting children " + element +" of class " +
-         * st.getJavaClass());
-         */
-        XmlObject[] kids = parent.selectChildren(element);
-      
-        T[] castKids = (T[]) Array.newInstance(childClass, kids.length);
-        for (int j = 0; j < castKids.length; j++) {
-
-            if (!st.getJavaClass().isAssignableFrom(kids[j].getClass())) {
-                //System.out.println("before typechange " +
-                // kids[j].getClass());
-                kids[j] = kids[j].changeType(st);
-                //System.out.println("after typechange " + kids[j].getClass());
-            }
-            else {
-                // System.out.println("no typechange needed");
-            }
-            castKids[j] = childClass.cast(kids[j]);
-        }
-        return castKids;
+      if (!st.getJavaClass().isAssignableFrom(kids[j].getClass())) {
+        // System.out.println("before typechange " +
+        // kids[j].getClass());
+        kids[j] = kids[j].changeType(st);
+        // System.out.println("after typechange " + kids[j].getClass());
+      } else {
+        // System.out.println("no typechange needed");
+      }
+      castKids[j] = childClass.cast(kids[j]);
     }
+    return castKids;
+  }
 }
-