AnsweredAssumed Answered

Web Services API

Question asked by mikool74321 on Jul 1, 2008
Latest reply on Jul 7, 2010 by prateekgoyal
Hi, I am trying to utilize the web service api to access the alfresco repository. Alfresco and the WCM extension work great, however; I am having problems with the web service samples for Java.

Here is my sample scenario:
1.  In Data Dictionary, created a new space (Create Space) called "Articles".
2.  Under "Articles", I added two text files as content (Add Content)

I want to be able to use the web services client api to query the "Articles" node and have it list its children. Using the web services client samples, I tried a few things but could not get it to work.

In the example below, the only path that I could get to return something was ""/app:company_home".  All other paths throw exceptions.

public class TestQuery extends SamplesBase {
   
    public void test()
    {
        List<ContentResult> results = new ArrayList<ContentResult>();
       
        String spaceName = "";
       
        try
        {
            AuthenticationUtils.startSession(USERNAME, PASSWORD);
            try
            {           
                RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();      
               
                // Get a reference to the space we have named
               
                String path = "/app:company_home/*[@cm:name=\"" + spaceName + "\"]";
                String path2 = "/app:company_home/*[@cm:name=\"SpacesStore\"]";
                String path3 = "/app:company_home";
                String path4 = "/app:company_home/*";
             
                Reference reference = new Reference(STORE, null, path4);
                //Reference reference = new Reference(STORE, null, );
                Predicate predicate = new Predicate(new Reference[]{reference}, null, null);       
                Node[] nodes = repositoryService.get(predicate);
                …
}


I then decided to try to use a Query instead.  The constructor of the Query object is language:String, statement:String.  What should the language string be?  This is not clear, but I think I want it to be XPATH, but there is nothing in Constants such as Constants.QUERY_LANG_XPATH.   Also, if I do get past the language parameter, what would the XPATH actually be?  I cannot figure out what the schema of the structure is.  For example, would it be "//app:company_home/cm:data_dictionary/*[@name="Articles]/*"   I cannot find what the actual schema the nodes are stored under.

Outcomes