我正在尝试将一些代码从shell脚本移动到erlang以获取新的内部工具.
当前的shell脚本调用curl,如下所示:
curl \
--header "Content-type: text/xml; charset=utf-8" \
--data @$OTAR_SOAP_FILE \
--output $OTAR_OUT_FILE \
--stderr $OTAR_ERR_FILE \
--insecure \
$OTAR_URL
Run Code Online (Sandbox Code Playgroud)
我希望能够使用inets的库从erlang中做同样的事情.
这是我到目前为止所做的,但它不起作用:
stress(Url, Message, ConcurrentAttempts, Attempts) ->
setup_connection(),
{ok, {{Version, ResponseCode, ReasonPhrase}, Headers, Body}} =
httpc:request(get, {Url, [], "text/xml", Message}).
Run Code Online (Sandbox Code Playgroud)
在这种情况下,URL与$ OTAR_URL相同,Message是$ OTAR_SOAP_FILE的内容.
我如何通过curl传递来自erlang中soap文件的OTAR_URL数据?
你正在使用httpc:request/2,它需要两个参数:一个Url和一个Profile.您将'get'作为URL传递,将元组作为Profile传递,这显然是错误的:
httpc:request(get, {Url, [], "text/xml", Message}).
Run Code Online (Sandbox Code Playgroud)
您可能希望查看httpc:request函数的其他变体,例如httpc:request/4.
请注意,始终添加您获得的特定错误.它通常包含错误的原因,并使其他用户更容易发现实际问题.
| 归档时间: |
|
| 查看次数: |
2904 次 |
| 最近记录: |