我知道有很多关于 Web 客户端的问题,但这里有一个新问题。:) 我想在 Web 客户端的帮助下发布一个 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);
谢谢你。