Gérald Quintana wrote:
> Hello,
>
> I tested the WADL generator Ant task. I think it's missing a "base
> url" (optionnal) argument because generated WADL file doesn't contain
> the base attribute in the resources element:
> <resources base="http://www.mycompany.com">
> Hence this WADL file can not be used directly with wadl2java without
> being modified. After that I couldn't use the Java code generated by
> wadl2java (missing library org.jvnet.ws.wadl.util.*) so I abandon this
> solution.
>
Good point. I just committed support for a required "baseUri" attribute,
should be in the latest build.
> I read the article by Steve Vinoski as well: I don't agree with his
> idea that no interface is a good thing, but I don't want to throw a
> troll in this mailing list.
Thats OK, it would be boring if we all agreed :-)
> By the way, I agree that in my case the
> WADL artefact is useless: The only I am looking for, is a way to call
> the web service easily (in Java and/or JavaScript). I don't want to
> write 10 lines of code to build the URL and the HTTP request (with
> Apache HTTP Client or whatever) and then 10 lines of code to decode
> the HTTP response (multiplied by the number of web services).
Right!
> Implementing a web service with JAXRS is as easy as implementing a
> function, calling it should be as easy. I couldn't find among provided
> samples, the one showing a JAXRS client calling a JAXRS service, I may
> have missed it.
>
The client API is currently not exposed as a Jersey API (it will for
version 0.6). See source in the package:
com.sun.ws.rest.impl.client
The place to look for its use is in the unit tests, not the best in
terms of examples....
Here are some concocted one liner examples:
String content = ResourceProxy.create("
http://localhost/resource").
get(String.class);
String content = ResourceProxy.create("
http://localhost/resource").
acceptable("application/xml").get(String.class);
String content = ResourceProxy.create("
http://localhost/resource").
post(String.class, "content");
You can use the same Java types for entities as you can on the server
side. You can also use the URI builder for building up a URI. The
general idea is to try and share as much code as make sense between the
service side and client side.
For 0.6 i am hoping to make some improvements to the client API.
Hope that helps,
Paul.
> Thanks for your work on JAXRS/Jersey,
> Gerald
>
> ----------------------------------------------------------------------------------------------------------------------------------
> FYI, I am attaching the Ant file I used for testing:
> <project default="main" basedir=".">
> <property name="jersey.dir" value="C:\java\jersey-0.5-ea-20080108" />
> <property name="wadl.dir" value="C:\java\wadl-dist-1.0-SNAPSHOT" />
> <path id="project.class.path">
> <pathelement location="build/classes"/>
> <fileset dir="${jersey.dir}/lib" includes="**/*.jar"/>
> <fileset dir="${wadl.dir}/lib" includes="**/*.jar"/>
> </path>
> <target name="java2wadl">
> <taskdef name="wadlgen"
> classname="com.sun.ws.rest.api.wadl.WadlGeneratorTask"
> classpathref="project.class.path"/>
> <wadlgen destfile="IntroJaxRs.wadl" >
> <classpath refid="project.class.path"/>
> </wadlgen>
> </target>
> <target name="wadl2java">
> <mkdir dir="jaxrs"/>
> <java classname="org.jvnet.ws.wadl2java.Main"
> classpathref="project.class.path">
> <arg line="-o jaxrs"/>
> <arg line="-p com.mycompany.myproject"/>
> <arg value=" IntroJaxRs.wadl"/>
> </java>
> <javac classpathref="project.class.path" destdir="build/classes"
> srcdir="jaxrs"/>
> </target>
> <target name="main" depends="java2wadl,wadl2java"/>
> </project>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109