I've got the following method and it behaves properly, as expected.
[OperationContract]
[WebGet(UriTemplate = "GetStuff", ResponseFormat = WebMessageFormat.Json)]
public String GetListOfTemplates()
{
String result = "time is " + DateTime.Now.ToString("HH:mm:ss");
try
{
String url = "...";
WebRequest request = WebRequest.Create(url);
}
catch (Exception exception)
{
result = exception.Message + "\n\n" + exception.InnerException.Message;
}
return result;
}
However, adding an actual read to it, as exemplified e.g. here, I get the following error, so the method below doesn't work.
The server encountered an error processing the request. See server logs for more details.
[OperationContract]
[WebGet(UriTemplate = "GetStuff", ResponseFormat = WebMessageFormat.Json)]
public String GetListOfTemplates()
{
String result = "time is " + DateTime.Now.ToString("HH:mm:ss");
try
{
String url = "...";
WebRequest request = WebRequest.Create(url);
using (Stream stream = request.GetResponse().GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
result = reader.ReadToEnd();
}
catch (Exception exception)
{
result = exception.Message + "\n\n" + exception.InnerException.Message;
}
return result;
}
There's of course the matter of why it doesn't work and how to resolve it but what baffles me (and stops me from debugging) is that the exception isn't caught and presented to the client. Also, I have no idea how to check the logs on server, since it's Azure and I'm generally confused when I don't get me dose of message in an exception. :)