You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Martin Gainty <mg...@hotmail.com> on 2009/09/27 18:14:41 UTC

Testing REST functionality

could someone determine if checking contentType to determine RESTRequest is sufficient?

org.apache.axis2.transport.http.HttpTransportUtils{
public static final String MEDIA_TYPE_APPLICATION_XML = "application/xml";
    public static final String MEDIA_TYPE_X_WWW_FORM =
            "application/x-www-form-urlencoded";
    public static final String MEDIA_TYPE_MULTIPART_FORM_DATA = "multipart/form-data";

    public static boolean isRESTRequest(String contentType) {
        return contentType != null &&
               (contentType.indexOf(HTTPConstants.MEDIA_TYPE_APPLICATION_XML) > -1 ||
                contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) > -1 ||
                contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA) > -1);
    }
}
some other projects are mapping REST based on URL parse(and not necessarily contentType test)
does REST have a spec to follow and if so is there any parsing of URL to determine if this is a REST request?

thanks,
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


 		 	   		  
_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

Re: Testing REST functionality

Posted by Andreas Veithen <an...@gmail.com>.
On Sun, Sep 27, 2009 at 18:14, Martin Gainty <mg...@hotmail.com> wrote:
> could someone determine if checking contentType to determine RESTRequest is
> sufficient?
>
> org.apache.axis2.transport.http.HttpTransportUtils{
> public static final String MEDIA_TYPE_APPLICATION_XML = "application/xml";
>     public static final String MEDIA_TYPE_X_WWW_FORM =
>             "application/x-www-form-urlencoded";
>     public static final String MEDIA_TYPE_MULTIPART_FORM_DATA =
> "multipart/form-data";
>
>     public static boolean isRESTRequest(String contentType) {
>         return contentType != null &&
>
> (contentType.indexOf(HTTPConstants.MEDIA_TYPE_APPLICATION_XML) > -1 ||
>                 contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) >
> -1 ||
>
> contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA) > -1);
>     }
> }
> some other projects are mapping REST based on URL parse(and not necessarily
> contentType test)

I'm not an expert, but I would say that RESTfulness is a property of
the service, not the message. This implies that one can determine
whether a request is REST or not only after dispatching to the service
(based on the URL). I don't know why in Axis2, we try to do this at
transport level.

Andreas

> does REST have a spec to follow and if so is there any parsing of URL to
> determine if this is a REST request?
>
> thanks,
> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
> ________________________________
> Hotmail® has ever-growing storage! Don’t worry about storage limits. Check
> it out.

Re: Testing REST functionality

Posted by Amila Suriarachchi <am...@gmail.com>.
On Sun, Sep 27, 2009 at 9:44 PM, Martin Gainty <mg...@hotmail.com> wrote:

>  could someone determine if checking contentType to determine RESTRequest
> is sufficient?
>
> org.apache.axis2.transport.http.HttpTransportUtils{
> public static final String MEDIA_TYPE_APPLICATION_XML = "application/xml";
>     public static final String MEDIA_TYPE_X_WWW_FORM =
>             "application/x-www-form-urlencoded";
>     public static final String MEDIA_TYPE_MULTIPART_FORM_DATA =
> "multipart/form-data";
>
>     public static boolean isRESTRequest(String contentType) {
>         return contentType != null &&
>
> (contentType.indexOf(HTTPConstants.MEDIA_TYPE_APPLICATION_XML) > -1 ||
>                 contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) >
> -1 ||
>
> contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA) > -1);
>     }
> }
> some other projects are mapping REST based on URL parse(and not necessarily
> contentType test)
> does REST have a spec to follow and if so is there any parsing of URL to
> determine if this is a REST request?
>

I think most of the Axis2 Rest stuff is based on the wsdl 2.0 http binding.

thanks,
Amila.

>
> thanks,
> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>
>
>
>
>
> ------------------------------
> Hotmail® has ever-growing storage! Don’t worry about storage limits. Check
> it out.<http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009>
>



-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/