来自Alfresco中WebScript的HTTP请求

编程入门 行业动态 更新时间:2024-10-17 13:31:26
本文介绍了来自Alfresco中WebScript的HTTP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用JS控制器在Alfresco中编写WebScript,我想向本地HTTP资源发出HTTP请求。此资源是一个基于Java的应用程序,并为我提供了自己的REST API。

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 REST API.

我的WebScript不是共享组件:因此我没有远程对象来调用另一个网页脚本。

My WebScript is not a Share Component: so I don't have a remote object to call another webscript.

如何向本地资源发出HTTP请求(例如'/ sdo / documents / getName?type = fl')来自WebScript?

How can I make a HTTP request to the local resource (something like '/sdo/documents/getName?type=fl') from a WebScript?

推荐答案

编辑:Alfresco覆盖了Spring Surf webscripts.container bean删除了远程定义(在 web-scripts-application-context.xml 的远程api ):

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

<bean id="webscripts.container" class="org.alfresco.repo.web.scripts.RepositoryContainer" parent="webscripts.abstractcontainer"> <property name="name"><value>Repository</value></property> <property name="scriptObjects"> <map merge="true"> <entry key="paging"> <ref bean="webscripts.js.paging"/> </entry> </map> <!-- ..... --> </bean>

我建议您再次将其作为自定义Javascript API 根级对象。

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

远程根对象来自 Spring Surf 框架,这意味着无论使用Alfresco存储库或Share开发Web脚本,都可以使用。作为证明,这是网络脚本的来源在公开的Alfresco CMIS服务器中可用(-> Alfresco存储库实例,如果需要登录,则为admin / admin):

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);

以下摘录摘自 spring-surf-application-context.xml ,位于Alfresco 3.4.0的 spring-webscripts-1.0.0.CI-SNAPSHOT.jar 内,在远程根对象得到其定义:

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:

<bean id="webscripts.container" parent="webscripts.abstractcontainer" class="org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer"> <property name="name"><value>Spring Surf Container</value></property> <property name="registry" ref="webscripts.registry" /> <property name="searchPath" ref="webframework.webscripts.searchpath" /> <property name="templateProcessorRegistry" ref="webframework.webscripts.registry.templateprocessor" /> <property name="scriptProcessorRegistry" ref="webframework.webscripts.registry.scriptprocessor" /> <property name="scriptParameterFactoryRegistry" ref="webscripts.web.scriptparameterfactoryregistry" /> <property name="configService" ref="web.config" /> <property name="scriptObjects"> <map merge="true"> <entry key="remote" value-ref="webframework.webscripts.scriptremote" /> </map> </property> <property name="processorModelHelper" ref="processor.model.helper"/> <property name="extensibilityModuleHandler" ref="webscripts.extensibility.handler"/> </bean> <bean id="webframework.webscripts.scriptremote" class="org.springframework.extensions.webscripts.ScriptRemote"> <property name="configService" ref="web.config"/> <property name="connectorProvider" ref="webframework.connector.provider"/> </bean>

更多推荐

来自Alfresco中WebScript的HTTP请求

本文发布于:2023-11-28 14:15:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642743.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Alfresco   WebScript   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!