Ich habe derzeit das Problem, das keine Exceptions weiter getriggert werden bei einem WebService. Ich kann mir jedoch nicht erklären warum.
// Initialize servicehost with with this as singletoninstance
_serviceHost = new WebServiceHost(this);
var endpoint = _serviceHost.AddServiceEndpoint(service,
new WebHttpBinding(WebHttpSecurityMode.None),
new Uri(game.BaseAddress, name));
// Enable the help page for service
endpoint.Behaviors.Add(new WebHttpBehavior {
HelpEnabled = true, FaultExceptionEnabled = true });
/// <summary>
/// The ITestService Interface
/// </summary>
[ServiceContract]
public interface ITestService
{
// --------------------------------------------------------
// Interface Functions
// --------------------------------------------------------
[OperationContract]
[WebGet(UriTemplate="/Greeting?name={name}",
RequestFormat=WebMessageFormat.Json,
ResponseFormat=WebMessageFormat.Json)]
[Description("Returns a simple greeting text with your name.")]
String Greeting(String name);
} // interface ITestService
public String Greeting(String name)
{
throw new Exception("ex");
return "Hello " + name + ", welcome to Nations War! " +
"You are visitor number " + _counter++;
} // Greeting
Wenn ich jetzt Greeting aufrufe stürzt die Anwendung ab mit einer nicht behandelten Fehlermeldung, jedoch müsste doch der WebService so etwas abfangen und dem User schicken?
MFG Wolf