wcf REST Ping超时

时间:2016-06-28 09:16:42

标签: wcf rest ping

我设置了我的IIS Authentification = Basic,并使用login = pda和password = xxx创建帐户窗口。

但是当我的客户端访问我的服务时,我收到消息超时

<!doctype html>
<html>
<body>
    <video autoplay loop>
        <source src="big_buck_bunny.mp4" type="video/mp4">
    </video>
</body>
</html>

当我删除此代码时:

 public Stream PingServer()
        {

            //string LeUrl = "http://localhost:81/Code/WcfService_REST_SuiviColis/WcfService_REST_SuiviColis/Service1.svc";
            string LeUrl = "http://xxx.YYY.ZZZ/FA85/Service1.svc/";
            string Result = "",ErrPb="";
            try
            {
                var myRequest = (HttpWebRequest)WebRequest.Create(LeUrl);

                myRequest.Credentials = new System.Net.NetworkCredential("pda", "xxx");
                myRequest.Method = "PUT";
                myRequest.ContentLength = 0;

                var response = (HttpWebResponse)myRequest.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    // Si le serveur OK
                    Result = "OK - " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                }
                else
                {
                    //  Sinon on a le problem
                    Result = "KO - " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    ErrPb = response.StatusDescription + System.Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                // encore un autre problem             
                Result = "KO - " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                ErrPb += ex.Message + System.Environment.NewLine;
            }

我收到错误401:身份验证失败

当我删除此代码时:

myRequest.Credentials = new System.Net.NetworkCredential("pda", "xxx");
                myRequest.Method = "PUT";

我收到错误411:需要长度。

但现在,我的超时延迟已过期

和我的web.config:

myRequest.ContentLength = 0;

1 个答案:

答案 0 :(得分:0)

您似乎在使用Windows帐户进行基本身份验证。您应该使用Windows身份验证设置IIS身份验证。