简体   繁体   English

Java REST接口

[英]Java REST Interface

I have a PHP web application environment. 我有一个PHP Web应用程序环境。 I am using Slim Framework as REST interface for my application. 我正在将Slim Framework用作我的应用程序的REST接口。 My application front-end is written using Backbone.js and jQuery. 我的应用程序前端是使用Backbone.js和jQuery编写的。

There is a utility (.jar file) which when I use command line makes a remote call (I guess this is a Web Service) which returns me the data. 有一个实用程序(.jar文件),当我使用命令行进行远程调用(我想这是一个Web服务)时,该实用程序会向我返回数据。

how do I best incorporate this into my webapplication described on top? 如何最好地将其合并到我上面描述的Web应用程序中?

My application front end will have a Button that should make an AJAX call to the REST Interface and fetch the data as JSON. 我的应用程序前端将有一个Button,该Button应该对REST接口进行AJAX调用,并以JSON形式获取数据。

My approach: PHP-REST interface url is: /api/phprestapi.php exists 我的方法:PHP-REST接口URL是:/api/phprestapi.php存在

Add a JAVA-REST interface at url: /api/javarestapi.java (Perhaps) to separate these two 在URL:/api/javarestapi.java(也许)中添加JAVA-REST接口以分隔这两个

Existing Environment: LAMP Stack on Ubuntu 现有环境:Ubuntu上的LAMP Stack

How do I achieve this? 我该如何实现? What is the kind of effort involved? 所涉及的努力是什么?

Thanks for your pointers 感谢您的指导

If I understand you correctly, you need to be able to return the data being output from the jar into php. 如果我对您的理解正确,则需要能够将jar中输出的数据返回到php中。 If that is the case then you should start looking at the different ways to execute a program from php [1]. 如果真是这样,那么您应该开始研究从php [1]执行程序的不同方法。 exec is probably the most well known. exec可能是最著名的。

If you want further control, I would recommend learning more about the web service being called by the jar and doing the call to the web service in php. 如果您想进一步控制,我建议您进一步了解jar所调用的Web服务,并在php中对Web服务进行调用。 However, this would take a lot more time than the first option above. 但是,这将比上面的第一个选项花费更多的时间。

[1] http://php.net/manual/en/ref.exec.php [1] http://php.net/manual/zh/ref.exec.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM