Foros de discusión

How to consume Restful Web services response in Liferay 6.1

ramakanth reddy, modificado hace 10 años.

How to consume Restful Web services response in Liferay 6.1

Junior Member Mensajes: 27 Fecha de incorporación: 17/04/13 Mensajes recientes
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&#x3a;&#x2f;&#x2f;localhost&#x3a;8080" rel="canonical" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;ar" hreflang="ar-SA" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;eu" hreflang="eu-ES" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;bg" hreflang="bg-BG" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;ca" hreflang="ca-AD" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;ca_ES" hreflang="ca-ES" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;zh" hreflang="zh-CN" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;zh_TW" hreflang="zh-TW" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;hr" hreflang="hr-HR" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;cs" hreflang="cs-CZ" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;da" hreflang="da-DK" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;nl" hreflang="nl-NL" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;nl_BE" hreflang="nl-BE" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;en_GB" hreflang="en-GB" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;et" hreflang="et-EE" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;fi" hreflang="fi-FI" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;fr" hreflang="fr-FR" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;gl" hreflang="gl-ES" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;de" hreflang="de-DE" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;el" hreflang="el-GR" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;iw" hreflang="iw-IL" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;hi" hreflang="hi-IN" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;hu" hreflang="hu-HU" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;in" hreflang="in-ID" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;it" hreflang="it-IT" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;ja" hreflang="ja-JP" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;ko" hreflang="ko-KR" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;lo" hreflang="lo-LA" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;nb" hreflang="nb-NO" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;fa" hreflang="fa-IR" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;pl" hreflang="pl-PL" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;pt" hreflang="pt-BR" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;pt_PT" hreflang="pt-PT" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;ro" hreflang="ro-RO" rel="alternate" />
<link href="http&#x3a;&#x2f;&#x2f;localhost&#x3a;8080&#x2f;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
thumbnail
Kan Zhang, modificado hace 10 años.

RE: How to consume Restful Web services response in Liferay 6.1

Junior Member Mensajes: 68 Fecha de incorporación: 1/12/10 Mensajes recientes
What do you get when you use the browser to access the URL: http://localhost:8080/RestFulRulesPOC1/provider/ruleInvoker/sampleRule/M