You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2006/02/08 06:53:49 UTC

svn commit: r375868 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/BeanUtil.java core/src/org/apache/axis2/description/AxisService.java wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java

Author: deepal
Date: Tue Feb  7 21:53:47 2006
New Revision: 375868

URL: http://svn.apache.org/viewcvs?rev=375868&view=rev
Log:
- Java2WSDL fixing (specillay in Java2 Schema generation)
- added a new binding ?wsdl if the wsdl is there

Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=375868&r1=375867&r2=375868&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Tue Feb  7 21:53:47 2006
@@ -19,12 +19,14 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
+import org.apache.axis2.wsdl.builder.SchemaGenerator;
 import org.apache.ws.commons.om.OMAbstractFactory;
 import org.apache.ws.commons.om.OMAttribute;
 import org.apache.ws.commons.om.OMElement;
 import org.apache.ws.commons.om.OMFactory;
 import org.apache.ws.commons.om.impl.llom.builder.StAXOMBuilder;
 import org.apache.ws.commons.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.codehaus.jam.*;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
@@ -49,11 +51,35 @@
      */
     public static XMLStreamReader getPullParser(Object beanObject, QName beanName) {
         try {
+            JamServiceFactory factory = JamServiceFactory.getInstance();
+            JamServiceParams jam_service_parms = factory.createServiceParams();
+            //setting the classLoder
+//        jam_service_parms.setParentClassLoader(factory.createJamClassLoader(classLoader));
+            //it can posible to add the classLoader as well
+            jam_service_parms.addClassLoader(beanObject.getClass().getClassLoader());
+            jam_service_parms.includeClass(beanObject.getClass().getName());
+            JamService service = factory.createService(jam_service_parms);
+            JamClassIterator jClassIter = service.getClasses();
+            JClass jClass = null;
+            while (jClassIter.hasNext()) {
+                jClass = (JClass) jClassIter.next();
+
+            }
+            // properties from JAM
+            JProperty properties [] = jClass.getDeclaredProperties();
+
             BeanInfo beanInfo = Introspector.getBeanInfo(beanObject.getClass());
             PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
-            ArrayList object = new ArrayList();
+            HashMap propertMap = new HashMap();
             for (int i = 0; i < propDescs.length; i++) {
                 PropertyDescriptor propDesc = propDescs[i];
+                propertMap.put(propDesc.getName(), propDesc);
+            }
+            ArrayList object = new ArrayList();
+            for (int i = 0; i < properties.length; i++) {
+                JProperty property = properties[i];
+                PropertyDescriptor propDesc = (PropertyDescriptor) propertMap.get(
+                        SchemaGenerator.getCorrectName(property.getSimpleName()));
                 Class ptype = propDesc.getPropertyType();
                 if (propDesc.getName().equals("class")) {
                     continue;
@@ -104,11 +130,7 @@
                 }
             }
             return ADBPullParser.createPullParser(beanName, object.toArray(), null);
-            // TODO : Deepal fix this. I added another parameter to the above method in the ADBPullPrser
-            // to get the attributes array. For the time being I passed null. Pass attributes array here.
-
         } catch (Exception e) {
-            //todo has to throw this exeception
             return null;
         }
     }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=375868&r1=375867&r2=375868&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java Tue Feb  7 21:53:47 2006
@@ -17,8 +17,7 @@
 
 package org.apache.axis2.description;
 
-import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
-import com.ibm.wsdl.extensions.soap.SOAPConstants;
+import com.ibm.wsdl.extensions.soap.*;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.engine.AxisConfiguration;
@@ -26,18 +25,17 @@
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.wsdl.builder.SchemaGenerator;
+import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
 import org.apache.axis2.wsdl.writer.WOMWriter;
 import org.apache.axis2.wsdl.writer.WOMWriterFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.wsdl.WSDLConstants;
-import org.apache.wsdl.WSDLDescription;
+import org.apache.wsdl.*;
+import org.apache.wsdl.extensions.*;
 
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
+import javax.wsdl.*;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
@@ -328,9 +326,112 @@
         }
     }
 
+    private WSDLBinding generateBinding(WSDLComponentFactory wsdlComponentFactory,
+                                        WSDLInterface portType, QName bindingName,
+                                        String style,
+                                        String use,
+                                        String trsportURI,
+                                        String namespeceURI) {
+        WSDLBinding binding = wsdlComponentFactory.createBinding();
+
+        ExtensionFactory extensionFactory = wsdlComponentFactory.createExtensionFactory();
+
+        binding.setBoundInterface(portType);
+        binding.setName(bindingName);
+
+        SOAPBinding soapbindingImpl = (SOAPBinding) extensionFactory.getExtensionElement(
+                ExtensionConstants.SOAP_11_BINDING);
+        soapbindingImpl.setStyle(style);
+        soapbindingImpl.setTransportURI(trsportURI);
+        binding.addExtensibilityElement(soapbindingImpl);
+
+        Iterator op_itr = portType.getOperations().keySet().iterator();
+        while (op_itr.hasNext()) {
+            String opName = (String) op_itr.next();
+            WSDLOperation wsdlOperation = portType.getOperation(opName);
+            MessageReference inMessage = wsdlOperation.getInputMessage();
+
+            WSDLBindingOperation bindingoperation = wsdlComponentFactory.createWSDLBindingOperation();
+            bindingoperation.setName(new QName(opName));
+            bindingoperation.setOperation(wsdlOperation);
+            binding.addBindingOperation(bindingoperation);
+
+            SOAPOperation soapOpimpl = (SOAPOperation) extensionFactory.getExtensionElement(
+                    ExtensionConstants.SOAP_11_OPERATION);
+            soapOpimpl.setStyle(style);
+            //to do heve to set a proper SOAPAction
+            soapOpimpl.setSoapAction(opName);
+            bindingoperation.addExtensibilityElement(soapOpimpl);
+            if (inMessage != null) {
+                WSDLBindingMessageReference bindingInMessage = wsdlComponentFactory.createWSDLBindingMessageReference();
+                bindingInMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+                bindingoperation.setInput(bindingInMessage);
+
+                SOAPBody requestSoapbody = (SOAPBody) extensionFactory.getExtensionElement(
+                        ExtensionConstants.SOAP_11_BODY);
+                requestSoapbody.setUse(use);
+                //todo need to fix this
+                requestSoapbody.setNamespaceURI(namespeceURI);
+                bindingInMessage.addExtensibilityElement(requestSoapbody);
+            }
+
+            MessageReference outMessage = wsdlOperation.getOutputMessage();
+            if (outMessage != null) {
+                WSDLBindingMessageReference bindingOutMessage = wsdlComponentFactory.createWSDLBindingMessageReference();
+
+                bindingOutMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+                bindingoperation.setOutput(bindingOutMessage);
+                SOAPBody resSoapbody = (SOAPBody) extensionFactory.getExtensionElement(
+                        ExtensionConstants.SOAP_11_BODY);
+                resSoapbody.setUse(use);
+                resSoapbody.setNamespaceURI(namespeceURI);
+                bindingOutMessage.addExtensibilityElement(resSoapbody);
+            }
+        }
+        return binding;
+    }
+
+
     private void printUsingWSDLDefinition(OutputStream out, String serviceURL) throws AxisFault {
         try {
             Definition wsdlDefinition = getWSDLDefinition();
+            Iterator itr_bindings = wsdlDefinition.getBindings().values().iterator();
+            while (itr_bindings.hasNext()) {
+                Binding binding = (Binding) itr_bindings.next();
+                binding.getExtensibilityElements().clear();
+                javax.wsdl.extensions.soap.SOAPBinding soapBinding = new SOAPBindingImpl();
+                soapBinding.setStyle("document");
+                soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+                binding.addExtensibilityElement(soapBinding);
+
+                Iterator bin_ops = binding.getBindingOperations().iterator();
+                while (bin_ops.hasNext()) {
+                    BindingOperation bindingOperation = (BindingOperation) bin_ops.next();
+                    bindingOperation.getExtensibilityElements().clear();
+                    javax.wsdl.extensions.soap.SOAPOperation soapOperation = new SOAPOperationImpl();
+                    soapOperation.setStyle("document");
+                    soapOperation.setSoapActionURI(bindingOperation.getName());
+                    bindingOperation.addExtensibilityElement(soapOperation);
+
+                    BindingInput input = bindingOperation.getBindingInput();
+                    if (input != null) {
+                        input.getExtensibilityElements().clear();
+                        javax.wsdl.extensions.soap.SOAPBody soapBody = new SOAPBodyImpl();
+                        soapBody.setUse("literal");
+                        soapBody.setNamespaceURI(getTargetNamespace());
+                        input.addExtensibilityElement(soapBody);
+                    }
+                    BindingOutput output = bindingOperation.getBindingOutput();
+                    if (output != null) {
+                        output.getExtensibilityElements().clear();
+                        javax.wsdl.extensions.soap.SOAPBody soapBody = new SOAPBodyImpl();
+                        soapBody.setUse("literal");
+                        soapBody.setNamespaceURI(getTargetNamespace());
+                        output.addExtensibilityElement(soapBody);
+                    }
+                }
+            }
+
             Collection services = wsdlDefinition.getServices().values();
 
             for (Iterator iterator = services.iterator(); iterator.hasNext();) {
@@ -339,8 +440,6 @@
 
                 for (Iterator iterator1 = ports.iterator(); iterator1.hasNext();) {
                     Port port = (Port) iterator1.next();
-
-                    service.setQName(new QName(this.getName()));
 
                     SOAPAddress soapAddress = new SOAPAddressImpl();
 

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java?rev=375868&r1=375867&r2=375868&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java Tue Feb  7 21:53:47 2006
@@ -317,7 +317,7 @@
      * @param wrongName
      * @return
      */
-    private String getCorrectName(String wrongName) {
+    public static String getCorrectName(String wrongName) {
         if (wrongName.length() > 1) {
             return wrongName.substring(0, 1).toLowerCase() + wrongName.substring(1, wrongName.length());
         } else {
@@ -365,7 +365,6 @@
                     if (isArryType) {
                         elt1.setMaxOccurs(Long.MAX_VALUE);
                         elt1.setMinOccurs(0);
-//                        elt1.setMinOccurs(2);
                     }
                 } else {
                     if (isArryType) {