Hi all

Let me expose my problem :

I have :
- One ClientA et one serverA hosted on http://localhost:8000
- One serverB on http://localhost:8080

serverB provides some REST services (with REstlet) which will be consumed by 
ClientA

However, due to the Same Origine Policy, I can make Cross Domain requests 
between clientA and serverB. That's why I decided to put a proxy (serverA) 
between clientA and serverB.

What I am trying to do is to use REstlet redirect mecanism to redirect ClientA 
call to server B. For example, when ClientA calls 
http://localhost:8000/rest/catalog/v1/dogs, the call will be redirected to 
http://localhost:8080/rest/catalog/v1/dogs

For this, I have on my serverA the following :

 @Override 
    public Restlet createInboundRoot() { 
        Redirector redirector = new Redirector(getContext(), 
"http://localhost:808​0/rest/catalog/v1{rr​}";, 
Redirector.MODE_SERV​ER_INBOUND); 
        return redirector; 
    } 

I obtain the following trace :

18/07/2012 17:28:27 DEBUG org.restlet - Invalid character detected in URI 
reference at index '37': "{". It will be automatically encoded. 
18/07/2012 17:28:27 INFO  org.restlet - Redirecting via server dispatcher to: 
http://localhost:808​0/rest/catalog/v1/do​gs
18/07/2012 17:28:27 WARN  org.restlet - No next Restlet provided for server 
redirection to http://localhost:808​0/rest/catalog/v1/do​gs
Jul 18, 2012 5:28:27 PM org.apache.catalina.​core.ApplicationCont​ext log 
INFO: A response with a 200 (Ok) status should have an entity. Make sure that 
resource "http://localhost:810​0/rest/catalog/v1/do​gs"; returns one or sets the 
status to 204 (No content). 


On my serverB, I have no trace. Do I suppose that no request was received ?

This is a snippet of my serverB (spring 3 + Restlet2) :

<code>
        <bean id="restletApplication" class="org.restlet.A​pplication">
                <property name="inboundRoot" ref="defaultRouter" />
        </bean>

        <bean id="defaultRouter" class="org.restlet.e​xt.spring.SpringRout​er">
                <property name="attachments">
                        <map>
                                <entry key="/catalog/v1" value-ref="catalog" />
                        </map>
                </property>
        </bean>

        

        <bean id="catalog" class="org.restlet.e​xt.spring.SpringRout​er">
                <property name="attachments">
                        <map>
                                <entry key="/login">
                                        <bean 
class="org.restlet.e​xt.spring.SpringFind​er">
                                                <lookup-method name="create" 
bean="loginRestResource" />
                                        </bean>
                                </entry>
                                <entry key="/dogs">
                                        <bean 
class="org.restlet.e​xt.spring.SpringFind​er">
                                                <lookup-method name="create" 
bean="dogsRestResource" />
                                        </bean>
                                </entry>
                                <entry key="/dogs/{id}">
                                        <bean 
class="org.restlet.e​xt.spring.SpringFind​er">
                                                <lookup-method name="create" 
bean="dogRestResource" />
                                        </bean>
                                </entry>
                                <entry key="/citizens">
                                        <bean 
class="org.restlet.e​xt.spring.SpringFind​er">
                                                <lookup-method name="create" 
bean="citizensRestResource" />
                                        </bean>
                                </entry>
                                <entry key="/citizens/{id}">
                                        <bean 
class="org.restlet.e​xt.spring.SpringFind​er">
                                                <lookup-method name="create" 
bean="citizenRestResource" />
                                        </bean>
                                </entry>
                        </map>
                </property>
        </bean>

</code>

My questions are :
1. Do it make sence what I am trying to do with Restlet, that is to say trying 
to use its redirect mecanism to enable cros domain requests
2. If so, how can I implements this with Restlet ?

Thank you for your answer

Thierry LAU

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2991807

Reply via email to