2016-06-28 2 views
0

IIS 인증을 기본 = 기본으로 설정하고 login = pda 및 password = xxx로 계정 창을 만듭니다.wcf REST Ping timeout

하지만 내 클라이언트가 내 서비스에 액세서 때이 코드를 삭제하면, 내가 메시지 제한 시간

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; 
      } 

을 가지고 :

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

내가 오류 (401)를 얻었다을 :위한 인증은

난을

실패 이 코드를 삭제했습니다 :

myRequest.ContentLength = 0; 

오류 411 : 길이가 필요합니다.

하지만 지금은, 내가 제한 시간이 지연되었다가

내 Web.config의 만료했다 : Windows를 사용하는 것 같습니다

<services> 
     <service name="WcfService_REST_SuiviColis.Service1" > 
      <endpoint address="" binding="webHttpBinding" contract="WcfService_REST_SuiviColis.IService1" bindingConfiguration="BasicHttpEndpointBinding" /> 
     </service> 
    </services> 

    <behaviors>  
     <serviceBehaviors> 
      <behavior name="ServiceBehaviour"> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior>   
     </serviceBehaviors> 
     <endpointBehaviors> 
      <behavior name="web"> 
       <dataContractSerializer maxItemsInObjectGraph="2147483647" />     
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 

    <bindings> 
     <webHttpBinding> 
     <binding name="BasicHttpEndpointBinding" 
       maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" 
      receiveTimeout="00:10:00" 
      sendTimeout="00:10:00" 
      openTimeout="00:10:00" 
      closeTimeout="00:10:00"> 
      <security mode="TransportCredentialOnly" > 
       <transport clientCredentialType="Basic" />     
      </security> 
     </binding> 
    </webHttpBinding> 
    </bindings> 


<serviceHostingEnvironment multipleSiteBindingsEnabled="false" aspNetCompatibilityEnabled="true"> 
    <serviceActivations> 
     <add 
      factory="System.ServiceModel.Activation.WebServiceHostFactory" 
      relativeAddress="Service1.svc" 
      service="WcfService_REST_SuiviColis.Service1" /> 
    </serviceActivations> 
</serviceHostingEnvironment> 

답변

0

는 기본 인증에 대해 차지한다. Windows 인증을 사용하여 IIS 인증을 설정해야합니다.

+0

감사합니다.하지만 기본 인증을 어떻게 만들 수 있습니까? – user609511