Hi every,
According to the new Wrox Alfresco book (pp. 306 - 309), the proper way of defining a remote end-point in Alfresco is to define <authenticator />, <connector />, and <endpoint /> elements and invoke them using the Webscript 'remote' object.
For instance, if I define the following connector objects in a configuration file:
I should be able to connect to the defined endpoint using the following script:Code:<config evaluator="string-compare" condition="Remote"> <remote> <authenticator> <id>proof-of-concept-authenticator</id> <name>Proof-of-Concept Authenticator</name> <description>Proof-of-Concept Authenticator</description> <class>org.alfresco.connector.AlfrescoAuthenticator</class> </authenticator> <connector> <id>proof-of-concept-connector</id> <name>Proof-of-Concept Connector</name> <description>Proof-of-Concept Connector</description> <class>org.alfresco.connector.AlfrescoConnector</class> <authenticator-id>proof-of-concept-authenticator</authenticator-id> </connector> <endpoint> <id>proof-of-concept-endpoint</id> <name>Proof-of-Concept Endpoint</name> <description>Proof-of-Concept Endpoint</description> <connector-id>proof-of-concept-connector</connector-id> <endpoint-url>http://localhost:8080/alfresco/service</endpoint-url> <identity>user</identity> </endpoint> </remote> </config>
The default authenticators, connectors, and endpoints are defined in the 'spring-webscripts-config.xml' file of the 'spring0webscripts' project of the Spring Surf SDK.Code:var connector = remote.connect("proof-of-concept-endpoint"); model.result = connector.get("/path/to/a/remote/service");
Problem is, the book never tells where this configuration is supposed to be placed -- especially if you're trying to add end-points to a Share application. If you take a look at '/share/WEB-INF/classes/alfresco/slingshot-application-context.xml', it appears as though endpoints are to be added to one of the following three locations:
If I define my endpoints in a local copy of:Code:<value>classpath:org/springframework/extensions/webscripts/spring-webscripts-config.xml</value> <value>classpath:META-INF/spring-webscripts-config-custom.xml</value> <value>jar:*!/META-INF/spring-webscripts-config-custom.xml</value>
my endpoints are read, but the default endpoints defined in the Spring Surf 'spring-webscripts' project are not. Clearly, I shouldn't be overriding these settings.Code:<value>classpath:org/springframework/extensions/webscripts/spring-webscripts-config.xml</value>
However, if I define my endpoints in:
they don't seem to be picked up. In fact, the script doesn't seem to be processed at all, for if I deliberately introduce a syntax error into the XML file (in my case by adding a dangling '<' to the middle of the file), Share starts up just fine and does not choke on the error. And further, if I stop the Javascript Debugger on the script trying to open the endpoint and watch the following expression:Code:<value>classpath:META-INF/spring-webscripts-config-custom.xml</value>
I learn that my endpoint is not known to my application.Code:remote.allEndpoints
Anyone have an idea on how to do this?
Darryl


Reply With Quote
