使用 erlang 洗涤剂库在 soap 调用中传递 oauth header

Pass oauth header in soap call with erlang detergent library

我正在使用 detergent 对 salesforce soap api 进行 soap 调用。 我想调用它的函数 call/4 但它失败了:

:detergent.call("metadata.wsdl", "describeMetadata", ["37.0"], [{'sessionId',token.access_token}])


** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in :erlsom_write.processAnyAttributes/4
    src/erlsom_write.erl:501: :erlsom_write.processAnyAttributes('ok', [], [{:ns, 'http://schemas.xmlsoap.org/soap/envelope/', 'soap', :unqualified}, {:ns, 'http://soap.sforce.com/2006/04/metadata', 'p', :qualified}, {:ns, 'http://www.w3.org/2001/XMLSchema', 'xsd', :qualified}], {[{'soap', 'http://schemas.xmlsoap.org/soap/envelope/'}], 0})
    src/erlsom_write.erl:325: :erlsom_write.processAlternativeValue/8

传递令牌的 header 语法的预期格式是什么?

您正在使用 detergent.call/4 that expects the last parameter to be a #call_opts。您正在传递一个列表 [由单个元组组成] 并且函数子句无法匹配。

我不确定你到底要传递什么(参见 #call_opts definition,)但我相信像下面这样的东西应该可以解决问题:

:detergent.call(
  "metadata.wsdl",
  "describeMetadata",
  ["37.0"],
  #call_opts{http_client_options=[{'sessionId',token.access_token}]}
)