2016-06-28 4 views
0

IIS Authentification = Basicを設定し、login = pdaおよびpassword = xxxのアカウントウィンドウを作成しました。wcf REST PINGタイムアウト

が、私のクライアントは私のサービスにアクセスもときに私はこのコードを削除したとき、私はメッセージタイムアウト

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:長さが必要です。あなたは基本認証に対して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

しかし、今、私は遅れてタイムアウトが

を有効期限が切れて、私のweb.configいました。 Windows認証でIIS認証を設定する必要があります。

+0

ありがとうございます。しかし、どうすれば基本認証を行うことができますか – user609511