简体   繁体   English

当第三方客户致电我的网络服务时致电控制器

[英]Call Controller when third party client call my web-service

I have web-service exposed at my side and I'm able to get it called when some one hit the URL like 我的网络服务暴露在我的身边,当有人点击该网址时,我可以调用它

curl http://localhost:8080/api/jsonws/XXXXX-Portlets.foo/verify-service \

-u test@liferay.com:test \\ -d action='' -u test@liferay.com:test \\ -d操作=''

Here verifyService(String action) is my method in class now when some one hit this service with curl I'm just taking the example of curl. 在这里,verifyService(String action)是我在类中的方法,当有人用curl击中该服务时,我仅以curl为例。 You can also call this service like below as well, 您也可以像下面这样调用此服务,

http://localhost:8080/api/jsonws/XXXXX-Portlets.foo/verify-service/action/{valueOfparameter}

Now this service hit by third party client and what I want to achieve is when some one call this web service I want to update my jsp with that parameter or want to call my controller. 现在,该服务受到第三方客户端的青睐,我想要实现的是当有人调用此Web服务时,我想用该参数更新jsp或要调用我的控制器。 I am using MVC pattern so its like I have to call my controller class from the my web-service class's method (verifyService). 我正在使用MVC模式,因此就像必须从Web服务类的方法(verifyService)调用控制器类一样。

If "Controller" means "Portlet" in your case (the Liferay context suggests this) I'd say that your architecture has it wrong. 如果在您的情况下“ Controller”的意思是“ Portlet”(Liferay上下文表明了这一点),我会说您的体系结构有问题。 Move the code that you need to call to a service and it'll be natural to call it. 将您需要调用的代码移动到服务上,这很自然。 Have the portlet as well as the service call the same service with your reusable code. 使Portlet和服务使用您的可重用代码调用相同的服务。

Consider the portlet world the UI for an application. 考虑Portlet世界中应用程序的UI。 You wouldn't call UI layer code from your business (or service) layer - whose UI would you call, especially on a webserver where there are potentially huge numbers of concurrent users. 您不会从业务(或服务)层调用UI层代码-您将调用其UI,尤其是在潜在存在大量并发用户的Web服务器上。

To answer your first comment on this post, I'm not sure what you mean with "CMS endpoint". 要回答您对此信息的第一条评论,我不确定您对“ CMS端点”的含义。 Liferay's API is available, for historical reasons the CMS interfaces' names start with "Journal", so you can actually create or read articles from your own services by delegating to JournalArticleService etc. This gives you access to the content side, there are also a lot of different APIs for changing/creating pages, adding content to the pages etc. - no need to go through a portlet. Liferay的API可用,由于历史原因,CMS接口的名称以“ Journal”开头,因此您可以通过委托JournalArticleService等从您自己的服务中实际创建或阅读文章。这使您可以访问内容侧,还有一个用于更改/创建页面,向页面添加内容等的许多不同的API。-无需通过Portlet。 All of Liferay's functionality is available through an API. Liferay的所有功能都可以通过API获得。 How much you need and which one is probably too much to answer in a single stackoverflow answer - check https://dev.liferay.com for some chapters on accessing Liferay's API. 在单个stackoverflow答案中,您需要多少资源以及可能太多了-请访问https://dev.liferay.com ,以获取有关访问Liferay API的某些章节。 Also, a good starting point is this blog article (series) 另外, 此博客文章(系列)也是一个很好的起点。

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

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