Hello Murilo,

I wonder if you can use the Redirector Restlet instead in "dispatcher" mode => http://www.restlet.org/documentation/1.1/api/org/restlet/Redirector.html
You may need to override the "redirectDispatcher" method.

best regards,
Thierry Boileau


Hi,

I'm using restlet with Mule (www.mulesource.org <http://www.mulesource.org>).

We have a system with 3 layer. A web layer (using Joomla), ESB layer (using Mule+Restlet) and Services layer (using Apache + PHP).

Joomla makes a request through ESB layer to Services layer.

So... I need receive this request, send this to Services and return to Joomla. My mappings is alright and working.

So... We put a Basic Authorization on requests to Joomla access the Services layer through the ESB layer, and my problems started.

I create to classes. A class extends Application and another class extends Resource.

1. public class EsbApplication extends Application {

2.    private static Properties properties = null;

3.    private static Logger logger = Logger.getLogger(EsbApplication.class
            .getName());

4.    @Override
5.    public Restlet createRoot() {
6.        Router router = new Router(getContext());
7.        router.attachDefault(MainResource.class);
8.        return router;
9.    }
10.}

11.public class MainResource extends Resource {
12. @SuppressWarnings("unchecked") 13. public MainResource(Context context, Request request, Response response) {
14.        super(context, request, response);
15.        getVariants().add(new Variant(MediaType.TEXT_XML));
16.    }
17. @Override
18.    public Representation getRepresentation(Variant variant) {
19. String url = EsbApplication.getProperty("services.url") + getRequest().getResourceRef();
20.        // Prepare the request
21.        Request request = new Request(Method.GET, url);

22.        // Handle it using an HTTP client connector
23.        Client client = new Client(Protocol.HTTPS);
24.        Response response = client.handle(request);
25. return response.getEntity();
26.    }
27.}

So I receive a request with basic authorization on Restlet application. But on the line 24 I debug the response object and on status has Unauthorized (401). But when I return (line 25) it send a 200 Ok to the Joomla.

I'm sure I'm doing mistakes. But I'm not know where. I didn't know if this is the better approach to this structure.

I read the tutorial and I think I need mix the 10 and 11 parts to do it.

So... Can someone help me? Or send me some links to clarify my doubts.

Thanks in advance.

Murilo

Reply via email to