我目前正在Liferay 7工作并尝试为门户网站构建我的第一个服务。
为此,我创建了一个新的服务构建器模型,添加了我的第一个简单方法,添加了必要的注释,并尝试现在部署web服务。但是json服务似乎没有被正确注册。我在“http://localhost:8080/api/jsonws”下看不到任何条目。
我的代码如下(仅限服务接口和实现):
serviceInterface等
@AccessControlled
@JSONWebService()
@OSGiBeanProperties(property = {"json.web.service.context.name=dynamicdataasset","json.web.service.context.path=DynamicDataAsset"}, service = DynamicDataAssetService.class)
@ProviderType
@Transactional(isolation = Isolation.PORTAL, rollbackFor = {PortalException.class, SystemException.class})
public interface DynamicDataAssetService extends BaseService {
/**
* Returns the OSGi service identifier.
*
* @return the OSGi service identifier
*/
public java.lang.String getOSGiServiceIdentifier();
}
ServiceImpl:
@ProviderType
@JSONWebService("dynamic-data-assets")
public class DynamicDataAssetServiceImpl extends DynamicDataAssetServiceBaseImpl {
/**
* Test method to see if the service is available.
* @return
*/
@JSONWebService(value = "get-availability-of-service", method = "GET")
public String getAvailabilityOfService() {
return "Service is available";
}
}
service.xml中
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="eu.gerhards.liferay.dynamic.data.list.assets">
<namespace>DynamicDataAsset</namespace>
<entity local-service="true" name="DynamicDataAsset" remote-service="true" uuid="false" human-name="DynamicDataAsset">
...
我按照教程可以找到:https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/service-builder-web-services。
任何人都可以告诉我,出了什么问题并指出了正确的方向吗?
非常感谢
Udo
答案 0 :(得分:0)
[Please see the example here][1] After service build you will get the serviceImple class to implement rest web service..
please choose the context name what you have provided in service.xml file ex :-<namespace>xxx_mh</namespace>
***********这是示例代码**************
@ProviderType
public class xxxServiceImpl extends xxxServiceBaseImpl {
@ProviderType
public class xxxServiceImpl extends xxxServiceBaseImpl {
public JSONObject UrmethodName(long xxId, Date startDate,
Date endDate) {
/*****Your implementation ***/
return responseData;
}
}
************Here is Service.xml file for reference **************
<entity local-service="true" name="Xxxx" table="xxx_xxx" remote-service="true" >