80,350
社区成员
发帖
与我相关
我的任务
分享
[SoapHeader("soapHeader")]
[WebMethod(Description = "测试参数为List<string> ")]
public string Test(List<string> iDList)
{
log.Info(iDList);
return ReturnFormatJson.WriteSuccess("", iDList);
}
public void Test() {
try {
List<String> iDList =new ArrayList<String>();
iDList.add("0000001");
iDList.add("0000002");
iDList.add("0000003");
JSONObject pParameters = new JSONObject();
pParameters.put("iDList", iDList);
HttpResponse response = post("Test", pParameters);
int code = response.getStatusLine().getStatusCode();
if (code == 200) {
String strEntity = EntityUtils.toString(response.getEntity());
} else {
response.getEntity().getContent().close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
protected HttpResponse post(String pMethodName, JSONObject pParameters) {
HttpResponse response = null;
String baseURL = Configure.WEBSERVICEURL + pMethodName;
try {
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
HttpClient httpclient = new DefaultHttpClient(httpParams);
HttpPost httppost = new HttpPost(baseURL);
// 添加http Header 信息
// httppost.setHeader("Range","bytes="+"");
httppost.setHeader("Accept", "application/json");
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
httppost.addHeader("CallName", "Vashion");
httppost.addHeader("CallPassword", "Vashion@Pass2016");
// 添加 json 参数
if (pParameters != null) {
httppost.setEntity(new StringEntity(pParameters.toString(), HTTP.UTF_8));
}
// execute
response = httpclient.execute(httppost );
} catch (IOException e) {
e.printStackTrace();
}
return response;
}