简体   繁体   中英

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=''

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. 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. I am using MVC pattern so its like I have to call my controller class from the my web-service class's method (verifyService).

If "Controller" means "Portlet" in your case (the Liferay context suggests this) I'd say that your architecture has it wrong. 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.

Consider the portlet world the UI for an application. 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.

To answer your first comment on this post, I'm not sure what you mean with "CMS endpoint". 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. All of Liferay's functionality is available through an 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. Also, a good starting point is this blog article (series)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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