[ 
http://issues.apache.org/jira/browse/AXIS-2200?page=comments#action_12324424 ] 

Chris Nappin commented on AXIS-2200:
------------------------------------

Here's a patch based on the latest code in CVS, I've also added a constant for 
the property name in AxisEngine as it's only hard-coded elsewhere in the http 
transport code. Note that I've assumed that if the development property is not 
explicitly set, Axis is in development mode by default.

Index: AxisEngine.java
===================================================================
RCS file: /home/cvspublic/ws-axis/java/src/org/apache/axis/AxisEngine.java,v
retrieving revision 1.121
diff -u -r1.121 AxisEngine.java
--- AxisEngine.java 21 Apr 2005 19:47:06 -0000 1.121
+++ AxisEngine.java 12 Sep 2005 21:00:42 -0000
@@ -75,6 +75,7 @@
     public static final String PROP_BYTE_BUFFER_RESIDENT_MAX_SIZE = 
"axis.byteBuffer.residentMaxSize";
     public static final String PROP_BYTE_BUFFER_WORK_BUFFER_SIZE = 
"axis.byteBuffer.workBufferSize";
     public static final String PROP_EMIT_ALL_TYPES = "emitAllTypesInWSDL";
+    public static final String PROP_IS_DEVELOPMENT_SYSTEM =
"axis.development.system";
     /**
      * Set this property to 'true' when you want Axis to avoid soap encoded
      * types to work around a .NET problem where it wont accept soap encoded




Index: AxisFault.java
===================================================================
RCS file: /home/cvspublic/ws-axis/java/src/org/apache/axis/AxisFault.java,v
retrieving revision 1.90
diff -u -r1.90 AxisFault.java
--- AxisFault.java 6 Jul 2005 06:21:58 -0000 1.90
+++ AxisFault.java 12 Sep 2005 20:59:29 -0000
@@ -251,14 +251,13 @@


         // Put the exception class into the AXIS SPECIFIC HACK
-        //  "exceptionName" element in the details.  This allows
-        // us to get back a correct Java Exception class on the other side
-        // (assuming they have it available).
-        // NOTE: This hack is obsolete!  We now serialize exception data
-        // and the other side uses *that* QName to figure out what
exception
-        // to use, because the class name may be completly different on the
-        // client.
-        if ((target instanceof AxisFault) &&
+        //  "exceptionName" element in the details.  Note this is an
+        // obsolete hack (no longer needed because exception data is
+        // serialized and the other side uses the QName of that) that has
+        // been kept only so the stack trace makes sense. Also, this
+        // information is only output if Axis is in development mode.
+        if (isDevelopmentMode() &&
+            (target instanceof AxisFault) &&
             (target.getClass() != AxisFault.class)) {
           addFaultDetail(Constants.QNAME_FAULTDETAIL_EXCEPTIONNAME,
                     target.getClass().getName()); @@ -873,9 +872,10 @@
      * @since Axis1.2
      */
     public void addHostnameIfNeeded() {
-        //look for an existing declaration
-        if(lookupFaultDetail(Constants.QNAME_FAULTDETAIL_HOSTNAME)!=null) {
-            //and do nothing if it exists
+        // if this is a production mode system or hostname is already
present...
+        if (!isDevelopmentMode() ||
+            lookupFaultDetail(Constants.QNAME_FAULTDETAIL_HOSTNAME) !=
null) {
+            // ...then do nothing
             return;
         }
         addHostname(NetworkUtils.getLocalHostname());
@@ -900,4 +900,14 @@
     public void removeHostname() {
         removeFaultDetail(Constants.QNAME_FAULTDETAIL_HOSTNAME);
     }
+
+    /**
+     * Determine whether Axis is in development or production mode.
+     * @return <code>true</code> if in development mode
+     */
+    private boolean isDevelopmentMode() {
+        //note that if property is not set, assume development mode
+        return AxisEngine.getCurrentMessageContext().isPropertyTrue(
+                AxisEngine.PROP_IS_DEVELOPMENT_SYSTEM, true);
+    }
 }



> Unable to throw CustomException without hostname and exceptionName being 
> added to details
> -----------------------------------------------------------------------------------------
>
>          Key: AXIS-2200
>          URL: http://issues.apache.org/jira/browse/AXIS-2200
>      Project: Apache Axis
>         Type: Bug
>   Components: Basic Architecture
>     Versions: 1.2.1
>  Environment: Windows XP SP1, Sun JDK 1.4.2, JBoss 4.0.2/Tomcat 5.5.9 
>     Reporter: Chris Nappin

>
> When throwing an exception as a fault in Axis, it automatically adds a 
> "hostname" and "exceptionName" to the "detail" section. Whilst I'm sure this 
> can be really useful for debugging development systems, it should be possible 
> to turn this behaviour off for a production system. Perhaps it could be tied 
> to the "axis.development.system" flag, like stack traces in SOAP faults are?  
> Below is an example SOAP fault extract thrown by Axis:
> <soapenv:Fault>
>     <faultcode>soapenv:Server.generalException</faultcode>
>     <faultstring/>
>     <detail>
>         <com.test.MyFirstException>
>             <text>Test!</text>
>         </com.test.MyFirstException>
>         <ns1:exceptionName xmlns:ns1="http://xml.apache.org/axis/";>
>             com.test.MyFirstException
>         </ns1:exceptionName>
>         <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/";>
>             PC55-ABMUK
>         </ns2:hostname>
>     </detail>
> </soapenv:Fault>
> This SOAP extract is taken from a fault thrown by an auto-generated exception 
> defined using the following wsdl:
> <!-- fault element -->
>   <xsd:element name="MyFirstException">
>    <xsd:complexType>
>     <xsd:sequence>
>      <xsd:element name="text" type="xsd:string" minOccurs="1" maxOccurs="1" 
> nillable="false"/>
>     </xsd:sequence>
>    </xsd:complexType>
>   </xsd:element>
> ...
> <message name="MyFirstExceptionFault">
>     <part name="fault" element="typens:MyFirstException"/>
> </message>
> ...
> <portType name="MyPort">
> <operation name="test">
>     <input message="typens:Request"/>
>     <output message="typens:Response"/>
>     <fault name="MySecondException" message="typens:MySecondExceptionFault"/>
> </operation>
> </port>
> ...
> <binding name="MyBinding" type="typens:MyPort">
>       <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; 
> style="document"/>
>       <operation name="test">
>         <input>
>               <soap:body use="literal"/>
>         </input>
>         <output>
>               <soap:body use="literal"/>
>         </output>
>           <fault name="MyFirstException">
>                 <soap:fault name="MyFirstException" use="literal"/>
>           </fault>        
>       </operation>
>   </binding>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to