Apache HttpClient、Cisco VoIP Phone - POST CGI 执行 CiscoIpPhone错误 1

Apache HttpClient, Cisco VoIP Phone - POST CGI Execute CiscoIpPhoneError 1

为了向 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>            
    """;

使用的 URLIP 地址类似

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.

HTTP POST 的内容应为 application/x-www-form-urlencoded 格式,因此指定正确的内容 header 并对 XML=[data] 进行编码,类似于:

POST /CGI/Execute HTTP/1.1
Host: 10.99.58.26
Authorization: Basic ZHN0YXVkdDpwYXNzd29yZA==
User-Agent: curl/7.74.0
Accept: */*
Content-Length: 427
Content-Type: application/x-www-form-urlencoded

XML=%3CCiscoIPPhoneText%3E%0A%20%20%20%20%3CText%3EHello%20World%3C%2FText%3E%0A%20%20%20%20%3CSoftKeyItem%3E%0A%20%20%20%20%20%20%20%20%3CName%3ECustom%3C%2FName%3E%0A%20%20%20%20%20%20%20%20%3CURL%3ENotify%3Ahttp%3A10.24.152.227%3A8080%3Atestpath%3AZHN0YXVkdDpwYXNzd29yZA%3D%3D%3Atestdata%3C%2FURL%3E%0A%20%20%20%20%20%20%20%20%3CPosition%3E1%3C%2FPosition%3E%0A%20%20%20%20%3C%2FSoftKeyItem%3E%0A%3C%2FCiscoIPPhoneText%3E%0A

(交叉发布于 https://community.cisco.com/t5/other-collaboration-subjects/tesxt-message-to-voip-phone-ciscoripphoneerror-1/m-p/4435874