users@jersey.java.net

Re: [Jersey] [RFC/RFH] Generating WADL and using it with client

From: Imran M Yousuf <imran_at_smartitengineering.com>
Date: Mon, 25 Aug 2008 20:09:02 +0600

Firstly before going into the email thanks a lot for the informative reply :).

On Mon, Aug 25, 2008 at 5:43 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Imran M Yousuf wrote:
>>
>> Hi,
>>
>> I am fairly new to RESTful WS in terms of using it and as steps of
>> learning it I am interested in generating WADL and using it for
>> generating client stubs. Following the generate-wadl sample I
>> succeeded in producing the wadl file :) but I am not sure whether its
>> content are appropriate or not.
>
> I do not see any element attribute on the representation referencing an
> element in the schema. This requires you reference it as follows:
>
> @request.representation.qname {http://www.example.com}item
>

Ah thats what the doclet attribute is for :), I was trying to get hold
of an document of why this was required :) so just deleted it. Thanks
for pointer, will work on it.

BTW, is there any document on what other doclet attributes are available?

Also I am generating the XSD from the from the JAXB annotated
entities, I will have to find a way to supply it with a URI, I wish
the documentation was better for the schemagen plugin. I am also
adding the plugin config just in case someone knows how to add the URI
info.

<!-- Generate XSD from entities -->
            <plugin>
                <groupId>com.sun.tools.jxc.maven2</groupId>
                <artifactId>maven-jaxb-schemagen-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <srcdir>../RestResource/src/main/</srcdir>
                    <destdir>${project.build.outputDirectory}/</destdir>
                    <includes>
                        <include>**/BooksResource.java</include>
                        <include>**/BookResource.java</include>
                    </includes>
                    <verbose>true</verbose>
                </configuration>
            </plugin>

>
>> Additionally the schema file seemed to
>> referred to from the wadl rather than including its content.
>>
>
> Yes, we either need to include the XSD or make sure it can be referenced
> relative to the base URI. BTW if you generate the application.html it does
> have XSD embedded but it is making use of xsltproc.

I am not making use of xsltproc instead I am using the
xml-maven-plugin. I am using the following configuration for the
transformation. Shouldn't the output be same?

<!-- xml-maven-plugin -->
           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xml-maven-plugin</artifactId>
                <version>1.0-beta-2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>transform</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <transformationSets>
                        <transformationSet>
                            <dir>${project.build.outputDirectory}/</dir>
                            <outputDir>${basedir}/target/html/</outputDir>

<stylesheet>${basedir}/src/main/doc/wadl_documentation.xsl</stylesheet>
                            <includes>
                                <include>**/*.wadl</include>
                            </includes>
                        </transformationSet>
                    </transformationSets>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.saxon</groupId>
                        <artifactId>saxon</artifactId>
                        <version>8.7</version>
                    </dependency>
                </dependencies>
            </plugin>

<!-- For renaming the file to .html extension -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <echo message="Rename application.wadl
to application.html"/>
                                <move
file="${basedir}/target/html/application.wadl"
tofile="${basedir}/target/html/application.html"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
>
> Could you log an issue?
>
>
>> Firstly, I would be grateful if someone could please confirm whether
>> their content is okey or not.
>>
>> Then I tried to create client stub from the WADL file in NetBeans
>> WebApplication project. But inspecting the JavaScript it shows that it
>> did could initialize the location but it did not read the resources
>> from the WADL. Is this normal?
>
> I do not know, i will forward this email to the tooling guys.
>

Thanks a lot, I hope we get a positive reply on it.

>
>> I was under the impression it would
>> also create operations for the resources as well. Can someone point me
>> to a ANT or Maven plugin to generate the client stubs for Java or JS?
>>
>
> See http://wadl.dev.java.net
>
>
>> I would also be grateful if someone would be kind enough to point me
>> to an example or sample on how to use the Jersey Client API.
>>
>
> http://blogs.sun.com/sandoz/entry/ehcache_using_jersey
> http://blogs.sun.com/sandoz/entry/jersey_client_api
> http://blogs.sun.com/sandoz/entry/jersey_client_api
>

Thanks a million, now I get read them :).

- Imran

> Paul.
>
> --
> | ? + ? = To question
> ----------------\
> Paul Sandoz
> x38109
> +33-4-76188109
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
Imran M Yousuf
Email: imran_at_smartitengineering.com
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557