users@jersey.java.net

[Jersey] Re: Changing baseURI when generating WADL

From: Pablo Mendes <pablomendes_at_gmail.com>
Date: Tue, 15 Mar 2011 12:48:05 +0100

Hi all,
I have a Jersey server running in a machine behind a firewall (let's call
the endpoint http://localhost/rest). All incoming requests are taken by the
webserver (http://webserver.example.com/rest) and forwarded to my local ip.
Easy, works like a charm.

Now I want to generate the WADL for this service. When somebody calls
http://webserver.example.com/application.wadl, I want them to see the
external base URI and not the one I'm using to run the service internally.

Currently, it generates:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://research.sun.com/wadl/2006/10">
    <doc xmlns:jersey="http://jersey.dev.java.net/"
jersey:generatedBy="Jersey: 1.5 01/14/2011 12:36 PM"/>
    <resources base="http://localhost/rest/">
        <resource path="/annotate">
            <method name="GET" id="getHTML">
                <request>
                    <param ...
...
</application>

And I would have liked to see:

    <resources base="http://webserver.example.com/rest/">

I thought I had found the answer in the docs when I set the application path
in my resource class.

@ApplicationPath("http://webserver.example.com/rest/")

However that didn't seem to do it. I currently do not have a web.xml and run
the server with:

HttpServer server = HttpServerFactory.create(serverURI, resources);
server.start();

Am I overlooking something very simple here?

Best,
Pablo