我知道有很多关于Web客户端的问题,但这里有一个新问题。 :) 我想在Web Client的帮助下发布一个XmlDocument,但XML永远不会到达另一端。 Tomcat总是发送回java.lang.NullPointerException。
enter code here
System.Net.WebClient WebClientObj = new System.Net.WebClient();
WebClientObj.Encoding = Encoding.UTF8; ;// System.Text.Encoding.GetEncoding("UTF-8");
WebClientObj.Headers[HttpRequestHeader.ContentType] = "text/xml;charset=utf-8";
ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, X509Certificate certificate, X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
byte[] ByteArray = Encoding.UTF8.GetBytes(ecgrr.GetResponse(xmlDoc).InnerXml);
byte[] ResponseBuffer = WebClientObj.UploadData("https://x.x.x.x/abcd/Req", "POST", ByteArray);
OR
string x = WebClientObj.UploadString("https://x.x.x.x/abcd/Req", "POST", ecgrr.GetResponse(xmlDoc).InnerXml);
谢谢。