Errors attempting to run XQuery scripts for single sign on into MarkLogic

荒凉一梦 提交于 2021-02-09 10:57:38

问题


I'm working on using an xquery re-writer script to automate the login for a Single Sign-On solution. I'm starting with the Admin App Server at port 8001. In the App Server configuration I have:

  • Set authentication = application-level
  • Set url rewriter = rewriter.xqy

I have also set the following rewriter.xqy script at the root Admin/ directory on the server. As you can see, just as a simple test, I'm attempting to programmatically login as user "Austin" (a valid user).

xquery version "1.0-ml";

import module namespace rest = "http://marklogic.com/appservices/rest"
    at "/MarkLogic/appservices/utils/rest.xqy";

import module namespace config = "http://marklogic.com/admin/endpoint-config"
    at "/endpoints/config.xqy";

xdmp:login("Austin")

return (rest:rewrite($config:OPTIONS,"uri"),xdmp:get-request-url())[1]

However, after recycling the webserver, I keep getting the following error when browsing to the Admin UI.
As soon as I remove the xdmp line, the error goes away, and I can get straight in.

500: Internal Server Error
XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_
In /rewriter.xqy on line 9

As another test, I tried to log some messages using xdmp:log, but those lines are also failing.
Any clue why xdmp scripts are not running successfully?


回答1:


In XQuery a return is only part of a FLWOR expression. It's not a procedural return. You can just execute a sequence here:

xdmp:login("Austin"),
(rest:rewrite($config:OPTIONS,"uri"),xdmp:get-request-url())[1]

I can't vouch that this logic is sound, but the syntax is.



来源:https://stackoverflow.com/questions/65816993/errors-attempting-to-run-xquery-scripts-for-single-sign-on-into-marklogic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!