Java 通过属性文件传递服务器URL在apache http客户端中不起作用

Java 通过属性文件传递服务器URL在apache http客户端中不起作用,java,http-status-code-404,apache-httpclient-4.x,properties-file,Java,Http Status Code 404,Apache Httpclient 4.x,Properties File,我试图通过属性文件读取url,并将其传递到apache http post构造函数。当我这样做时,我得到404错误,当硬编码时,它工作正常。我不知道这两种方法之间的区别。从属性文件中读取后,我在控制台上打印变量,它显示的是准确的url,但当我在http apache客户端中传递相同的字符串变量时,我得到了“404未找到”。有人能指导我吗?谢谢 阅读网址: requestURL = MWTConfiguration.getInstance().getValue("NPCI_AUTH_URL

我试图通过属性文件读取url,并将其传递到apache http post构造函数。当我这样做时,我得到404错误,当硬编码时,它工作正常。我不知道这两种方法之间的区别。从属性文件中读取后,我在控制台上打印变量,它显示的是准确的url,但当我在http apache客户端中传递相同的字符串变量时,我得到了“404未找到”。有人能指导我吗?谢谢

阅读网址:

    requestURL = MWTConfiguration.getInstance().getValue("NPCI_AUTH_URL");
                System.out.println("Request URL :"+requestURL);
                objAuthRequest.setPid(objFITransXTRequest.getPid());
                objAuthRequest.setRbd(""); 
 authResponse =objMWTHttpClient.execute(strRequestJson, requestURL);  
客户端代码:

public String execute(String requestData, String strURL) throws ParseException, Exception {
        String strResponse = "";
        StringBuffer objSBuffer = new StringBuffer();
        try {
            HttpClient httpClient = HttpClientBuilder.create().build();
            System.out.println("URLLLL : :"+strURL);
            HttpPost reqFundTransf = new HttpPost(strURL);
            StringEntity params = new StringEntity(requestData);
            reqFundTransf.addHeader("content-type", "application/json");
            reqFundTransf.setEntity(params);
            HttpResponse objResponse = httpClient.execute(reqFundTransf);
            HttpEntity objRespEntity = objResponse.getEntity();
            BufferedReader objBReader = new BufferedReader(new InputStreamReader(objRespEntity.getContent()));

            while ((strResponse = objBReader.readLine()) != null) {
                objSBuffer.append(strResponse);
            }

        } catch (Exception e) {
            throw new Exception(e);
        }
        return objSBuffer.toString();
控制台视图:

URLLLL : :http://223.30.66.28:8080/AEPSNPCI/rest/aepsauth/authentication
2017-03-14 16:08:27 DEBUG RequestAddCookies:122 - CookieSpec selected: best-match
2017-03-14 16:08:27 DEBUG RequestAuthCache:75 - Auth cache not set in the context
2017-03-14 16:08:27 DEBUG PoolingHttpClientConnectionManager:219 - Connection request: [route: {}->http://223.30.66.28:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2017-03-14 16:08:27 DEBUG PoolingHttpClientConnectionManager:250 - Connection leased: [id: 0][route: {}->http://223.30.66.28:8080][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2017-03-14 16:08:27 DEBUG MainClientExec:217 - Opening connection {}->http://223.30.66.28:8080
2017-03-14 16:08:27 DEBUG HttpClientConnectionOperator:120 - Connecting to /223.30.66.28:8080
2017-03-14 16:08:27 DEBUG HttpClientConnectionOperator:127 - Connection established 10.9.31.135:44782<->223.30.66.28:8080
2017-03-14 16:08:27 DEBUG MainClientExec:238 - Executing request POST /AEPSNPCI/rest/aepsauth/authentication HTTP/1.1
2017-03-14 16:08:27 DEBUG MainClientExec:243 - Target auth state: UNCHALLENGED
2017-03-14 16:08:27 DEBUG MainClientExec:249 - Proxy auth state: UNCHALLENGED
2017-03-14 16:08:27 DEBUG headers:124 - http-outgoing-0 >> POST /AEPSNPCI/rest/aepsauth/authentication HTTP/1.1
2017-03-14 16:08:27 DEBUG headers:127 - http-outgoing-0 >> content-type: application/json
2017-03-14 16:08:27 DEBUG headers:127 - http-outgoing-0 >> Content-Length: 729
2017-03-14 16:08:27 DEBUG headers:127 - http-outgoing-0 >> Host: 223.30.66.28:8080
2017-03-14 16:08:27 DEBUG headers:127 - http-outgoing-0 >> Connection: Keep-Alive
2017-03-14 16:08:27 DEBUG headers:127 - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.4 (java 1.5)
2017-03-14 16:08:27 DEBUG headers:127 - http-outgoing-0 >> Accept-Encoding: gzip,deflate
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "POST /AEPSNPCI/rest/aepsauth/authentication HTTP/1.1[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "content-type: application/json[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "Content-Length: 729[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "Host: 223.30.66.28:8080[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java 1.5)[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 >> "[\r][\n]"
2017-03-14 16:08:27 DEBUG wire:86 - http-outgoing-0 >> "{"modality":{"fp":true,"otp":false},"uidNumber":"496640436689","rrn":"707316193975","pid":"YUVIL7CKWbBjFV+UCZBKGMnLJeHSNJjrZ6r+0kyfMZl0VEKNeIHyeaXFPLsYXyxJ9qISBTPmN/4qrS82AT781Q\u003d\u003d","rbd":"","hmac":"XuVPiZ9kLxHSAzxzyFqu+eY18F1bQVqOzjbGF7Pc21L2ohIFM+Y3/iqtLzYBPvzV","ci":"20170227","sKey":"lrq66RF9C0H00tFVA3MjRRui0NFyM/1BlYxfJkzHFZhrWaLt1xpUd7M1z1skeXqJwNmB7Ygcyht22Tqr701eHSiZTKWl6N4gJLDr4EZjDB+OYqDTg28qSiHC3/TDvASr9m+F0ymKZhAdw7aASf+ZCxpkdjBOI/FzaIlTo67r9azYeVKPd/53bnpOvboxUdpt0coI8ElheTArcE5xQVDVC3Y5iJYkARjVgRonrjWSLlb0D9WzZ2Aolq2vnwo7nnglb0uqiqanUUrStqK//MNcVq5R5acu5hZv83XZNH0m/4v1+Ku3zQp0Kuc6nRNkE0M6f+LKZJ8JlkeSnIwoubFA1Q\u003d\u003d","metaData":{"udc":"AX20123","pip":"10.230.23.24","lot":"P","lov":"244221"}}"
2017-03-14 16:08:27 DEBUG wire:72 - http-outgoing-0 << "HTTP/1.1 404 Not Found[\r][\n]" 
urlll::http://223.30.66.28:8080/AEPSNPCI/rest/aepsauth/authentication
2017-03-14 16:08:27调试请求添加cookies:122-CookieSpec选择:最佳匹配
2017-03-14 16:08:27调试请求验证缓存:75-未在上下文中设置验证缓存
2017-03-14 16:08:27调试池客户端连接管理器:219-连接请求:[路由:{}->http://223.30.66.28:8080][保持活动状态的总数:0;分配的路由:0,共2条;分配的总数:0,共20条]
2017-03-14 16:08:27调试池客户端连接管理器:250-租用连接:[id:0][路由:{}->http://223.30.66.28:8080][保持活动状态的总数:0;分配的路由:1/2;分配的总数:1/20]
2017-03-14 16:08:27调试MainClientExec:217-打开连接{}->http://223.30.66.28:8080
2017-03-14 16:08:27调试HttpClientConnection操作员:120-连接到/223.30.66.28:8080
2017-03-14 16:08:27调试HttpClientConnectionOperator:127-连接已建立10.9.31.135:44782223.30.66.28:8080
2017-03-14 16:08:27调试MainClientExec:238-执行请求POST/AEPSNPCI/rest/aepsauth/authentication HTTP/1.1
2017-03-14 16:08:27调试主客户端执行C:243-目标身份验证状态:未被质疑
2017-03-14 16:08:27调试主客户端执行C:249-代理身份验证状态:未被质疑
2017-03-14 16:08:27调试头:124-http-outgoing-0>>POST/AEPSNPCI/rest/aepsauth/authentication http/1.1
2017-03-14 16:08:27调试头:127-http-outgoing-0>>内容类型:application/json
2017-03-14 16:08:27调试头:127-http-outgoing-0>>内容长度:729
2017-03-14 16:08:27调试头:127-http-outgoing-0>>主机:223.30.66.28:8080
2017-03-14 16:08:27调试头:127-http-outgoing-0>>连接:保持活动状态
2017-03-14 16:08:27调试头:127-http-outgoing-0>>用户代理:Apache HttpClient/4.3.4(java 1.5)
2017-03-14 16:08:27调试头:127-http-outgoing-0>>接受编码:gzip,deflate
2017-03-14 16:08:27调试连线:72-http-OUTING-0>>“POST/AEPSNPCI/rest/aepsauth/authentication http/1.1[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-outing-0>>“内容类型:application/json[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-outing-0>>“内容长度:729[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-OUTING-0>>“主机:223.30.66.28:8080[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-OUTING-0>>“连接:保持活动[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-outing-0>>“用户代理:Apache HttpClient/4.3.4(java 1.5)[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-outing-0>>“接受编码:gzip,deflate[\r][\n]”
2017-03-14 16:08:27调试连线:72-http-outing-0>>“[\r][\n]”
2017-03-14 16:08:27调试线路:86-http-outgoing-0>>“{”模式:{“fp”:true,“otp”:false},“uidNumber:“496640436689”,“rrn:“707316193975”,“pid:“YUVIL7CKWbBjFV+UCZBKGMNLJEHSNJRZ6R+0KYFMZL0VEKNEYEAXFSYXYXJ9QISBTPMN/4QR2AT781Q\u003d\u003d”,“rbd:“hmac:”XHAC:“XUVPIZZZQQQU018FZFZYZFZZZFZFZZZY7FK+2017FZYZFZYZFZFZFZFZFZFZFZFZZFZZF3”;“2017FZFZFZFZFZFZFZFZFZ斯凯“:”研究结果表明,这一问题是一个关于某一领域的研究成果。一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究成果,一个关于某一领域的研究,或者某一领域的研究成果,或者某一个领域的某某一领域的某一方面,或者某一个研究,或者某某一领域的某一领域的某一领域的某一方面,或者某一个研究的某一领域的某一研究成果,或者某某一领域的某一方面的某某一方面,或者某某一领域的某一领域的某某某一领域的某一领域的某某一领域的某某一领域的某一领域的某一领域的某一领域的某一领域的某8JLKESNIWOUBFA1Q\u003d\u003d,“元数据”:{“udc”:“AX20123”,“pip”:“10.230.23.24”,“lot”:“P”,“lov”:“244221”}”

2017-03-14 16:08:27调试连线:72-http-OUTING-0使用微调功能字符串的结尾或开头可能有空白


HttpPost reqFundTransf=新的HttpPost(strURL.trim())

尝试将其更改为反斜杠

属性文件中提到的url中可能缺少正斜杠的转义字符


尝试在正斜杠前使用“\/”。

你能
curl
那个URL吗?curl?这是什么?你能告诉我一个关于旋度的有用链接吗?你能用任何其他方式向那个端点发布任何东西吗?是的,通过使用postman,我可以点击并获得响应,还可以在http post构造函数中硬编码url。您是否尝试url编码和解码?抱歉,如果您在属性文件中有如下url,我无法理解如何使用此“\/”:尝试将其更改为http:\///223.30.66.28:8080\//AEPSNPCI\//rest\//aepsauth\//Authentication我做到了,但是,如果得到相同的响应,请尝试在身份验证结束时再添加一个斜杠。连接正在建立,但post请求/AEPSNPCI/rest/aepsauth/authentication HTTP/1.1正在失败。