为了向 a 发送消息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
.