Я получаю 500 внутренняя ошибка сервера (XDMP-CHILDNODEKIND) при обработке ZIP - PullRequest
1 голос
/ 20 февраля 2020

У нас есть расширение rest, для которого одним из параметров для метода post является zip, который мы хотим обработать, но я получаю ошибку 500. следующее сообщение отображается в ответе. ZIP состоит из некоторых json и изображений и PDF. Есть ли обходной путь, чтобы заставить его работать.

здесь я воспроизвел то же, что и в среде PROD:

код расширения:

declare 
%roxy:params("")
%rapi:transaction-mode("update")
function dmc:post(
    $context as map:map,
    $params  as map:map,
    $input   as document-node()*
) as document-node()*
{
  let $_ := xdmp:log("**********")
  let $_ := xdmp:log($context)
  let $_ := xdmp:log("**********")

  let $_ := xdmp:log("**********")
  let $_ := xdmp:log($params)
  let $_ := xdmp:log("**********")

  let $_ := xdmp:log("**********")
  let $_ := xdmp:log($input)
  let $_ := xdmp:log("**********")

  let $_ := xdmp:log("**********")
  let $_ := xdmp:log(xdmp:get-request-field-content-type("rs:file"))
  let $_ := xdmp:log("**********")

  let $_ := map:put($context, "output-types", "application/xml")
  let $_ := map:put($context, "output-status", (201, "Created"))
  let $name := map:get($params, "name")
  let $file := map:get($params, "file")
  return document{c:my-function($name, $file)}
};

код модуля:

declare function c:my-function($name as xs:string, $file as binary()) as xs:string{

    let $my-name := $name
    let $my-file := $file
    return $my-name
};

журнал ошибок:

2020-02-20 20:57:04.530 Info: **********
2020-02-20 20:57:04.530 Info: {"input-types":"multipart/form-data"}
2020-02-20 20:57:04.530 Info: **********
2020-02-20 20:57:04.530 Info: **********
2020-02-20 20:57:04.531 Info: {"file":["", "504b0304140000000800339fa94a56184dfee3850000209000001a00000000a882994a20b6abbe41000000410000000a00000000000000010020000000a38e0000617373656c2e6a736f6e504b05060000000003000300b90000000c8f00000000"], "name":"shrikant"}
2020-02-20 20:57:04.531 Info: **********
2020-02-20 20:57:04.531 Info: **********
2020-02-20 20:57:04.531 Info: **********
2020-02-20 20:57:04.531 Info: **********
2020-02-20 20:57:04.531 Info: application/x-zip-compressed
2020-02-20 20:57:04.531 Info: **********
2020-02-20 20:57:04.537 Notice: XDMP-AS: (err:XPTY0004) $file as binary() -- Invalid coercion: "" as binary()
2020-02-20 20:57:04.537 Notice:+in /config/config.xqy, at 21:60,
2020-02-20 20:57:04.537 Notice:+in xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/MyExtension","post"), "/marklogic.rest.resource/MyExtension/assets/resource.xqy")(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...), document{binary{""}}) [1.0-ml]
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/lib/extensions-util.xqy, at 905:44,
2020-02-20 20:57:04.537 Notice:+in extut:call-service("MyExtension", "POST", xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/MyExtension","post"), "/marklogic.rest.resource/MyExtension/assets/resource.xqy"), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...), document{binary{""}}) [1.0-ml]
2020-02-20 20:57:04.537 Notice:+  $extension-name = "MyExtension"
2020-02-20 20:57:04.537 Notice:+  $method = "POST"
2020-02-20 20:57:04.537 Notice:+  $service = xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/MyExtension","post"), "/marklogic.rest.resource/MyExtension/assets/resource.xqy")
2020-02-20 20:57:04.537 Notice:+  $context = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>)
2020-02-20 20:57:04.537 Notice:+  $service-params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2020-02-20 20:57:04.537 Notice:+  $input = document{binary{""}}
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/lib/extensions-util.xqy, at 858:20,
2020-02-20 20:57:04.537 Notice:+in function() as item()*() [1.0-ml]
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/lib/extensions-util.xqy,
2020-02-20 20:57:04.537 Notice:+in xdmp:invoke(function() as item()*, <options xmlns="xdmp:eval"><isolation>different-transaction</isolation>...</options>) [1.0-ml]
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/lib/extensions-util.xqy, at 856:12,
2020-02-20 20:57:04.537 Notice:+in extut:invoke-service("MyExtension", "POST", "query", xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/MyExtension","post"), "/marklogic.rest.resource/MyExtension/assets/resource.xqy"), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...), document{binary{""}}, fn:false()) [1.0-ml]
2020-02-20 20:57:04.537 Notice:+  $extension-name = "MyExtension"
2020-02-20 20:57:04.537 Notice:+  $method = "POST"
2020-02-20 20:57:04.537 Notice:+  $default-txn-mode = "query"
2020-02-20 20:57:04.537 Notice:+  $service = xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/MyExtension","post"), "/marklogic.rest.resource/MyExtension/assets/resource.xqy")
2020-02-20 20:57:04.537 Notice:+  $context = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>)
2020-02-20 20:57:04.537 Notice:+  $service-params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2020-02-20 20:57:04.537 Notice:+  $input = document{binary{""}}
2020-02-20 20:57:04.537 Notice:+  $in-txn = fn:false()
2020-02-20 20:57:04.537 Notice:+  $txn-curr = "query"
2020-02-20 20:57:04.537 Notice:+  $txn-mode = "update"
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/models/resource-model-query.xqy, at 269:20,
2020-02-20 20:57:04.537 Notice:+in rsrcmodqry:resource-post("MyExtension", map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...), document{binary{""}}, fn:false(), local:rsrcmod-callback#6) [1.0-ml]
2020-02-20 20:57:04.537 Notice:+  $resource-name = "MyExtension"
2020-02-20 20:57:04.537 Notice:+  $context = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>)
2020-02-20 20:57:04.537 Notice:+  $resource-params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2020-02-20 20:57:04.537 Notice:+  $input = document{binary{""}}
2020-02-20 20:57:04.537 Notice:+  $in-txn = fn:false()
2020-02-20 20:57:04.537 Notice:+  $responder = local:rsrcmod-callback#6
2020-02-20 20:57:04.537 Notice:+  $service = xdmp:function(fn:QName("http://marklogic.com/rest-api/resource/MyExtension","post"), "/marklogic.rest.resource/MyExtension/assets/resource.xqy")
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/models/resource-model-query.xqy, at 236:4,
2020-02-20 20:57:04.537 Notice:+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" .../>), map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...), document{binary{""}}, local:rsrcmod-callback#6) [1.0-ml]
2020-02-20 20:57:04.537 Notice:+  $headers = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>)
2020-02-20 20:57:04.537 Notice:+  $endpoint-params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2020-02-20 20:57:04.537 Notice:+  $input = document{binary{""}}
2020-02-20 20:57:04.537 Notice:+  $responder = local:rsrcmod-callback#6
2020-02-20 20:57:04.537 Notice:+in /MarkLogic/rest-api/endpoints/resource-service-query.xqy, at 78:8 [1.0-ml]
2020-02-20 20:57:04.537 Notice:+  $headers = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>)
2020-02-20 20:57:04.537 Notice:+  $method = "POST"
2020-02-20 20:57:04.537 Notice:+  $body = document{binary{""}}
2020-02-20 20:57:04.537 Notice:+  $params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>...XDMP-CHILDNODEKIND: element nodes cannot have binary node children...)
2020-02-20 20:57:04.537 Notice:+  $extra-names = ()
2020-02-20 20:57:04.542 Info: Status 500: XDMP-AS: (err:XPTY0004) $file as binary() -- Invalid coercion: "" as binary()

1 Ответ

1 голос
/ 20 февраля 2020

Сообщение об ошибке здесь довольно ясно - вы не можете иметь дочерние узлы с двоичным содержимым, то есть не можете поместить изображение в качестве дочернего узла документа XML, например

Это было уже ответил более подробно:
Запрос на генерацию 'XDMP-CHILDNODEKIND: $ final - узлы элементов не могут иметь дочерних элементов двоичных узлов

...