【发布时间】:2021-07-19 12:08:09
【问题描述】:
要向Cisco VoIP Phone 发送消息,我使用Apache HttpClient:
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new StringEntity(body, ContentType.TEXT_XML));
httpPost.addHeader(new BasicScheme().authenticate(usernamePasswordCredentials, httpPost, null));
XML 消息如下所示
String body =
"""
XML=
<CiscoIPPhoneText>
<Title>...</Title>
<Prompt>...</Prompt>
<Text>...</Text>
</CiscoIPPhoneText>
""";
使用的URL 与IP 地址类似
String url = "https://<ip-adress>/CGI/Execute";
Wenn 执行POST 请求
HttpResponse response = closeableHttpClient.execute(httpPost);
我收到状态码 400 和
<CiscoIPPhoneError Number="1"></CiscoIPPhoneError>
我不知道这意味着什么以及POST 请求的问题所在。
身份验证接缝已经成功,因为如果我删除部分httpPost.addHeader(new BasicScheme()... 然后我得到401。
【问题讨论】:
标签: apache-httpclient-4.x cisco cisco-axl