2016-09-29 77 views
1

我目前正在Liferay 7中工作,並試圖爲門戶構建我的第一個服務。Liferay 7 - 服務構建器 - JSON寧靜服務未顯示

爲此,我創建了一個新的服務構建器模型,添加了我的第一個簡單方法,添加了必要的註釋,並嘗試現在部署webservice。但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

任何人都可以告訴我,什麼是錯的,並指向正確的方向?

非常感謝

回答

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" >