马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Liferay是基于SOA理念设计的,很容易通过Web Services对外提供服务接口,下面简单介绍一下。 Liferay如何对外提供服务? 1、在service.xml中编辑,增加一个<entity name="xx" local-service="false" remote-service="true" /> 2、ant build-service-xxxx (portal-impl/build.xml) 3、修改XXServiceImpl, 写入你要对外提供的方法逻辑; 4、ant build-service-xxxx (重复2) 5、ant build-wsdd-xxxx in portal-impl/build.xml 6、ant clean deploy in portal-impl/build.xml 这样你就成功发布以了一个服务,在tunnel-web/doc-root/WEB-INF/server-config.wsdd 中查找是否发布成功 如何调用Liferay发布的服务?smilingleo原创 1、新建一个项目(或者打开你要调用服务的项目) 2、将Apache AXIS的所有lib文件拷贝到<your-webapp>/WEB-INF/lib下面; 3、将portal-client.jar拷贝到上述目录,如果没有,在portal-client/build.xml中ant build-client(注意,这时,服务器要在开启状态,而且上面编写的服务已经成功deploy到服务器) 4、编写代码,例如; import java.net.URL; import com.company.portal.service.http.MyUserServiceSoap; import com.company.portal.service.http.MyUserServiceSoapServiceLocator; public class LiferayClient ...{
public static void main(String [] args) ...{
long userId = 54321L;
long companyId = 12345L;
String email = "me@company.com";
String password = "notTellingYou";
try ...{
MyUserServiceSoapServiceLocator locator = new MyUserServiceSoapServiceLocator();
MyUserServiceSoap soap = locator.getPortal_MyUserService(_getURL(Long.toString(userId), "Portal_MyUserService"));
int isAuthenticated = soap.authenticateByEmailAddress(companyId, email, password);
System.out.println("is user authenticated? " + isAuthenticated);
} catch (Exception e) ...{
System.err.println(e.toString());
}
}
private static URL _getURL(String remoteUser, String serviceName) throws Exception ...{
String password = "secret";
url = "http://" + remoteUser + ":" + password + "@localhost:8080/tunnel-web/secure/axis/" + serviceName;
return new URL(url);
}
} 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/smilingleo/archive/2008/01/03/2017832.aspx |