net 调用接口,发现对方可以获取我方的请求,但是数据为空。求指教
下面是我调用接口的代码
参数:1.PostUrl : http://www.xxxxxx.gov.cn:81/RejectTaskPlanService.do?method=receiveTaskPlanFile
2.Parameters: 以XML格式推送的报文
public static string RwsPost(string PostUrl, string Parameters)
{
string content = string.Empty;
try
{
//转换为字节数组
byte[] bytesRequestData = Encoding.UTF8.GetBytes(Parameters);
//path不是登录界面,是登录界面向服务器提交数据的界面
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(PostUrl);
myReq.Method = "post";
myReq.ContentType = "application/x-www-form-urlencoded";
//填充POST数据
myReq.ContentLength = bytesRequestData.Length;
Stream requestStream = myReq.GetRequestStream();
requestStream.Write(bytesRequestData, 0, bytesRequestData.Length);
requestStream.Close();
//发送POST数据请求服务器
HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
//获取服务器返回信息
//StreamReader sr = new StreamReader(HttpWResp.GetResponseStream(),System.Text.Encoding.UTF8);
//content = sr.ReadToEnd();
Stream myStream = HttpWResp.GetResponseStream();
StreamReader reader = new StreamReader(myStream, Encoding.UTF8);
content = reader.ReadToEnd();
reader.Close();
HttpWResp.Close();
}
catch (Exception ex)
{
content = ex.ToString();
}
return content;
}
为什么对方可以获取我的请求,但获取的数据为空。