Powered By Blogger

Tuesday, May 24, 2011

Using Liferay WebServices

The wsdl url we can get it from
http://127.0.0.1:8080/tunnel-web/secure/axis/Portal_UserService?wsdl

by using the above url we can generate the skeleton classes in the eclipse.


The client code to access the url is as below


/**
*
*/
package com.cignex.test;

import java.net.URL;

import com.liferay.portal.model.UserSoap;
import com.liferay.portal.service.http.UserServiceSoap;
import com.liferay.portal.service.http.UserServiceSoapServiceLocator;

/**
* @author basanagowda.patil
*
*/
public class LiferayUserServiceClient {

/**
* @param args
*/
public static void main(String[] args) {
try {
UserServiceSoapServiceLocator locatorUser = new UserServiceSoapServiceLocator();
UserServiceSoap soapUser = locatorUser.getPortal_UserService(new URL("http://test:test@127.0.0.1:8080/tunnel-web/secure/axis/Portal_UserService"));

//http://abc:abc@127.0.0.1:8080/tunnel-web/secure/axis/Portal_UserService

if(null!=soapUser){
System.out.println("Inside soapUser not null*********");
UserSoap soapUserModel = soapUser.getUserById(10134);
System.out.println(" getEmailAddress:" + soapUserModel.getEmailAddress());

}

} catch (Exception e) {
e.printStackTrace();
}
}

}

2 comments:

  1. Hi Basu ! very impressive post..thnx.

    my manager had given me two tasks in Liferay portlet:

    1. to connect with mysql database in which the data entered by the user in liferay should persist in db.

    2. to consume a webservice from the portlet.

    fortunately got succeeded in the 1st part.
    but second part still remaining buddy.

    plz help me in this. if u can provide me step by step procedure to consume the wbservice..plz.

    also i am in bangalore only. if u can give me ur no. or catch up with me smtimes, it wud gr8 gesture from ur side.

    thnx and waiting for ur reply...

    ReplyDelete
  2. Hi....when i am enetring this in the address bar...http://127.0.0.1:8080/tunnel-web/secure/axis/Portal_UserService?wsdl....
    it is asking for username and password....what is this??

    ok what i am doing in the eclipse IDE is ---> i am creating a "new web service client" by right clicking on my project. Then a window comes asking for "service definition". then plz tell me the further steps to consume any free webservices available.....plz...plz...

    ReplyDelete