axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r440271 - in /webservices/axis2/trunk/java/modules: java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java kernel/src/org/apache/axis2/deployment/util/Utils.java kernel/src/org/apache/axis2/description/AxisService.java
Date Tue, 05 Sep 2006 05:58:19 GMT
Author: deepal
Date: Mon Sep  4 22:58:18 2006
New Revision: 440271

URL: http://svn.apache.org/viewvc?view=rev&rev=440271
Log:
- fault message generation for POJOs and Java2wsdl
(I know , need to improve that a lot but need expert opinion)

Modified:
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java?view=diff&rev=440271&r1=440270&r2=440271
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
(original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
Mon Sep  4 22:58:18 2006
@@ -153,6 +153,15 @@
                         // no need to generate Schema for non public methods
                         continue;
                     }
+                    if (jMethod.getExceptionTypes().length > 0) {
+                        methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName()
+ "Fault");
+                        sequence = new XmlSchemaSequence();
+                        XmlSchemaElement elt1 = new XmlSchemaElement();
+                        elt1.setName(jMethod.getSimpleName() + "Fault");
+                        elt1.setSchemaTypeName(typeTable.getQNamefortheType(Object.class.getName()));
+                        sequence.getItems().add(elt1);
+                        methodSchemaType.setParticle(sequence);
+                    }
                     uniqueMethods.put(jMethod.getSimpleName(), jMethod);
                     //create the schema type for the method wrapper
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?view=diff&rev=440271&r1=440270&r2=440271
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
Mon Sep  4 22:58:18 2006
@@ -26,13 +26,13 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import java.io.*;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.*;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
-import java.lang.reflect.Method;
 
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
@@ -218,7 +218,7 @@
         ClassLoader serviceClassLoader = axisService.getClassLoader();
 
         if (implInfoParam != null) {
-           serviceClass = (String) implInfoParam.getValue();
+            serviceClass = (String) implInfoParam.getValue();
         } else {
             // if Service_Class is null, every AbstractMR will look for
             // ServiceObjectSupplier. This is user specific and may contain
@@ -231,10 +231,10 @@
                 // Find static getServiceObject() method, call it if there
                 Method method = serviceObjectMaker.
                         getMethod("getServiceObject",
-                                  new Class[] { AxisService.class });
+                                new Class[]{AxisService.class});
                 Object obj = null;
                 if (method != null) {
-                    obj =  method.invoke(serviceObjectMaker.newInstance(), new Object[] {
axisService });
+                    obj = method.invoke(serviceObjectMaker.newInstance(), new Object[]{axisService});
                 }
                 if (obj == null) {
                     throw new Exception("ServiceObjectSupplier implmentation Object could
not be found");
@@ -329,7 +329,12 @@
                     Java2WSDLConstants.RESPONSE));
             outMessage.setName(opName + Java2WSDLConstants.RESPONSE);
         }
-
+        if (jmethod.getExceptionTypes().length > 0) {
+            AxisMessage faultMessage = new AxisMessage();
+            faultMessage.setName(jmethod.getSimpleName() + "Fault");
+            faultMessage.setElementQName(table.getComplexSchemaType(jmethod.getSimpleName()
+ "Fault"));
+            operation.setFaultMessages(faultMessage);
+        }
         operation.setName(new QName(opName));
         AxisMessage inMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
         if (inMessage != null) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?view=diff&rev=440271&r1=440270&r2=440271
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
Mon Sep  4 22:58:18 2006
@@ -60,8 +60,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.URL;
 import java.net.SocketException;
+import java.net.URL;
 import java.util.*;
 
 /**
@@ -523,7 +523,7 @@
         AxisOperation axisOperation = getOperation(new QName(operationName));
         if (axisOperation == null) {
             throw new AxisFault(Messages.getMessage("invalidoperation",
-                                                    operationName));
+                    operationName));
         }
         PolicyUtil.writePolicy(axisOperation.getPolicyInclude(), out);
     }
@@ -595,10 +595,10 @@
                     if (listener != null) {
                         try {
                             if (listener.getEPRForService(getName(), requestIP)
-                                != null) {
+                                    != null) {
                                 String address =
                                         listener.getEPRForService(getName(),
-                                                                  requestIP).getAddress();
+                                                requestIP).getAddress();
                                 if (address != null) {
                                     eprList.add(address);
                                 }
@@ -638,7 +638,7 @@
     private void getWSDL(OutputStream out, String [] serviceURL, String servicePath) throws
AxisFault {
         if (isWsdlfound()) {
             AxisService2OM axisService2WOM = new AxisService2OM(this,
-                                                                serviceURL, "document", "literal",
servicePath);
+                    serviceURL, "document", "literal", servicePath);
             try {
                 OMElement wsdlElement = axisService2WOM.generateOM();
                 wsdlElement.serialize(out);
@@ -656,10 +656,10 @@
     private void printWSDLError(OutputStream out) throws AxisFault {
         try {
             String wsdlntfound = "<error>" +
-                                 "<description>Unable to generate WSDL for this service</description>"
+
-                                 "<reason>Either user has not dropped the wsdl into
META-INF or" +
-                                 " operations use message receivers other than RPC.</reason>"
+
-                                 "</error>";
+                    "<description>Unable to generate WSDL for this service</description>"
+
+                    "<reason>Either user has not dropped the wsdl into META-INF or"
+
+                    " operations use message receivers other than RPC.</reason>" +
+                    "</error>";
             out.write(wsdlntfound.getBytes());
             out.flush();
             out.close();
@@ -943,9 +943,9 @@
      */
     public void setScope(String scope) {
         if (Constants.SCOPE_APPLICATION.equals(scope) ||
-            Constants.SCOPE_TRANSPORT_SESSION.equals(scope) ||
-            Constants.SCOPE_SOAP_SESSION.equals(scope) ||
-            Constants.SCOPE_REQUEST.equals(scope)) {
+                Constants.SCOPE_TRANSPORT_SESSION.equals(scope) ||
+                Constants.SCOPE_SOAP_SESSION.equals(scope) ||
+                Constants.SCOPE_REQUEST.equals(scope)) {
             this.scope = scope;
         }
     }
@@ -1215,13 +1215,13 @@
 
         ClassLoader serviceClassLoader = axisService.getClassLoader();
         SchemaGenerator schemaGenerator;
+        ArrayList excludeOpeartion = new ArrayList();
         try {
             schemaGenerator = new SchemaGenerator(serviceClassLoader,
-                                                  implClass, schemaNameSpace,
-                                                  axisService.getSchematargetNamespacePrefix());
+                    implClass, schemaNameSpace,
+                    axisService.getSchematargetNamespacePrefix());
             schemaGenerator.setElementFormDefault(Java2WSDLConstants.FORM_DEFAULT_UNQUALIFIED);
             axisService.setElementFormDefault(false);
-            ArrayList excludeOpeartion = new ArrayList();
             excludeOpeartion.add("init");
             excludeOpeartion.add("setOperationContext");
             excludeOpeartion.add("destroy");
@@ -1245,7 +1245,7 @@
             if (!jmethod.isPublic()) {
                 // no need to expose , private and protected methods
                 continue;
-            } else if ("init".equals(jmethod.getSimpleName())) {
+            } else if (excludeOpeartion.contains(jmethod.getSimpleName())) {
                 continue;
             }
             AxisOperation operation = Utils.getAxisOperationforJmethod(jmethod, table);
@@ -1256,10 +1256,10 @@
                 operation.setMessageReceiver(messageReceiver);
             } catch (IllegalAccessException e) {
                 throw new AxisFault("IllegalAccessException occured during message receiver
loading"
-                                    + e.getMessage());
+                        + e.getMessage());
             } catch (InstantiationException e) {
                 throw new AxisFault("InstantiationException occured during message receiver
loading"
-                                    + e.getMessage());
+                        + e.getMessage());
             }
             pinfo.setOperationPhases(operation);
             axisService.addOperation(operation);
@@ -1275,7 +1275,7 @@
             clazz = Class.forName("org.apache.axis2.rpc.receivers.RPCMessageReceiver");
         } catch (ClassNotFoundException e) {
             throw new AxisFault("ClassNotFoundException occured during message receiver loading"
-                                + e.getMessage());
+                    + e.getMessage());
         }
 
         return createService(implClass, axisConfig, clazz);
@@ -1367,13 +1367,13 @@
                     s = externalSchema.getSchema();
                     if (s != null && nameTable.get(s) == null) {
                         nameTable.put(s,
-                                      ("xsd" + count++)
-                                      + (customSchemaNameSuffix != null ?
-                                         customSchemaNameSuffix :
-                                         ""));
+                                ("xsd" + count++)
+                                        + (customSchemaNameSuffix != null ?
+                                        customSchemaNameSuffix :
+                                        ""));
                         calcualteSchemaNames(Arrays.asList(
                                 new XmlSchema[]{s}),
-                                             nameTable);
+                                nameTable);
                     }
                 }
             }
@@ -1411,6 +1411,7 @@
             }
         }
     }
+
     /**
      * Swap the key,value pairs
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message