用ExPath HTTP Client调用Marklogic数据服务遇参数错误的问题
关于XQuery脚本调用MarkLogic数据服务的问题
我想找从XQuery脚本使用ExPath HTTP Client库调用MarkLogic上部署的数据服务的相关文档,但目前只找到描述从Node.js应用或Java应用使用生成的代理类调用该服务的文档。
我在MarkLogic应用服务器上部署了一个采用摘要认证的数据服务,其*.api文件中参数定义如下:
"params": [ { "name": "foobar", "datatype": "string", "desc": "blah blah" } ],
现在需要在eXist-DB运行的XQuery脚本中,用EXPath HTTP Client库的http:send-request($req, $uri, $bodies)方法调用该服务,其中$uri为服务地址,请求元素$req的定义如下:
<http:request chunked="false" method="post" username="admin" password="PWD" auth-method="digest" send-authorization="true"> <http:header name="Accept" value='application/xml'/> <http:multipart media-type="multipart/form-data" boundary="boundary"> <http:header name="Content-Disposition" value='form-data; name="foobar"'/> <http:body media-type="application/json" method="text"/> </http:multipart> </http:request>
$bodies的值为("42"),但始终收到MarkLogic返回的错误:
XDMP-ENDPOINTINVALIDPARAM: foobar has an invalid value per the endpoint declaration
用Postman及curl命令调用该服务均正常,换用其他XQuery HTTP Client库也能成功调用,原因是ExPath HTTP Client会在请求体各部分自动添加Content-Type,导致MarkLogic解析失败:
错误的请求负载:
--boundary Content-Disposition: form-data; name="foobar" Content-Type: application/json; charset=UTF-8 42 --boundary--
正常的请求负载:
--boundary Content-Disposition: form-data; name="foobar" 42 --boundary--
请问:
- 若带Content-Type的负载符合multipart/form-data规范,MarkLogic是否应支持这种格式?
- ExPath HTTP Client是否有禁用自动添加Content-Type的方法?
- 是否有其他序列化数据服务参数的方式?
内容的提问来源于stack exchange,提问作者S. Sire
相关产品推荐
相关产品推荐

