2013-06-27 54 views
0

我正在關注java支持webscripts的alfresco維基指南,並且無法使其工作。更糟的是,我無法在日誌或其他方面產生錯誤,或者在/ alfresco/service/index/all中列出webscript。java支持webscript根本不顯示

除了這個wiki的例子,我沒有使用AMP,而是爲我的課程使用了一個jar。這是因爲我必須將我的web腳本添加到當前構建到jar中的現有應用程序中。

據我瞭解,有在創建Java支持webscript三個主要步驟:

  1. 創建Java類
  2. 註冊豆
  3. 將描述符

我執行如下。文件位置相對於jar的根目錄。 NL /標記/露天/爲MyService/webscript/GetFooTypes.java

package nl.mark.alfresco.myservice.webscript; 

import java.util.HashMap; 
import java.util.Map; 

import org.springframework.extensions.webscripts.DeclarativeWebScript; 
import org.springframework.extensions.webscripts.Status; 
import org.springframework.extensions.webscripts.WebScriptRequest; 

public class GetFooTypes extends DeclarativeWebScript { 
    @Override 
    protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { 
     Map<String, Object> model = new HashMap<String, Object>(); 
     model.put("types", "[\"foo\", \"bar\"]"); 
     return model; 
    } 
} 

露天/擴展/模板/ webscripts/NL /標記/ cacher的/ footype.desc.xml

<webscript> 
    <shortname>Retrieve a list of foo types associated to a bar type.</shortname> 
    <description>Returns an empty JSON array or a JSON array filled with foo types as Strings, named 'types'.</description> 
    <url>/mark/cacher/footype?typecode={code}</url> 
    <authentication>user</authentication> 
    <family>Mark cacher</family> 
</webscript> 

露天/擴展/標記的context.xml

<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> 

<beans> 
    <!-- Java backed webscripts --> 
    <bean id="webscript.nl.mark.cacher.footype.get" class="nl.mark.alfresco.myservice.webscript.GetFooTypes" 
     parent="webscript"> 
    </bean> 
</beans> 

mark-context.xml文件也包含其他註冊,它們都被正確拾取。

最後,將此jar放在露天的WEB-INF/lib文件夾中,然後重新啓動服務器。但是,webscript在其URL(404)下不可用,並且我發現沒有提及(awefully clean)日誌中的任何相關內容。它也沒有在webscripts索引中列出,甚至沒有加載失敗。我覺得我在搞亂文件位置。

+2

快速猜測(有沒有正在運行的露天這裏):重命名描述爲「footype.get.desc.xml」 –

回答

4

完整的文件夾和文件名

alfresco/extension/templates/webscripts/nl/mark/cacher/footype.get.desc.xml 

定義,

一個包NL /標記/ cacher的的,

一足跡的服務ID,

綁定到HTT P GET方法

<bean id="webscript.nl.mark.cacher.footype.get" 
     class="nl.mark.alfresco.myservice.webscript.GetFooTypes" 
     parent="webscript"> 
</bean> 

前綴webscript被Web腳本引擎拾取。 結束get由Web腳本引擎拾取。它告訴Web腳本引擎處理哪個HTTP方法。在這種情況下,HTTP GET

因此,在您的代碼中,您錯過了。在文件描述文件名獲得

參考: http://wiki.alfresco.com/wiki/Web_Scripts http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples

+0

我在犯了一個錯誤問題,描述符實際上被命名爲「footype.desc.get.xml」。事實上,這仍然是錯誤的。解決方案:正如你所說的,'footype.get.desc.xml'。一直堅持這一點,我想我會去扼殺一些東西:P。謝謝! –

+0

Spring bean ID應該是'webscript.nl.mark.cacher.footype.get',如問題中提供的配置。您缺少服務ID。 –

+0

@WillAbson,是的,已更新 –

2

我認爲描述文件應該被命名爲footype.get.desc.xml