liferay对外提供webservice按口

先引用一篇别人的文章
[color=red]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);
}
}[/color]
这篇文章让我们解决了liferay如何去做webservice服务端,,文中也提到外部程序如何去调用liferay写的服务端,在5.0的版本中liferay的网站提供了client用到的所有的包,当然了这个包中不包括你自已开发的webservice.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值