HTTP Request from WebScript in Alfresco

前端 未结 1 396
再見小時候
再見小時候 2020-12-19 13:24

I\'m writing a WebScript in Alfresco using JS controller and I want to make a HTTP request to the local HTTP resource. This resource is a Java-based app and gives me its own

1条回答
  •  清歌不尽
    2020-12-19 13:46

    EDIT: Alfresco is overriding the Spring Surf webscripts.container bean removing the remote definition (in web-scripts-application-context.xml of remote-api):

    
          Repository
          
             
               
                  
               
             
    
    
    

    I suggest you include it again as a custom Javascript API root level object.


    The remote root object comes from the Spring Surf framework, meaning you have it regardless of being developing your Web Scripts against the Alfresco repository or Share. As a proof, here's the source for a Web Script available in the public Alfresco CMIS server (-> Alfresco repository instance, admin/admin if you are asked to login):

    var serviceUrl = (args.service === null) ? "/api/repository" : args.service;
    var conn = remote.connect("alfresco");
    var result = conn.get(stringUtils.urlEncodeComponent(serviceUrl));
    
    var service = atom.toService(result.response);
    var workspace = service.workspaces.get(0);
    model.repo = workspace.getExtension(atom.names.cmisra_repositoryInfo);
    

    The following snippet is taken from spring-surf-application-context.xml as found inside spring-webscripts-1.0.0.CI-SNAPSHOT.jar of Alfresco 3.4.0, which is where the remote root object gets its definition:

       
          Spring Surf Container
          
          
          
          
          
          
          
             
                
             
          
          
          
       
    
       
          
          
       
    

    0 讨论(0)
提交回复
热议问题