Hello Pablo,
problem here is that base param in <resources /> elem is generated from
injected UriInfo, BUT you can "reset" it by subclassing
WadlGeneratorImpl and setting this value by yourself. What I did:
set init param "com.sun.jersey.config.property.WadlGeneratorConfig" to
point to my WadlGeneratorConfig (you can set it as servlet init param)
initParams.put("com.sun.jersey.config.property.WadlGeneratorConfig",
"com.sun.jersey.samples.helloworld.MyWadlGeneratorConfig");
And implementation:
package com.sun.jersey.samples.helloworld;
...
public class MyWadlGeneratorConfig extends WadlGeneratorConfig {
@Override
public List<WadlGeneratorDescription> configure() {
return generator(MyWadlGenerator.class).descriptions();
}
}
package com.sun.jersey.samples.helloworld;
...
public class MyWadlGenerator extends WadlGeneratorImpl {
@Override
public Resources createResources() {
Resources resources = super.createResources();
resources.setBase("
http://myBaseUri");
return resources;
}
@Override
public void setWadlGeneratorDelegate(WadlGenerator delegate) {
// nothing
}
}
There might be easier way, but this at least works.. (I'm not very
familiar with wadl generation yet).
I got following response after calling GET
http://localhost:9998/application.wadl:
<?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.6-SNAPSHOT 03/15/2011 10:37 AM"/>
<resources base="
http://myBaseUri">
<resource path="/helloworld">
<method name="GET" id="getClichedMessage">
<response>
<representation mediaType="text/plain"/>
</response>
</method>
</resource>
</resources>
</application>
Hope it helps.
Regards,
Pavel
On 03/15/2011 12:48 PM, Pablo Mendes wrote:
> 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