Posts

Showing posts with the label client

Generating Stubs(webservices) in Liferay

Generating stubs in liferay , 1. we can generate the stubs in eclipse as         File ---> New ---> Others --->type webservices and select webservices client ---> Paste the WSDL in the service defination and move the slide till to TestClient and click on the "finish" to generate. WSDL can of type below http://localhost:8080/api/axis/Portlet_Blogs_BlogsEntryService?wsdl When i am trying to do in liferay eclipse it is not allowing to generate the stubs. So i am used Plain tomcat to generate the stubs. 2. We can also generate the stubs by ant    Drag and Drop the build.xml in ant    Locate the build-client . Double click on it . It Generate the <portlet-name>-portlet-client.jar file in the docroot/WEB-INF/client folder.      This lib contains the stubs. By Using that stubs we can write the our own implementations.

Accesing the webservices using REST

Here i am trying to delete the blogsEntry. Here is the sample code for the REST based application    String uri = "http://localhost:8080/api/secure/jsonws/blogsentry/delete-entry";      String userName="test@liferay.com";    String password = "test";      Credentials credentials = new UsernamePasswordCredentials(userName, password);      HttpClient client = new HttpClient();    client.getState().setCredentials(AuthScope.ANY, credentials);    client.getParams().setParameter("http.useragent", "Test Client");    client.getParams().setAuthenticationPreemptive(true);        PostMethod postMethod = new PostMethod(uri);    postMethod.addParameter("entryId", "10101") ;      int returnCode = 0;    try {     returnCode = client.executeMethod(postMethod); } catch (IOException...