How call external url from back-end js webscript

cancel
Showing results for 
Search instead for 
Did you mean: 
jamilnour
Established Member

How call external url from back-end js webscript

Jump to solution

Hello,

I want to call an External URL as POST from my server js webscript

I tried with the predefined Surf remote variable but I have "remote not found" error

Thank you

Jamil

1 Solution

Accepted Solutions
jpotts
Professional

Re: How call external url from back-end js webscript

Jump to solution

By default, the remote object is disabled for repository tier web scripts. But you can always re-enable it. Take a look at this post on Stack to see if it helps you out: web scripting - HTTP Request from WebScript in Alfresco - Stack Overflow

View solution in original post

6 Replies
jpotts
Professional

Re: How call external url from back-end js webscript

Jump to solution

By default, the remote object is disabled for repository tier web scripts. But you can always re-enable it. Take a look at this post on Stack to see if it helps you out: web scripting - HTTP Request from WebScript in Alfresco - Stack Overflow

afaust
Master

Re: How call external url from back-end js webscript

Jump to solution

This has also been covered in a post on the old forums which has been migrated to the new Jive platform.

jamilnour
Established Member

Re: How call external url from back-end js webscript

Jump to solution

Hi Axel,

Can you tell me where to add this webscripts.container bean?

Thanks

Jamil

jpotts
Professional

Re: How call external url from back-end js webscript

Jump to solution

Any file on the classpath ending in context.xml. Ideally you already have an amp project started and you can add it to service-context.xml or similar.

jamilnour
Established Member

Re: How call external url from back-end js webscript

Jump to solution

After adding the webscripts.container bean to the service-context.xml inside my amp I have an exception (related to Solr!!!). Note that when I remove the webscripts.container the server is back and work well. Any conflict?

Thank you

Jamil

<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>
            <entry key="remote">
                <ref bean="webscripts.script.remote" />
            </entry>
            <entry key="cmis">
                <ref bean="webscripts.js.cmis.client" />
            </entry>
        </map>
    </property>
</bean>

The exception:
2017-03-07 14:21:30,027 ERROR [solr.tracker.AbstractTracker] [SolrTrackerScheduler_Worker-31] Model tracking failed
org.alfresco.error.AlfrescoRuntimeException: 02070063 GetModelsDiff return status is 503
at org.alfresco.solr.client.SOLRAPIClient.getModelsDiff(SOLRAPIClient.java:1157)
at org.alfresco.solr.tracker.ModelTracker.trackModelsImpl(ModelTracker.java:249)
at org.alfresco.solr.tracker.ModelTracker.trackModels(ModelTracker.java:207)
at org.alfresco.solr.tracker.ModelTracker.ensureFirstModelSync(ModelTracker.java:229)
at org.alfresco.solr.component.EnsureModelsComponent.prepare(EnsureModelsComponent.java:80)
at org.apache.solr.handler.component.AlfrescoSearchHandler.handleRequestBody(AlfrescoSearchHandler.java:283)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.alfresco.solr.Cloud.getResponse(Cloud.java:159)
at org.alfresco.solr.Cloud.getSolrDocumentList(Cloud.java:143)
at org.alfresco.solr.SolrInformationServer.getDocsWithUncleanContent(SolrInformationServer.java:715)
at org.alfresco.solr.tracker.ContentTracker.doTrack(ContentTracker.java:74)
at org.alfresco.solr.tracker.AbstractTracker.track(AbstractTracker.java:185)
at org.alfresco.solr.tracker.TrackerJob.execute(TrackerJob.java:47)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:563)
Santiago-Florez
Member II

Re: How call external url from back-end js webscript

Jump to solution
Hello Jamil Have you solved the solr problem?