在Tomcat应用程序中使用Apache中的应用程序

在Tomcat应用程序中使用Apache中的应用程序,apache,rest,tomcat,Apache,Rest,Tomcat,基本上,我有两个RESTful服务:一个是用Java构建的,使用Tomcat服务器;另一个是用PHP构建的,使用Apache服务器。 有没有办法配置Tomcat的应用程序成为Apache应用程序的消费者 Tomcat的Web服务位于以下地址: http://localhost:8080/myapp1 http://localhost:80/myapp2. Apache的应用程序位于以下地址: http://localhost:8080/myapp1 http://localhost:80/

基本上,我有两个RESTful服务:一个是用Java构建的,使用Tomcat服务器;另一个是用PHP构建的,使用Apache服务器。 有没有办法配置Tomcat的应用程序成为Apache应用程序的消费者

Tomcat的Web服务位于以下地址:

http://localhost:8080/myapp1
http://localhost:80/myapp2.
Apache的应用程序位于以下地址:

http://localhost:8080/myapp1
http://localhost:80/myapp2.
我想要的是在Tomcat one中使用Apache上RESTful服务的响应,类似于Java代码中使用的:

HttpGet httpget = new HttpGet(http://localhost:80/myapp2/items);

目前我收到404未找到。有没有办法做到这一点?还是有其他方式让服务沟通?

忘记发布答案了。我觉得自己太笨了——我的代码有错误。它按预期工作。下面是一个从Tomcat调用Apache服务器的简单示例:

final static String BASE_URL = "http://localhost:80/proiect/";

    private String getResponse(String title) {
        HttpClient httpclient = new DefaultHttpClient();
        String url = (title != null && title.length() > 0) ? BASE_URL + "?title=" + title : BASE_URL;
        HttpGet httpget = new HttpGet(url);
        String response;
        try {
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            response = httpclient.execute(httpget, responseHandler);
            return response;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }
final static String BASE\u URL=”http://localhost:80/proiect/";
私有字符串getResponse(字符串标题){
HttpClient HttpClient=新的DefaultHttpClient();
字符串url=(title!=null&&title.length()>0)?BASE_url+“?title=“+title:BASE_url;
HttpGet HttpGet=新的HttpGet(url);
字符串响应;
试一试{
ResponseHandler ResponseHandler=新BasicResponseHandler();
response=httpclient.execute(httpget,responseHandler);
返回响应;
}捕获(客户端协议例外e){
e、 printStackTrace();
}捕获(IOE异常){
e、 printStackTrace();
}
返回null;
}

Apache httpd是否配置为仅在特定主机名下为VirtualHost提供服务?基于PHP的RESTful应用程序是否配置为在默认VirtualHost下运行?