【问题标题】:Apache HttpClient, Cisco VoIP Phone - POST CGI Execute CiscoIpPhoneError 1Apache HttpClient、Cisco VoIP 电话 - POST CGI 执行 CiscoIpPhoneError 1
【发布时间】: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>            
    """;

使用的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

【问题讨论】:

    标签: apache-httpclient-4.x cisco cisco-axl


    【解决方案1】:

    HTTP POST 的内容应该是 application/x-www-form-urlencoded 格式,因此指定正确的内容标头并编码 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 1970-01-01
      • 2023-03-31
      相关资源
      最近更新 更多