A lot of people I run into at trainings and on consulting gigs ask this question:
"How do I access Liferay via Web Services?"
Well, there are 2 basic things you need:
1) A way to get the stubs for Liferay Web Services
2) Some sort of client app to access the portal's services
OK. Honestly, here is the easiest thing you can do to get started: Use Eclipse and download the Web Tools Platform (WTP) plugin. You can use the wizard to generate a Web Services client without writing a lick of code!
The 3 main steps:
1) Generate an Axis web service client
2) Call web services via your generated client
3) Use your generated client to access web services from the ext environment
I took most of this from a pretty good slide that Rich Sezov (who is doing a lot of the new Liferay docs) made. This slide is here: Liferay Web Services
Download that and follow the steps there.
In that example we are using a URL for a stock quote web service (non Liferay). This gets you the WSDL file to do the generation from Eclipse WTP. You need the WSDL file to get started with any web services client. If you've got this working, now the question is: "How do I get the WSDL for Liferay Web Services?"
Here is the URL you need for Liferay:
http://" + userIdAsString + ":" + password + "@localhost:8080/tunnel-web/secure/axis/" + serviceName
So for example, to get Organization data, use this URL:
http://2:test@localhost:8080/tunnel-web/secure/axis/Portal_OrganizationService
Look in the database in the User_ table to find an appropriate userId.
It should be as simple as that.
Now...
Another way to achieve the above is to use one of the Liferay samples. If you are a Java developer, download this:
Liferay Portal 4.3.4 Web Services Client
Java Stubs for Liferay Services (SOAP, Spring Remoting).
This will give you the jar files you need to access these services. Use these jar files to create a very simple webapp. So for a Tomcat instance, in your webapps directory, you will have a directory for your app, and in that directory it will have a standard WEB-INF (with a web.xml) and index.jsp. Very standard stuff. In WEB-INF/lib you will place all the jars. Especially important is the portal-client.jar. To access Liferay Organization data for example, you will have something like this in your index.jsp:
<%@ page import="com.liferay.client.portal.model.OrganizationSoap" %>
<%@ page import="com.liferay.client.portal.service.http.OrganizationServiceSoap" %>
<%@ page import="com.liferay.client.portal.service.http.OrganizationServiceSoapServiceLocator" %>
<%@ page import="java.net.URL" %>
<table>
<tr>
<th>Organizational Membership</th>
</tr>
<%
long userId = 0;
try {
userId = Long.parseLong(userIdAsString);
} catch (Exception e) {
e.printStackTrace();
}
OrganizationServiceSoapServiceLocator locator = new OrganizationServiceSoapServiceLocator();
OrganizationServiceSoap soap = locator.getPortal_OrganizationService(_getURL(userIdAsString, "Portal_OrganizationService"));
OrganizationSoap[] organizations = soap.getUserOrganizations(userId);
for (int i = 0; i < organizations.length; i++) {
OrganizationSoap organization = organizations[i];
%>
<tr>
<td><%= organization.getName() %></td>
</tr>
<%
}
%>
</table>
<%!
private URL _getURL(String userIdAsString, String serviceName) throws Exception {
// Unathenticated url
String url = "http://localhost:8080/tunnel-web/axis/" + serviceName;
// Authenticated url
if (true) {
String password = "test";
url = "http://" + userIdAsString + ":" + password + "@localhost:8080/tunnel-web/secure/axis/" + serviceName;
}
return new URL(url);
}
%>
Lastly, but not LEAST!!!
Another example that Liferay provides is here:
sample-portal-client-portlet-4.3.4.1.war
Take a good look at this sample and you will see almost everything you need. I usually am in the habit of telling people to "just look here" but I think it works better with all the above stuff explained first. =)
Hope it works for you and good luck!

