aliyun / csb-sdk

The CSB-SDK is a client-side invocation SDK for HTTP or Web Service API opened by the CSB (Cloud Service Bus) product. It is responsible for invoking the open API and signing the request information.
Other
63 stars 48 forks source link

HTTP-Client Error: post a request url with " character #1

Closed walking98 closed 7 years ago

walking98 commented 7 years ago

Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in query at index 404: http://210.76.72.141:8086/service?ProcessType=webservice.CallWebService&ServerAppID=center_2/server&MenuID=dixianminsheng_to_xml&Locator=DataProcess&ServiceType=DataProcess__sxxzx_zhongxin_dixianminsheng&ServiceID=zhongxin_dixianminsheng_T29014_14AB010&User=dxmsQuery&PWD=9A21210789859D3F0A5C6031DF1B372C&ResultType=ResponseXML&ResponseNo=1&DWID=sxxzx&SecPwd=true&VarID=IdCard&VarValue=F29014_14AB010007="411121196410035030" at java.net.URI.create(URI.java:859) at org.apache.http.client.methods.HttpPost.(HttpPost.java:76) at com.alibaba.csb.sdk.internel.HttpClientHelper.createPost(HttpClientHelper.java:264) at com.alibaba.csb.sdk.HttpCaller.doPost(HttpCaller.java:865) at com.alibaba.csb.sdk.HttpCaller.doPost(HttpCaller.java:827) at com.alibaba.csb.sdk.HttpCaller.doPost(HttpCaller.java:1013) at test.Demo02.main(Demo02.java:21) Caused by: java.net.URISyntaxException: Illegal character in query at index 404: http://210.76.72.141:8086/service?ProcessType=webservice.CallWebService&ServerAppID=center_2/server&MenuID=dixianminsheng_to_xml&Locator=DataProcess&ServiceType=DataProcess__sxxzx_zhongxin_dixianminsheng&ServiceID=zhongxin_dixianminsheng_T29014_14AB010&User=dxmsQuery&PWD=9A21210789859D3F0A5C6031DF1B372C&ResultType=ResponseXML&ResponseNo=1&DWID=sxxzx&SecPwd=true&VarID=IdCard&VarValue=F29014_14AB010007="411121196410035030" at java.net.URI$Parser.fail(URI.java:2829) at java.net.URI$Parser.checkChars(URI.java:3002) at java.net.URI$Parser.parseHierarchical(URI.java:3092) at java.net.URI$Parser.parse(URI.java:3034) at java.net.URI.(URI.java:595) at java.net.URI.create(URI.java:857) ... 6 more

The HttpPost can not process the request url when it has a parameter like this VarValue=F29014_14AB010007="411121196410035030"

walking98 commented 7 years ago

fix it, urlencode the request url or parameters before invoke the HttpComponents. commit# 9d45ef2f0dcd84288ccdeb3574a963aa54575545