2009-03-17 16 views
3

Ich habe einen SOAP-Web-Service zu einer Konsolen-App hinzugefügt, und jedes Mal, wenn ich einen bestimmten Anruf tätige, wird das Zeitlimit überschritten. Andere Anrufe funktionieren gut. Wie verlängere ich die Timeout-Länge in einer Konsolen-App? Scheint so, als ob es momentan ungefähr 90 Sekunden sind.Zeitlimit für SOAP-Anfragen in der Konsolen-App (.NET)

Danke.

Antwort

5

Sie die Web-Service-Client-Timeout kann durch die Timeout Eigenschaft festlegen. Der Standardwert ist 100000 Millisekunden (100 Sekunden).

Zum Beispiel:

MyWebServices.Webservice svc = new MyWebServices.Webservice(); 
// Set timeout to 200 seconds 
svc.Timeout = 200000; 
svc.DoWork(); 
0

Dies sollte Ihnen ermöglichen, das Timeout zu ändern und dann zu überprüfen, dass es geändert wurde.

public int Zeitlimit {get; einstellen; }

[Transaktion (Timeout = 30)] public class TransactionAttribute_Timeout: ServicedComponent { public void TimeoutExample() { // Holen Sie sich das Transaction auf die Klasse angewendet. TransactionAttribute-Attribut = (Transaktionsattribut) Attribute.GetCustomAttribute ( this.GetType(), typeof (Transaktionsattribut), false);

// Display the current value of the attribute's Timeout property. 
    Console.WriteLine("TransactionAttribute.Timeout: {0}", 
     attribute.Timeout); 

    // Set the Timeout property value of the attribute to sixty 
    // seconds. 
    attribute.Timeout = 60; 

    // Display the new value of the attribute's Timeout property. 
    Console.WriteLine("TransactionAttribute.Timeout: {0}", 
     attribute.Timeout); 
} 

}