我有一个xml文件,其中包含iefile.xml
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<authorise xmlns="http://tempuri.org/">
<value1>{0}</value1>
<value2>{1}</value2>
</authorise>
</soap12:Body>
</soap12:Envelope>
我有一个asmx网络服务,我称之为:
string[] data = { "Value1", "Value2"};
using (WebClient client = new WebClient())
{
client.Proxy = null;
client.Headers.Add(HttpRequestHeader.ContentType, "application/soap+xml; charset=utf-8");
client.Headers.Add("SOAPAction", "http://tempuri.org");
StreamReader reader = new StreamReader(path); //path to xml file i.e file.xml
MyData = String.Format(reader.ReadToEnd(), data);
reader.Close();
ServicePointManager.Expect100Continue = true;
ServicePointManager.ServerCertificateValidationCallback +=
delegate(
object sender1,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
rst = client.UploadString(new Uri(https://myasmxwebservice.asmx), MyData); //Throws exception from here
}
它一直工作正常,直到我开始出错 “基础连接已关闭:接收时发生意外错误。”我不知道这个问题,也不知道如何解决它。