Liferay研究之十五:Liferay如何对外提供Service,以及如何调用
来源:互联网 发布:java编程入门 pdf 编辑:程序博客网 时间:2024/05/22 01:32
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);
}
}
- Liferay研究之十五:Liferay如何对外提供Service,以及如何调用
- Liferay研究之十五:Liferay如何对外提供Service,以及如何调用
- Liferay研究之二十:如何防止连续重复提交
- Liferay研究之廿四:如何实现配置模式
- Liferay Portal 6.2 CE 如何提供Webservice
- 研究:Liferay研究(六)Liferay中如何获取相应的portlet实例Id和portletId
- liferay 如何使用javascript
- liferay 如何重定向
- liferay 如何 用 国际化
- liferay如何debug
- Liferay研究之十六:FCKeditor如何插入服务器上的资源?
- Liferay研究之五:Liferay的MDA开发模式
- Liferay研究之六:Liferay技巧几则
- Liferay研究之廿一:Liferay集成Jbpm
- 如何更改Liferay context path
- 1.Liferay新手如何入门
- liferay 6.2 +httpclient4.5 调用 REST service
- Liferay
- (4)SVG中所用到的形状简介------矩形
- 大三实习的迷茫。。
- IBM i 抓住Mono的时机--再次
- Proxool连接池 配置
- Liferay研究之廿三:JSP中可直接引用的Liferay对象
- Liferay研究之十五:Liferay如何对外提供Service,以及如何调用
- iphone table 实现动态加载图片
- JavaLiferay研究之十六:FCKeditor如何插入服务器上的资源?
- Liferay研究之十二:对Liferay框架的几点分析总结 收藏
- 有没有那么一刻,你突然想起
- Liferay中配置MySQL数据库的两种方法零
- 考试
- Drawable、Bitmap、byte[]之间的转换
- ec:table