AppEngine 上的反向代理 (restlet 2.1):404 - 缺少客户端协议

发布于 2024-12-11 17:23:37 字数 4286 浏览 0 评论 0原文

尝试让 Restlet 在 AppEngine 上用作第 3 方 json/xml 服务的反向代理。

  • AppEngine 版本 1.5.5
  • Restlet GAE 版本 2.1RC1

我在 web.xml 中设置 Restlet,如下所示:

<servlet>
<servlet-name>​RestletServlet</s​ervlet-name>
<servlet-class​>org.restlet.ext.ser​vlet.ServerServlet​</servlet-class>​
 <init-param>
   <param-name>or​g.restlet.applicatio​n</param-name>​
   <param-value>b​e.koma.server.MyAppl​ication</param-va​lue>
 </init-param>
</servlet>
<servlet-mapping>
 <servlet-name>​RestletServlet</s​ervlet-name>
 <url-pattern>/​api/*</url-patter​n>
</servlet-mapping>

我将以下 jar 添加到 WEB-INF/lib,GAE 版本 2.1RC1

org.json.jar
org.restlet.ext.crypto.jar
org.restlet.ext.gae.jar
org.restlet.ext.gwt.jar
org.restlet.ext.jackson.jar
org.restlet.ext.json.jar
org.restlet.ext.net.jar
org.restlet.ext.servlet.jar
org.restlet.ext.xml.jar
org.restlet.jar

这是 be.koma.server.MyApplication 的实现;

public class MyApplication extends Application {

    @Override
    public Restlet createInboundRoot() {

        Router router = new Router(getContext());

        String target = "http://otherservice.​com/users.xml";
        Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_SERV​ER_OUTBOUND);
        router.setDefaultMat​chingMode(Router.MOD​E_FIRST_MATCH);

        getConnectorService(​).getClientProtocols​().add(Protocol.HTTP​);

        router.attachDefault​(redirector);

        return router;
    }
}

从我的浏览器或curl 调用 otherservice.com 效果很好。

然而,当我调用 Restlet 时,我收到 404,因为找不到客户端协议?

Oct 24, 2011 9:36:22 AM org.restlet.engine.l​og.LogFilter beforeHandle
FINE: Processing request to: "http://127.0.1.1:888​8/api/otherservice/u​sers.xml"
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.HostRoute score
FINER: Call score for the "org.restlet.routing​.VirtualHost@e3e496a​" host: 1.0
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.ServerRoute​r logRoute
FINE: Default virtual host selected
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.HostRoute beforeHandle
FINE: Base URI: "http://127.0.1.1:8888". Remaining part: "/api/otherservice/users.xml"
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute score
FINER: Call score for the "/api" URI pattern: 0.5909091
Oct 24, 2011 9:36:22 AM org.restlet.routing.Router logRoute
FINE: Selected route: "/api" -> be.koma.server.MyApp​lication@668b1967
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINER: 4 characters were matched
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINE: New base URI: "http://127.0.1.1:8888/api". New remaining part: "/otherservice/users.xml"
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINER: Delegating the call to the target Restlet
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute score
FINER: Call score for the "" URI pattern: 0.5
Oct 24, 2011 9:36:22 AM org.restlet.routing.Router logRoute
FINE: The default route was selected
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINER: No characters were matched
Oct 24, 2011 9:36:22 AM org.restlet.routing.Redirector handle
INFO: Redirecting via client dispatcher to: http://otherservice.​com/users.xml
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.ClientRoute​ score
FINER: Call score for the "[WAR]" client: 0.0
Oct 24, 2011 9:36:22 AM org.restlet.routing.Router logRoute
FINE: The default route was selected
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.ClientRoute​r getNext
WARNING: The protocol used by this request is not declared in the list of client connectors. (HTTP/1.1)
Oct 24, 2011 9:36:22 AM org.restlet.engine.l​og.LogFilter afterHandle
INFO: 2011-10-24    07:36:22    127.0.0.1       127.0.1.1   8888    GET /api/otherservice/users.xml -   404 439 0   28  http://127.0.1.1:8888   Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.10 Chromium/14.0.835.202 Chrome/14.0.835.202 Safari/535.1   http://127.0.1.1:888​8/test.html?gwt.code​svr=127.0.1.1:9997

有什么想法吗? 有关如何调试的建议? 我错过了什么洞察力,这看起来如此微不足道?

Trying to get Restlet going on AppEngine to use as a reverse proxy for a 3rd party json/xml service.

  • AppEngine version 1.5.5
  • Restlet GAE edition 2.1RC1

I setup Restlet in my web.xml like this :

<servlet>
<servlet-name>​RestletServlet</s​ervlet-name>
<servlet-class​>org.restlet.ext.ser​vlet.ServerServlet​</servlet-class>​
 <init-param>
   <param-name>or​g.restlet.applicatio​n</param-name>​
   <param-value>b​e.koma.server.MyAppl​ication</param-va​lue>
 </init-param>
</servlet>
<servlet-mapping>
 <servlet-name>​RestletServlet</s​ervlet-name>
 <url-pattern>/​api/*</url-patter​n>
</servlet-mapping>

I added the following jars to WEB-INF/lib, GAE version 2.1RC1

org.json.jar
org.restlet.ext.crypto.jar
org.restlet.ext.gae.jar
org.restlet.ext.gwt.jar
org.restlet.ext.jackson.jar
org.restlet.ext.json.jar
org.restlet.ext.net.jar
org.restlet.ext.servlet.jar
org.restlet.ext.xml.jar
org.restlet.jar

This is the implementation for be.koma.server.MyApplication ;

public class MyApplication extends Application {

    @Override
    public Restlet createInboundRoot() {

        Router router = new Router(getContext());

        String target = "http://otherservice.​com/users.xml";
        Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_SERV​ER_OUTBOUND);
        router.setDefaultMat​chingMode(Router.MOD​E_FIRST_MATCH);

        getConnectorService(​).getClientProtocols​().add(Protocol.HTTP​);

        router.attachDefault​(redirector);

        return router;
    }
}

Calling otherservice.com from my browser or curl works fine.

When I call the Restlet however, I get 404 because the client protocol cannot be found ??

Oct 24, 2011 9:36:22 AM org.restlet.engine.l​og.LogFilter beforeHandle
FINE: Processing request to: "http://127.0.1.1:888​8/api/otherservice/u​sers.xml"
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.HostRoute score
FINER: Call score for the "org.restlet.routing​.VirtualHost@e3e496a​" host: 1.0
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.ServerRoute​r logRoute
FINE: Default virtual host selected
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.HostRoute beforeHandle
FINE: Base URI: "http://127.0.1.1:8888". Remaining part: "/api/otherservice/users.xml"
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute score
FINER: Call score for the "/api" URI pattern: 0.5909091
Oct 24, 2011 9:36:22 AM org.restlet.routing.Router logRoute
FINE: Selected route: "/api" -> be.koma.server.MyApp​lication@668b1967
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINER: 4 characters were matched
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINE: New base URI: "http://127.0.1.1:8888/api". New remaining part: "/otherservice/users.xml"
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINER: Delegating the call to the target Restlet
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute score
FINER: Call score for the "" URI pattern: 0.5
Oct 24, 2011 9:36:22 AM org.restlet.routing.Router logRoute
FINE: The default route was selected
Oct 24, 2011 9:36:22 AM org.restlet.routing.​TemplateRoute beforeHandle
FINER: No characters were matched
Oct 24, 2011 9:36:22 AM org.restlet.routing.Redirector handle
INFO: Redirecting via client dispatcher to: http://otherservice.​com/users.xml
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.ClientRoute​ score
FINER: Call score for the "[WAR]" client: 0.0
Oct 24, 2011 9:36:22 AM org.restlet.routing.Router logRoute
FINE: The default route was selected
Oct 24, 2011 9:36:22 AM org.restlet.engine.c​omponent.ClientRoute​r getNext
WARNING: The protocol used by this request is not declared in the list of client connectors. (HTTP/1.1)
Oct 24, 2011 9:36:22 AM org.restlet.engine.l​og.LogFilter afterHandle
INFO: 2011-10-24    07:36:22    127.0.0.1       127.0.1.1   8888    GET /api/otherservice/users.xml -   404 439 0   28  http://127.0.1.1:8888   Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.10 Chromium/14.0.835.202 Chrome/14.0.835.202 Safari/535.1   http://127.0.1.1:888​8/test.html?gwt.code​svr=127.0.1.1:9997

Any idea ?
Advice on howto debug ?
What insight am I missing, this seems so trivial ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许一世地老天荒 2024-12-18 17:23:37

感谢 Restlet 邮件列表上的 Jerome,额外的初始化参数解决了问题:

<servlet>
    <servlet-name>RestletServlet</servlet-name>
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
        <param-name>org.restlet.application</param-name>
        <param-value>b​e.koma.server.MyAppl​ication</param-value>
    </init-param>
    <init-param>
        <param-name>org.restlet.clients</param-name>
        <param-value>HTTP HTTPS</param-value>
    </init-param>
</servlet>

更多信息
http://www.restlet.org /documentation/snapshot/gae/ext/org/restlet/ext/servlet/ServerServlet.html

Thx to Jerome on the Restlet mailing list, extra init parameters solve the problem :

<servlet>
    <servlet-name>RestletServlet</servlet-name>
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
        <param-name>org.restlet.application</param-name>
        <param-value>b​e.koma.server.MyAppl​ication</param-value>
    </init-param>
    <init-param>
        <param-name>org.restlet.clients</param-name>
        <param-value>HTTP HTTPS</param-value>
    </init-param>
</servlet>

More info
http://www.restlet.org/documentation/snapshot/gae/ext/org/restlet/ext/servlet/ServerServlet.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文