留言板
How to consume Restful Web services response in Liferay 6.1
ramakanth reddy,修改在10 年前。
How to consume Restful Web services response in Liferay 6.1
Junior Member 帖子: 27 加入日期: 13-4-17 最近的帖子
Hi All
I am trying to get response from Restful Web service in portlet do view method as follows:
@Override
public void doView(RenderRequest renderRequest,
RenderResponse renderResponse) throws IOException, PortletException {
System.out.println("Executing doVIew");
ClientRequest clientRequest=new ClientRequest("http://localhost:8080/RestFulRulesPOC1/provider/ruleInvoker/sampleRule/M");
clientRequest.accept(MediaType.APPLICATION_JSON);
try {
ClientResponse<Response> clientResponse = clientRequest.get(Response.class);
System.out.println("Output IS: "+ clientResponse.getEntity(String.class) );
} catch (Exception e) {
e.printStackTrace();
}
super.doView(renderRequest, renderResponse);
}
But it returns a response as follows(Attaching a part of response as it is too huge):
<!DOCTYPE html>
<html class="ltr" dir="ltr" lang="en-US">
<head>
<title>Status - Liferay</title>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<link href="http://localhost:8080/html/themes/classic/images/favicon.ico" rel="Shortcut Icon" />
<link href="http://localhost:8080" rel="canonical" />
<link href="http://localhost:8080/ar" hreflang="ar-SA" rel="alternate" />
<link href="http://localhost:8080/eu" hreflang="eu-ES" rel="alternate" />
<link href="http://localhost:8080/bg" hreflang="bg-BG" rel="alternate" />
<link href="http://localhost:8080/ca" hreflang="ca-AD" rel="alternate" />
<link href="http://localhost:8080/ca_ES" hreflang="ca-ES" rel="alternate" />
<link href="http://localhost:8080/zh" hreflang="zh-CN" rel="alternate" />
<link href="http://localhost:8080/zh_TW" hreflang="zh-TW" rel="alternate" />
<link href="http://localhost:8080/hr" hreflang="hr-HR" rel="alternate" />
<link href="http://localhost:8080/cs" hreflang="cs-CZ" rel="alternate" />
<link href="http://localhost:8080/da" hreflang="da-DK" rel="alternate" />
<link href="http://localhost:8080/nl" hreflang="nl-NL" rel="alternate" />
<link href="http://localhost:8080/nl_BE" hreflang="nl-BE" rel="alternate" />
<link href="http://localhost:8080/en_GB" hreflang="en-GB" rel="alternate" />
<link href="http://localhost:8080/et" hreflang="et-EE" rel="alternate" />
<link href="http://localhost:8080/fi" hreflang="fi-FI" rel="alternate" />
<link href="http://localhost:8080/fr" hreflang="fr-FR" rel="alternate" />
<link href="http://localhost:8080/gl" hreflang="gl-ES" rel="alternate" />
<link href="http://localhost:8080/de" hreflang="de-DE" rel="alternate" />
<link href="http://localhost:8080/el" hreflang="el-GR" rel="alternate" />
<link href="http://localhost:8080/iw" hreflang="iw-IL" rel="alternate" />
<link href="http://localhost:8080/hi" hreflang="hi-IN" rel="alternate" />
<link href="http://localhost:8080/hu" hreflang="hu-HU" rel="alternate" />
<link href="http://localhost:8080/in" hreflang="in-ID" rel="alternate" />
<link href="http://localhost:8080/it" hreflang="it-IT" rel="alternate" />
<link href="http://localhost:8080/ja" hreflang="ja-JP" rel="alternate" />
<link href="http://localhost:8080/ko" hreflang="ko-KR" rel="alternate" />
<link href="http://localhost:8080/lo" hreflang="lo-LA" rel="alternate" />
<link href="http://localhost:8080/nb" hreflang="nb-NO" rel="alternate" />
<link href="http://localhost:8080/fa" hreflang="fa-IR" rel="alternate" />
<link href="http://localhost:8080/pl" hreflang="pl-PL" rel="alternate" />
<link href="http://localhost:8080/pt" hreflang="pt-BR" rel="alternate" />
<link href="http://localhost:8080/pt_PT" hreflang="pt-PT" rel="alternate" />
<link href="http://localhost:8080/ro" hreflang="ro-RO" rel="alternate" />
<link href="http://localhost:8080/ru" hreflang="ru-RU" rel="alternate" />
and so on..
Please help me out how to make restful web services call in Liferay 6.1
Thanks,
Ramakanth
I am trying to get response from Restful Web service in portlet do view method as follows:
@Override
public void doView(RenderRequest renderRequest,
RenderResponse renderResponse) throws IOException, PortletException {
System.out.println("Executing doVIew");
ClientRequest clientRequest=new ClientRequest("http://localhost:8080/RestFulRulesPOC1/provider/ruleInvoker/sampleRule/M");
clientRequest.accept(MediaType.APPLICATION_JSON);
try {
ClientResponse<Response> clientResponse = clientRequest.get(Response.class);
System.out.println("Output IS: "+ clientResponse.getEntity(String.class) );
} catch (Exception e) {
e.printStackTrace();
}
super.doView(renderRequest, renderResponse);
}
But it returns a response as follows(Attaching a part of response as it is too huge):
<!DOCTYPE html>
<html class="ltr" dir="ltr" lang="en-US">
<head>
<title>Status - Liferay</title>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<link href="http://localhost:8080/html/themes/classic/images/favicon.ico" rel="Shortcut Icon" />
<link href="http://localhost:8080" rel="canonical" />
<link href="http://localhost:8080/ar" hreflang="ar-SA" rel="alternate" />
<link href="http://localhost:8080/eu" hreflang="eu-ES" rel="alternate" />
<link href="http://localhost:8080/bg" hreflang="bg-BG" rel="alternate" />
<link href="http://localhost:8080/ca" hreflang="ca-AD" rel="alternate" />
<link href="http://localhost:8080/ca_ES" hreflang="ca-ES" rel="alternate" />
<link href="http://localhost:8080/zh" hreflang="zh-CN" rel="alternate" />
<link href="http://localhost:8080/zh_TW" hreflang="zh-TW" rel="alternate" />
<link href="http://localhost:8080/hr" hreflang="hr-HR" rel="alternate" />
<link href="http://localhost:8080/cs" hreflang="cs-CZ" rel="alternate" />
<link href="http://localhost:8080/da" hreflang="da-DK" rel="alternate" />
<link href="http://localhost:8080/nl" hreflang="nl-NL" rel="alternate" />
<link href="http://localhost:8080/nl_BE" hreflang="nl-BE" rel="alternate" />
<link href="http://localhost:8080/en_GB" hreflang="en-GB" rel="alternate" />
<link href="http://localhost:8080/et" hreflang="et-EE" rel="alternate" />
<link href="http://localhost:8080/fi" hreflang="fi-FI" rel="alternate" />
<link href="http://localhost:8080/fr" hreflang="fr-FR" rel="alternate" />
<link href="http://localhost:8080/gl" hreflang="gl-ES" rel="alternate" />
<link href="http://localhost:8080/de" hreflang="de-DE" rel="alternate" />
<link href="http://localhost:8080/el" hreflang="el-GR" rel="alternate" />
<link href="http://localhost:8080/iw" hreflang="iw-IL" rel="alternate" />
<link href="http://localhost:8080/hi" hreflang="hi-IN" rel="alternate" />
<link href="http://localhost:8080/hu" hreflang="hu-HU" rel="alternate" />
<link href="http://localhost:8080/in" hreflang="in-ID" rel="alternate" />
<link href="http://localhost:8080/it" hreflang="it-IT" rel="alternate" />
<link href="http://localhost:8080/ja" hreflang="ja-JP" rel="alternate" />
<link href="http://localhost:8080/ko" hreflang="ko-KR" rel="alternate" />
<link href="http://localhost:8080/lo" hreflang="lo-LA" rel="alternate" />
<link href="http://localhost:8080/nb" hreflang="nb-NO" rel="alternate" />
<link href="http://localhost:8080/fa" hreflang="fa-IR" rel="alternate" />
<link href="http://localhost:8080/pl" hreflang="pl-PL" rel="alternate" />
<link href="http://localhost:8080/pt" hreflang="pt-BR" rel="alternate" />
<link href="http://localhost:8080/pt_PT" hreflang="pt-PT" rel="alternate" />
<link href="http://localhost:8080/ro" hreflang="ro-RO" rel="alternate" />
<link href="http://localhost:8080/ru" hreflang="ru-RU" rel="alternate" />
and so on..
Please help me out how to make restful web services call in Liferay 6.1
Thanks,
Ramakanth
Kan Zhang,修改在10 年前。
RE: How to consume Restful Web services response in Liferay 6.1
Junior Member 帖子: 68 加入日期: 10-12-1 最近的帖子
What do you get when you use the browser to access the URL: http://localhost:8080/RestFulRulesPOC1/provider/ruleInvoker/sampleRule/M