axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Veithen <andreas.veit...@gmail.com>
Subject Re: svn commit: r888980 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
Date Tue, 15 Dec 2009 20:04:07 GMT
Azeez,

After Ruwan updated the Axis2 and Axiom dependencies of the WS-Commons
Transport project to snapshot (r890764), the problem also shows up in
the unit tests of the SimpleHTTPServer, even after your changes in
r890315 and r890676. Thus the regression is not limited to Synapse.

I think the problem boils down to the following question: assume I
have a service with endpoint /services/MyService; if I do a POST with
content type application/xml to /services/MyService (i.e. without
additional path components identifying the operation), how should
Axis2 react? Until now, this type of request gets dispatched in the
same way as a SOAP request; but with your change, an empty message
will flow through the handler chain. Since the unit tests set
AxisService.SUPPORT_SINGLE_OP to true, this empty message even hits
the service.

Andreas

On Sun, Dec 13, 2009 at 19:29, Afkham Azeez <azeez@apache.org> wrote:
> I'll look into this.
> Azeez
>
> On Sun, Dec 13, 2009 at 5:36 PM, Andreas Veithen <andreas.veithen@gmail.com>
> wrote:
>>
>> Afkham,
>>
>> Your change in createDocumentElement causes a regression detected by
>> the unit tests of the Synapse NHTTP transport. The failing test cases
>> send POST requests with plain XML and content type application/xml to
>> the NHTTP transport receiver. Because of your change, the service now
>> receives an empty message.
>>
>> Andreas
>>
>> On Wed, Dec 9, 2009 at 22:25,  <azeez@apache.org> wrote:
>> > Author: azeez
>> > Date: Wed Dec  9 21:25:21 2009
>> > New Revision: 888980
>> >
>> > URL: http://svn.apache.org/viewvc?rev=888980&view=rev
>> > Log:
>> > If it is a REST request and the service or operation cannot be found, do
>> > not consume the input stream
>> >
>> > Modified:
>> >
>> >  webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
>> >
>> > Modified:
>> > webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
>> > URL:
>> > http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?rev=888980&r1=888979&r2=888980&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
>> > (original)
>> > +++
>> > webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
>> > Wed Dec  9 21:25:21 2009
>> > @@ -66,10 +66,10 @@
>> >     public static SOAPEnvelope createSOAPMessage(MessageContext
>> > msgContext) throws AxisFault {
>> >         return createSOAPMessage(msgContext, false);
>> >     }
>> > -
>> > +
>> >     /**
>> >      * This method will create a SOAPEnvelope based on the InputStream
>> > stored on
>> > -     * the MessageContext. The 'detach' parameter controls whether or
>> > not the
>> > +     * the MessageContext. The 'detach' parameter controls whether or
>> > not the
>> >      * underlying DetachableInputStream is detached at the end of the
>> > method. Note,
>> >      * detaching the DetachableInputStream closes the underlying
>> > InputStream that
>> >      * is stored on the MessageContext.
>> > @@ -106,7 +106,7 @@
>> >
>> > msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
>> > charSetEnc);
>> >
>> >             SOAPEnvelope env = createSOAPMessage(msgContext, inStream,
>> > contentType);
>> > -
>> > +
>> >             // if we were told to detach, we will make the call here,
>> > this is only applicable
>> >             // if a DetachableInputStream instance is found on the
>> > MessageContext
>> >             if(detach) {
>> > @@ -156,7 +156,9 @@
>> >             // SOAPEnvelope.
>> >             SOAPFactory soapFactory = new SOAP11Factory();
>> >             envelope = soapFactory.getDefaultEnvelope();
>> > -            envelope.getBody().addChild(documentElement);
>> > +            if (documentElement != null) {
>> > +                envelope.getBody().addChild(documentElement);
>> > +            }
>> >         }
>> >         return envelope;
>> >     }
>> > @@ -164,6 +166,13 @@
>> >     public static OMElement createDocumentElement(String contentType,
>> >                                                   MessageContext
>> > msgContext,
>> >                                                   InputStream
inStream)
>> > throws AxisFault, XMLStreamException {
>> > +        // If we are handling a REST request, and the dispatchAndVerify
>> > method was not able to
>> > +        // locate the relevant service/operation, we should not try to
>> > build a document element
>> > +        if (msgContext.isDoingREST() &&
>> > +            (msgContext.getAxisService() == null ||
>> > msgContext.getAxisOperation() == null)) {
>> > +            return null;
>> > +        }
>> > +
>> >         OMElement documentElement = null;
>> >         String type = null;
>> >         if (contentType != null) {
>> > @@ -191,7 +200,7 @@
>> >             Builder builder = BuilderUtil.getBuilderFromSelector(type,
>> > msgContext);
>> >             if (builder != null) {
>> >                    if (log.isDebugEnabled()) {
>> > -                       log.debug("createSOAPEnvelope using Builder
(" +
>> > +                       log.debug("createSOAPEnvelope using Builder
(" +
>> >                                  builder.getClass() + ") selected
from
>> > type (" + type +")");
>> >                    }
>> >                 documentElement = builder.processDocument(inStream,
>> > contentType, msgContext);
>> > @@ -435,8 +444,8 @@
>> >         }
>> >         return messageFormatterProperty;
>> >     }
>> > -
>> > -
>> > +
>> > +
>> >         /**
>> >          * This is a helper method to get the response written flag from
>> > the RequestResponseTransport
>> >          * instance.
>> > @@ -456,7 +465,7 @@
>> >                 return false;
>> >             }
>> >         }
>> > -
>> > +
>> >        /**
>> >          * This is a helper method to set the response written flag on
>> > the RequestResponseTransport
>> >          * instance.
>> > @@ -474,7 +483,7 @@
>> >                }
>> >            }
>> >        }
>> > -
>> > +
>> >        /**
>> >         * This is an internal helper method to retrieve the
>> > RequestResponseTransport instance
>> >         * from the MessageContext object. The MessageContext may be the
>> > response MessageContext so
>> > @@ -484,7 +493,7 @@
>> >           try {
>> >                   // If this is the request MessageContext we should
>> > find it directly by the getProperty()
>> >                // method
>> > -               if
>> > (messageContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL)
>> > +               if
>> > (messageContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL)
>> >                           != null) {
>> >                    return (RequestResponseTransport)
>> > messageContext.getProperty(
>> >
>> > RequestResponseTransport.TRANSPORT_CONTROL);
>> > @@ -497,10 +506,10 @@
>> >
>> >  getOperationContext().getMessageContext(
>> >
>> >  WSDLConstants.MESSAGE_LABEL_IN_VALUE).getProperty(
>> >
>> >                RequestResponseTransport.TRANSPORT_CONTROL);
>> > -                       }
>> > +                       }
>> >                        else {
>> >                                return null;
>> > -                       }
>> > +                       }
>> >           }
>> >            catch(AxisFault af) {
>> >                // probably should not be fatal, so just log the message
>> > @@ -509,16 +518,16 @@
>> >                return null;
>> >            }
>> >     }
>> > -
>> > +
>> >        /**
>> > -        * Clean up cached attachment file
>> > +        * Clean up cached attachment file
>> >         * @param msgContext
>> >         */
>> >        public static void deleteAttachments(MessageContext msgContext) {
>> >                if (log.isDebugEnabled()) {
>> >                log.debug("Entering deleteAttachments()");
>> >            }
>> > -
>> > +
>> >                Attachments attachments = msgContext.getAttachmentMap();
>> >                LifecycleManager lcm =
>> > (LifecycleManager)msgContext.getRootContext().getAxisConfiguration().getParameterValue(DeploymentConstants.ATTACHMENTS_LIFECYCLE_MANAGER);
>> >            if (attachments != null) {
>> > @@ -555,7 +564,7 @@
>> >
>> >                            if (file != null) {
>> >                                if(lcm!=null){
>> > -                                   try{
>> > +                                   try{
>> >                                        lcm.deleteOnExit(file);
>> >                                    }catch(Exception ex){
>> >                                        file.deleteOnExit();
>> > @@ -569,16 +578,16 @@
>> >                    }
>> >                }
>> >            }
>> > -
>> > +
>> >            if (log.isDebugEnabled()) {
>> >                log.debug("Exiting deleteAttachments()");
>> >            }
>> >        }
>> > -
>> > +
>> >        /**
>> >         * This method can be called by components wishing to detach the
>> > DetachableInputStream
>> >         * object that is present on the MessageContext. This is meant to
>> > shield components
>> > -        * from any logic that needs to be executed on the
>> > DetachableInputStream in order to
>> > +        * from any logic that needs to be executed on the
>> > DetachableInputStream in order to
>> >         * have it effectively detached. If the DetachableInputStream is
>> > not present, or if
>> >         * the supplied MessageContext is null, no action will be taken.
>> >         */
>> > @@ -597,7 +606,7 @@
>> >                    if(log.isDebugEnabled()) {
>> >                        log.debug("Detach not performed for
>> > MessageContext: " + msgContext);
>> >                    }
>> > -               }
>> > +               }
>> >            }
>> >            catch(Throwable t) {
>> >                throw AxisFault.makeFault(t);
>> > @@ -642,8 +651,8 @@
>> >                 if (msgContext.isServerSide()) {
>> >                     if (msgContext.isDoingMTOM()) {
>> >                         enableMTOM = true;
>> > -                    }
>> > -                    // in the client side, we enable MTOM if it is
>> > optional
>> > +                    }
>> > +                    // in the client side, we enable MTOM if it is
>> > optional
>> >                 } else {
>> >                     enableMTOM = true;
>> >                 }
>> > @@ -699,7 +708,7 @@
>> >         if (msgContext.isDoingREST()) {
>> >             return true;
>> >         }
>> > -
>> > +
>> >         Object enableRESTProperty =
>> > msgContext.getProperty(Constants.Configuration.ENABLE_REST);
>> >         if (enableRESTProperty != null) {
>> >             enableREST = JavaUtils.isTrueExplicitly(enableRESTProperty);
>> > @@ -739,3 +748,4 @@
>> >     }
>> >
>> >  }
>> > +
>> > \ No newline at end of file
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
>> For additional commands, e-mail: dev-help@synapse.apache.org
>>
>
>
>
> --
> Thanks
> Afkham Azeez
>
> Blog: http://afkham.org
> Developer Portal: http://www.wso2.org
> WSAS Blog: http://wso2wsas.blogspot.com
> Company: http://wso2.com
> GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760
>

Mime
View raw message