Marklogic 8 rest扩展插件多部分/表单数据存在文件上载问题

Marklogic 8 rest扩展插件多部分/表单数据存在文件上载问题,marklogic,marklogic-8,Marklogic,Marklogic 8,我在ML8中编写了一个小的rest扩展,它基本上存储上传到ml内容数据库中的文件。。当我这样做时,我得到以下异常 <error-response xmlns="http://marklogic.com/xdmp/error"> <status-code>500</status-code> <status>Internal Server Error</status> <message-code>INTERNAL ERROR&l

我在ML8中编写了一个小的rest扩展,它基本上存储上传到ml内容数据库中的文件。。当我这样做时,我得到以下异常

<error-response xmlns="http://marklogic.com/xdmp/error">
<status-code>500</status-code>
<status>Internal Server Error</status>
<message-code>INTERNAL ERROR</message-code>
<message>XDMP-UPDATEFUNCTIONFROMQUERY: xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy")($context, $service-params, $input) -- Cannot apply an update function from a query . See the MarkLogic server error log for further detail.</message>
</error-response>
下面是日志文件中的错误跟踪

2016-02-15 17:29:32.085 Notice: content-repo: XDMP-UPDATEFUNCTIONFROMQUERY: xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy")($context, $service-params, $input) -- Cannot apply an update function from a query
2016-02-15 17:29:32.085 Notice: content-repo: in /MarkLogic/rest-api/lib/extensions-util.xqy, at 877:20,
2016-02-15 17:29:32.085 Notice: content-repo: in extut:call-service("repoLoad", "POST", xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy"), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="accept-types"><map:value xsi:type="xs:string">te...</map:map>), map:map(), document{binary{""}}) [1.0-ml]
2016-02-15 17:29:32.085 Notice: content-repo:   $extension-name = "repoLoad"
2016-02-15 17:29:32.085 Notice: content-repo:   $method = "POST"
2016-02-15 17:29:32.085 Notice: content-repo:   $service = xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy")
2016-02-15 17:29:32.085 Notice: content-repo:   $context = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="accept-types"><map:value xsi:type="xs:string">te...</map:map>)
2016-02-15 17:29:32.085 Notice: content-repo:   $service-params = map:map()
2016-02-15 17:29:32.085 Notice: content-repo:   $input = document{binary{""}}
2016-02-15 17:29:32.085 Notice: content-repo: in /MarkLogic/rest-api/lib/extensions-util.xqy, at 792:14,
2016-02-15 17:29:32.085 Notice: content-repo: in extut:invoke-service("repoLoad", "POST", "query", xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy"), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="accept-types"><map:value xsi:type="xs:string">te...</map:map>), map:map(), document{binary{""}}, fn:false()) [1.0-ml]
2016-02-15 17:29:32.085 Notice: content-repo:   $extension-name = "repoLoad"
2016-02-15 17:29:32.085 Notice: content-repo:   $method = "POST"
2016-02-15 17:29:32.085 Notice: content-repo:   $default-txn-mode = "query"
2016-02-15 17:29:32.085 Notice: content-repo:   $service = xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy")
2016-02-15 17:29:32.085 Notice: content-repo:   $context = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="accept-types"><map:value xsi:type="xs:string">te...</map:map>)
2016-02-15 17:29:32.085 Notice: content-repo:   $service-params = map:map()
2016-02-15 17:29:32.085 Notice: content-repo:   $input = document{binary{""}}
2016-02-15 17:29:32.085 Notice: content-repo:   $in-txn = fn:false()
2016-02-15 17:29:32.085 Notice: content-repo:   $txn-curr = "query"
2016-02-15 17:29:32.085 Notice: content-repo:   $annotation = ()
2016-02-15 17:29:32.085 Notice: content-repo:   $txn-mode = "query"
2016-02-15 17:29:32.085 Notice: content-repo: in /MarkLogic/rest-api/models/resource-model-query.xqy, at 254:8,
2016-02-15 17:29:32.085 Notice: content-repo: in rsrcmodqry:resource-post("repoLoad", map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="accept-types"><map:value xsi:type="xs:string">te...</map:map>), map:map(), document{binary{""}}, fn:false(), local:rsrcmod-callback#6) [1.0-ml]
2016-02-15 17:29:32.085 Notice: content-repo:   $resource-name = "repoLoad"
2016-02-15 17:29:32.085 Notice: content-repo:   $context = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="accept-types"><map:value xsi:type="xs:string">te...</map:map>)
2016-02-15 17:29:32.085 Notice: content-repo:   $resource-params = map:map()
2016-02-15 17:29:32.085 Notice: content-repo:   $input = document{binary{""}}
2016-02-15 17:29:32.085 Notice: content-repo:   $in-txn = fn:false()
2016-02-15 17:29:32.085 Notice: content-repo:   $responder = local:rsrcmod-callback#6
2016-02-15 17:29:32.085 Notice: content-repo:   $service = xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy")
2016-02-15 17:29:32.085 Notice: content-repo: in /MarkLogic/rest-api/models/resource-model-query.xqy, at 219:4,
2016-02-15 17:29:32.085 Notice: content-repo: in rsrcmodqry:exec-post(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="content-type"><map:value xsi:type="xs:string">mu...</map:map>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="upload"><map:value/></map:entry></map:map>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...), document{binary{""}}, local:rsrcmod-callback#6) [1.0-ml]
2016-02-15 17:29:32.085 Notice: content-repo:   $headers = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="content-type"><map:value xsi:type="xs:string">mu...</map:map>)
2016-02-15 17:29:32.085 Notice: content-repo:   $endpoint-params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="upload"><map:value/></map:entry></map:map>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2016-02-15 17:29:32.085 Notice: content-repo:   $input = document{binary{""}}
2016-02-15 17:29:32.085 Notice: content-repo:   $responder = local:rsrcmod-callback#6
2016-02-15 17:29:32.085 Notice: content-repo: in /MarkLogic/rest-api/endpoints/resource-service-query.xqy, at 65:8 [1.0-ml]
2016-02-15 17:29:32.085 Notice: content-repo:   $params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="upload"><map:value/></map:entry></map:map>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2016-02-15 17:29:32.085 Notice: content-repo:   $headers = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="content-type"><map:value xsi:type="xs:string">mu...</map:map>)
2016-02-15 17:29:32.085 Notice: content-repo:   $method = "POST"
2016-02-15 17:29:32.085 Notice: content-repo:   $body = document{binary{""}}
2016-02-15 17:29:32.216 Info: content-repo: Status 500: XDMP-UPDATEFUNCTIONFROMQUERY: xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/repoLoad","post"), "/marklogic.rest.resource/repoLoad/assets/resource.xqy")($context, $service-params, $input) -- Cannot apply an update function from a query
2016-02-15 17:29:32.085通知:内容回复:XDMP-UPDATEFUNCTIONFROMQUERY:XDMP:function(fn:QName(“http://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”)($context、$service params、$input)--无法从查询应用更新函数
2016-02-15 17:29:32.085通知:内容回复:in/MarkLogic/restapi/lib/extensions-util.xqy,877:20,
2016-02-15 17:29:32.085通知:内容repo:in-extut:call服务http://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”),map:map(te…,map:map(),document{binary{”“})[1.0-ml]
2016-02-15 17:29:32.085通知:内容回购:$extension name=“repoLoad”
2016-02-15 17:29:32.085通知:内容回购:$method=“POST”
2016-02-15 17:29:32.085通知:内容回购:$service=xdmp:functionhttp://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”)
2016-02-15 17:29:32.085通知:内容回购:$context=map:map(te…)
2016-02-15 17:29:32.085通知:内容回购:$service params=map:map()
2016-02-15 17:29:32.085通知:内容回复:$input=document{binary{”“}
2016-02-15 17:29:32.085通知:内容回复:in/MarkLogic/restapi/lib/extensions-util.xqy,792:14,
2016-02-15 17:29:32.085通知:内容repo:in extut:调用服务http://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”),映射:映射(te…,映射:映射(),文档{binary{”“},fn:false())[1.0-ml]
2016-02-15 17:29:32.085通知:内容回购:$extension name=“repoLoad”
2016-02-15 17:29:32.085通知:内容回购:$method=“POST”
2016-02-15 17:29:32.085通知:内容回购:$default txn mode=“query”
2016-02-15 17:29:32.085通知:内容回购:$service=xdmp:functionhttp://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”)
2016-02-15 17:29:32.085通知:内容回购:$context=map:map(te…)
2016-02-15 17:29:32.085通知:内容回购:$service params=map:map()
2016-02-15 17:29:32.085通知:内容回复:$input=document{binary{”“}
2016-02-15 17:29:32.085通知:内容回购:$in txn=fn:false()
2016-02-15 17:29:32.085通知:内容回购:$txn curr=“查询”
2016-02-15 17:29:32.085通知:内容回购:$annotation=()
2016-02-15 17:29:32.085通知:内容回购:$txn mode=“query”
2016-02-15 17:29:32.085通知:内容回复:in/MarkLogic/restapi/models/resource-model-query.xqy,254:8,
2016-02-15 17:29:32.085通知:内容repo:in rsrcmodqry:resource post(“repoLoad”,map:map(te…,map:map(),document{binary{“”}},fn:false(),local:rsrcmod callback#6)[1.0-ml]
2016-02-15 17:29:32.085通知:内容回购:$resource name=“repoLoad”
2016-02-15 17:29:32.085通知:内容回购:$context=map:map(te…)
2016-02-15 17:29:32.085通知:内容回购:$resource params=map:map()
2016-02-15 17:29:32.085通知:内容回复:$input=document{binary{”“}
2016-02-15 17:29:32.085通知:内容回购:$in txn=fn:false()
2016-02-15 17:29:32.085通知:内容回复:$responder=local:rsrcmod callback#6
2016-02-15 17:29:32.085通知:内容回购:$service=xdmp:functionhttp://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”)
2016-02-15 17:29:32.085通知:内容回复:in/MarkLogic/restapi/models/resource-model-query.xqy,219:4,
2016-02-15 17:29:32.085通知:内容回复:在rsrcmodqry中:exec post(map:map(mu…,map:map(…XDMP-CHILDNODEKIND:element节点不能有二进制节点子节点…),文档{binary{“”},本地:rsrcmod callback#6)[1.0-ml]
2016-02-15 17:29:32.085通知:内容回购:$headers=map:map(mu…)
2016-02-15 17:29:32.085通知:内容回复:$endpoint params=map:map(…XDMP-CHILDNODEKIND:element节点不能有二进制节点子节点…)
2016-02-15 17:29:32.085通知:内容回复:$input=document{binary{”“}
2016-02-15 17:29:32.085通知:内容回复:$responder=local:rsrcmod callback#6
2016-02-15 17:29:32.085通知:内容回复:in/MarkLogic/restapi/endpoints/resource-service-query.xqy,65:8[1.0-ml]
2016-02-15 17:29:32.085通知:内容回复:$params=map:map(…XDMP-CHILDNODEKIND:element节点不能有二进制节点子节点…)
2016-02-15 17:29:32.085通知:内容回购:$headers=map:map(mu…)
2016-02-15 17:29:32.085通知:内容回购:$method=“POST”
2016-02-15 17:29:32.085通知:内容回复:$body=document{binary{”“}
2016-02-15 17:29:32.216信息:内容回复:状态500:XDMP-UPDATEFUNCTIONFROMQUERY:XDMP:function(fn:QName(“http://marklogic.com/rest-api/resource/repoLoad“,“post”),“/marklogic.rest.resource/repoLoad/assets/resource.xqy”)($context、$service params、$input)--无法从查询应用更新函数

默认情况下,MarkLogic REST扩展在特定的更新模式下运行,具体取决于请求方法和单/多语句。自MarkLogic 8以来,POST方法单个语句的默认更新模式更改为
query
。向
repoLoad:post
方法添加注释,如下所示:

declare %rapi:transaction-mode("update") function repoLoad:post(...)
另见


默认情况下,MarkLogic REST扩展在特定的更新模式下运行,具体取决于请求方法和单/多语句。自MarkLogic 8以来,POST方法单个语句的默认更新模式更改为
query
。向
repoLoad:post
方法添加注释,如fol
declare %rapi:transaction-mode("update") function repoLoad:post(...)