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 Arnout Engelen <ar...@bzzt.net> on 2008/08/26 12:26:06 UTC
Friendly API for calling a RESTful webservice
Hi,
I'm trying to generate some friendly client code for accessing a
REST-ish webservice.
To that end, I wrote a WSDL2.0 description of the webservice, containing
the following operation:
<wsdl:operation name="getEvents"
pattern="http://www.w3.org/ns/wsdl/in-out"
style="http://www.w3.org/ns/wsdl/style/iri"
wsdlx:safe="true">
<wsdl:input element="lastfmgeo:getEventsRequest"/>
<wsdl:output element="lastfmgeo:lfm"/>
</wsdl:operation>
The request type is defined as follows:
<xs:element name="getEventsRequest" type="tns:getEventsRequestType">
<xs:annotation>
<xs:documentation>
The request element for the getEvents service.
</xs:documentation>
</xs:annotation>
</xs:element>
<complexType name="getEventsRequestType">
<sequence>
<element name="api_key" type="string" minOccurs="1" maxOccurs="1"/>
<element name="location" type="string" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>
I called wsdl2code on this (adb bindings), which generated a GeoStub. This
already works, like this:
GeoStub stub = new GeoStub("http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
GetEventsRequestType request = new GetEventsRequestType();
request.setApi_key(apiKey);
request.setLocation(location);
GetEventsRequest requestDoc = new GetEventsRequest();
requestDoc.setGetEventsRequest(request);
LfmType response = stub.getEvents(requestDoc).getLfm();
However, it would of course be much nicer if it could look something like this:
GeoStub stub = new GeoStub("http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
LfmType response = stub.getEvents(apiKey, location);
Would it be possible to generate a friendly interface like this?
Kind regards,
Arnout
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Friendly API for calling a RESTful webservice
Posted by Arnout Engelen <ar...@bzzt.net>.
On Tue, Aug 26, 2008 at 07:55:56PM +0530, keith chapman wrote:
> If you use the -uw options when generating the stub it becomes more
> user friendly. -uw instructs the code generator to unwrap the
> parameters. hence you will be able to call the stub as,
>
> GeoStub stub = new GeoStub();
> LfmType response = stub.getEvents(apiKey, location).getLfm();
Many thanks, that was exactly what I was hoping for.
Arnout
> On Tue, Aug 26, 2008 at 3:56 PM, Arnout Engelen <ar...@bzzt.net> wrote:
> > Hi,
> >
> > I'm trying to generate some friendly client code for accessing a
> > REST-ish webservice.
> >
> > To that end, I wrote a WSDL2.0 description of the webservice, containing
> > the following operation:
> >
> > <wsdl:operation name="getEvents"
> > pattern="http://www.w3.org/ns/wsdl/in-out"
> > style="http://www.w3.org/ns/wsdl/style/iri"
> > wsdlx:safe="true">
> > <wsdl:input element="lastfmgeo:getEventsRequest"/>
> > <wsdl:output element="lastfmgeo:lfm"/>
> > </wsdl:operation>
> >
> > The request type is defined as follows:
> >
> > <xs:element name="getEventsRequest" type="tns:getEventsRequestType">
> > <xs:annotation>
> > <xs:documentation>
> > The request element for the getEvents service.
> > </xs:documentation>
> > </xs:annotation>
> > </xs:element>
> >
> > <complexType name="getEventsRequestType">
> > <sequence>
> > <element name="api_key" type="string" minOccurs="1" maxOccurs="1"/>
> > <element name="location" type="string" minOccurs="0" maxOccurs="1"/>
> > </sequence>
> > </complexType>
> >
> > I called wsdl2code on this (adb bindings), which generated a GeoStub. This
> > already works, like this:
> >
> > GeoStub stub = new GeoStub("http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
> >
> > GetEventsRequestType request = new GetEventsRequestType();
> > request.setApi_key(apiKey);
> > request.setLocation(location);
> >
> > GetEventsRequest requestDoc = new GetEventsRequest();
> > requestDoc.setGetEventsRequest(request);
> > LfmType response = stub.getEvents(requestDoc).getLfm();
> >
> > However, it would of course be much nicer if it could look something like this:
> >
> > GeoStub stub = new GeoStub("http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
> > LfmType response = stub.getEvents(apiKey, location);
> >
> > Would it be possible to generate a friendly interface like this?
> >
> >
> > Kind regards,
> >
> > Arnout
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>
>
> --
> Keith Chapman
> Senior Software Engineer
> WSO2 Inc.
> Oxygenating the Web Service Platform.
> http://wso2.org/
>
> blog: http://www.keith-chapman.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Friendly API for calling a RESTful webservice
Posted by keith chapman <ke...@gmail.com>.
Hi,
If you use the -uw options when generating the stub it becomes more
user friendly. -uw instructs the code generator to unwrap the
parameters. hence you will be able to call the stub as,
GeoStub stub = new GeoStub();
LfmType response = stub.getEvents(apiKey, location).getLfm();
Thanks,
Keith.
On Tue, Aug 26, 2008 at 3:56 PM, Arnout Engelen <ar...@bzzt.net> wrote:
> Hi,
>
> I'm trying to generate some friendly client code for accessing a
> REST-ish webservice.
>
> To that end, I wrote a WSDL2.0 description of the webservice, containing
> the following operation:
>
> <wsdl:operation name="getEvents"
> pattern="http://www.w3.org/ns/wsdl/in-out"
> style="http://www.w3.org/ns/wsdl/style/iri"
> wsdlx:safe="true">
> <wsdl:input element="lastfmgeo:getEventsRequest"/>
> <wsdl:output element="lastfmgeo:lfm"/>
> </wsdl:operation>
>
> The request type is defined as follows:
>
> <xs:element name="getEventsRequest" type="tns:getEventsRequestType">
> <xs:annotation>
> <xs:documentation>
> The request element for the getEvents service.
> </xs:documentation>
> </xs:annotation>
> </xs:element>
>
> <complexType name="getEventsRequestType">
> <sequence>
> <element name="api_key" type="string" minOccurs="1" maxOccurs="1"/>
> <element name="location" type="string" minOccurs="0" maxOccurs="1"/>
> </sequence>
> </complexType>
>
> I called wsdl2code on this (adb bindings), which generated a GeoStub. This
> already works, like this:
>
> GeoStub stub = new GeoStub("http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
>
> GetEventsRequestType request = new GetEventsRequestType();
> request.setApi_key(apiKey);
> request.setLocation(location);
>
> GetEventsRequest requestDoc = new GetEventsRequest();
> requestDoc.setGetEventsRequest(request);
> LfmType response = stub.getEvents(requestDoc).getLfm();
>
> However, it would of course be much nicer if it could look something like this:
>
> GeoStub stub = new GeoStub("http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
> LfmType response = stub.getEvents(apiKey, location);
>
> Would it be possible to generate a friendly interface like this?
>
>
> Kind regards,
>
> Arnout
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
--
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/
blog: http://www.keith-chapman.org
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Friendly API for calling a RESTful webservice
Posted by Arnout Engelen <ar...@bzzt.net>.
On Tue, Aug 26, 2008 at 11:43:42PM +1000, Rahul Devgan wrote:
> Not sure what you are looking for exactly but have you tried www.restlet.org.
> Also, I am implementing RESTful WS for a major project but its all hand
> written Servlet based code.
I can't tell for sure from the website - does this library take care of
both the server and the client side?
For now I'm only interested in consuming web services, though it's of
course very convenient if the same tool can also be used for implementing
the server side.
Arnout
> On Tue, Aug 26, 2008 at 8:26 PM, Arnout Engelen <ar...@bzzt.net> wrote:
>
> > Hi,
> >
> > I'm trying to generate some friendly client code for accessing a
> > REST-ish webservice.
> >
> > To that end, I wrote a WSDL2.0 description of the webservice, containing
> > the following operation:
> >
> > <wsdl:operation name="getEvents"
> > pattern="http://www.w3.org/ns/wsdl/in-out"
> > style="http://www.w3.org/ns/wsdl/style/iri"
> > wsdlx:safe="true">
> > <wsdl:input element="lastfmgeo:getEventsRequest"/>
> > <wsdl:output element="lastfmgeo:lfm"/>
> > </wsdl:operation>
> >
> > The request type is defined as follows:
> >
> > <xs:element name="getEventsRequest" type="tns:getEventsRequestType">
> > <xs:annotation>
> > <xs:documentation>
> > The request element for the getEvents service.
> > </xs:documentation>
> > </xs:annotation>
> > </xs:element>
> >
> > <complexType name="getEventsRequestType">
> > <sequence>
> > <element name="api_key" type="string" minOccurs="1" maxOccurs="1"/>
> > <element name="location" type="string" minOccurs="0" maxOccurs="1"/>
> > </sequence>
> > </complexType>
> >
> > I called wsdl2code on this (adb bindings), which generated a GeoStub. This
> > already works, like this:
> >
> > GeoStub stub = new GeoStub("
> > http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
> >
> > GetEventsRequestType request = new
> > GetEventsRequestType();
> > request.setApi_key(apiKey);
> > request.setLocation(location);
> >
> > GetEventsRequest requestDoc = new
> > GetEventsRequest();
> > requestDoc.setGetEventsRequest(request);
> > LfmType response =
> > stub.getEvents(requestDoc).getLfm();
> >
> > However, it would of course be much nicer if it could look something like
> > this:
> >
> > GeoStub stub = new GeoStub("
> > http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
> > LfmType response = stub.getEvents(apiKey, location);
> >
> > Would it be possible to generate a friendly interface like this?
> >
> >
> > Kind regards,
> >
> > Arnout
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>
> --
> warm regards,
> Rahul Devgan
> Cell: +61-412163412
> --- there is no pleasure in life like music ---
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Friendly API for calling a RESTful webservice
Posted by Rahul Devgan <rd...@gmail.com>.
Not sure what you are looking for exactly but have you tried www.restlet.org.
Also, I am implementing RESTful WS for a major project but its all hand
written Servlet based code.
On Tue, Aug 26, 2008 at 8:26 PM, Arnout Engelen <ar...@bzzt.net> wrote:
> Hi,
>
> I'm trying to generate some friendly client code for accessing a
> REST-ish webservice.
>
> To that end, I wrote a WSDL2.0 description of the webservice, containing
> the following operation:
>
> <wsdl:operation name="getEvents"
> pattern="http://www.w3.org/ns/wsdl/in-out"
> style="http://www.w3.org/ns/wsdl/style/iri"
> wsdlx:safe="true">
> <wsdl:input element="lastfmgeo:getEventsRequest"/>
> <wsdl:output element="lastfmgeo:lfm"/>
> </wsdl:operation>
>
> The request type is defined as follows:
>
> <xs:element name="getEventsRequest" type="tns:getEventsRequestType">
> <xs:annotation>
> <xs:documentation>
> The request element for the getEvents service.
> </xs:documentation>
> </xs:annotation>
> </xs:element>
>
> <complexType name="getEventsRequestType">
> <sequence>
> <element name="api_key" type="string" minOccurs="1" maxOccurs="1"/>
> <element name="location" type="string" minOccurs="0" maxOccurs="1"/>
> </sequence>
> </complexType>
>
> I called wsdl2code on this (adb bindings), which generated a GeoStub. This
> already works, like this:
>
> GeoStub stub = new GeoStub("
> http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
>
> GetEventsRequestType request = new
> GetEventsRequestType();
> request.setApi_key(apiKey);
> request.setLocation(location);
>
> GetEventsRequest requestDoc = new
> GetEventsRequest();
> requestDoc.setGetEventsRequest(request);
> LfmType response =
> stub.getEvents(requestDoc).getLfm();
>
> However, it would of course be much nicer if it could look something like
> this:
>
> GeoStub stub = new GeoStub("
> http://ws.audioscrobbler.com/2.0/?method=geo.getevents");
> LfmType response = stub.getEvents(apiKey, location);
>
> Would it be possible to generate a friendly interface like this?
>
>
> Kind regards,
>
> Arnout
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
--
warm regards,
Rahul Devgan
Cell: +61-412163412
--- there is no pleasure in life like music ---