Fórum

Integrate or Call External Web Services in Liferay

thumbnail
Helder Jossias, modificado 9 Anos atrás.

Integrate or Call External Web Services in Liferay

New Member Postagens: 7 Data de Entrada: 11/11/14 Postagens Recentes
Good Afternoon
Dear Sir's
I am trying to call an external web services using Liferay! but i can't do it, i was looking for related posts there was explained that i have to configure first a portal-ex.properties, and then create a web service client to interact with the web services, i think its all confused. if someone here explain me I'll be grateful. I'm waiting for your reply with some support.

Kindest Regards
thumbnail
David H Nebinger, modificado 9 Anos atrás.

RE: Integrate or Call External Web Services in Liferay

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Helder, you have to keep track of whether you're providing web services or consuming web services.

I'm guessing most of the other forum posts referring to portal-ext.properties was for providing web services.

For calling a web service, you can use axis or axis2 or cxf (etc) if your web service is soap based, if REST I'd use spring's RestTemplate. There's nothing magical about how to invoke a web service within your portlet code, just follow many online examples for building the client code and invoking the web service, then build a portlet around the invocation.
thumbnail
Meera Prince, modificado 9 Anos atrás.

RE: Integrate or Call External Web Services in Liferay

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
Hi
Use http client in the java or use Ajax in the client side to call rest full web services and pass required parameters..
and pass required parameters in the URL so that web services will be called.

Example Code
public void getCountries(ActionRequest actionRequest, ActionResponse res)
	throws IOException, PortletException, PortalException, SystemException, JSONException {
		System.out.println("getCountries");
		 String getURL="https://test.httpapi.com/api/country/list.xml?auth-userid=45334425&api-key=KHEPJeeeerSEobkZnWwrA4p0BWGjXBiMZCly";
		  HttpClient client = new DefaultHttpClient();
			HttpGet request = new HttpGet(getURL.trim());
			HttpResponse response = client.execute(request);
			StringBuffer countriesBuffer = new StringBuffer();
			// Get the response
			BufferedReader brd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
			String lines = "";
			while ((lines = brd.readLine()) != null) {
				countriesBuffer.append(lines);
				System.out.println(lines); 
			} 
		  
		 org.json.JSONObject jsonObject;
		 org.json.JSONObject jsonObject1;
		
			jsonObject = XML.toJSONObject(countriesBuffer.toString());
			 System.out.println(jsonObject);
			 System.out.println(jsonObject.getJSONObject("hashtable"));
			 Map<string,string> countriesMap=new HashMap<string,string>();
			 List<map<string,string>&gt; mapList=new ArrayList<map<string,string>&gt;();
			 org.json.JSONObject responseJosnobject=jsonObject.getJSONObject("hashtable");
			 org.json.JSONArray responseJsonArray=responseJosnobject.getJSONArray("entry");
			 
			 
			 for(int i=0;i<responsejsonarray.length();i++){ countriesmap.put(string.valueof(responsejsonarray.getjsonobject(i).getjsonarray("string").get(0)),string.valueof(responsejsonarray.getjsonobject(i).getjsonarray("string").get(1))); maplist.add(hasmap); system.out.println(responsejsonarray.getjsonobject(i).getjsonarray("string").get(0)); system.out.println(responsejsonarray.getjsonobject(i).getjsonarray("string").get(1)); } actionrequest.getportletsession().setattribute("countriesmap", countriesmap); portalutil.copyrequestparameters(actionrequest,res); }< code></responsejsonarray.length();i++){></map<string,string></map<string,string></string,string></string,string>
<br><br>follow the link it will give idea<br><a href="http://www.liferaysavvy.com/2014/05/consuming-liferay-json-web-services.html">http://www.liferaysavvy.com/2014/05/consuming-liferay-json-web-services.html</a><br><br><a href="http://www.liferaysavvy.com/2012/11/java-client-to-consuming-liferay-json.html">http://www.liferaysavvy.com/2012/11/java-client-to-consuming-liferay-json.html</a><br><br>If it SOAP based web serviced then we need to get client jar file into our application and call methods as for client soap api<br><br>Regards,<br>Meera Prince
Harsh Kanakhara, modificado 6 Anos atrás.

RE: Integrate or Call External Web Services in Liferay

Junior Member Postagens: 74 Data de Entrada: 06/04/17 Postagens Recentes
Hi Meera,

I like to consume .NET web services implemented using SOAP in Liferay DXP. Can you please guide me how to build it ?

Regards,
Harsh Kanakhara.
thumbnail
Manish Kumar Jaiswal, modificado 6 Anos atrás.

RE: Integrate or Call External Web Services in Liferay

Regular Member Postagens: 153 Data de Entrada: 25/11/08 Postagens Recentes
Harsh Kanakhara:
Hi Meera,

I like to consume .NET web services implemented using SOAP in Liferay DXP. Can you please guide me how to build it ?

Regards,
Harsh Kanakhara.



Hi Harsh,

were you able to consume SOAP service in DXP?

It would be great if you can share any sample module on the same.

Regards
Manish