留言板

Integrate or Call External Web Services in Liferay

thumbnail
Helder Jossias,修改在9 年前。

Integrate or Call External Web Services in Liferay

New Member 帖子: 7 加入日期: 14-11-11 最近的帖子
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,修改在9 年前。

RE: Integrate or Call External Web Services in Liferay

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
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,修改在9 年前。

RE: Integrate or Call External Web Services in Liferay

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
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,修改在6 年前。

RE: Integrate or Call External Web Services in Liferay

Junior Member 帖子: 74 加入日期: 17-4-6 最近的帖子
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,修改在6 年前。

RE: Integrate or Call External Web Services in Liferay

Regular Member 帖子: 153 加入日期: 08-11-25 最近的帖子
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