If a web service I'm using throws a web exception, how can I get the details on what caused it
IE: Authentication failure etc.
Thanks!
If a web service I'm using throws a web exception, how can I get the details on what caused it
IE: Authentication failure etc.
Thanks!
Further details on WebException? How can I get them?
Seericssop
fill it with this content:
< xml version="1.0" encoding="UTF-8" >
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net" maxdatasize="1024">
<listeners>
<add name="MyTraceFile"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="MyTraceFile"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log"
/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
</switches>
</system.diagnostics>
</configuration>
it should create trace file for all System.Net stuff and exceptions too.
I'm sure it works with desktop .net framework, but give it a try for compact framework.
juraj
ArunBandy
.NETCF does not implement configuration classes so the approach given above will not work for compact framework.
To get more details of your exception do something like the following
try
{
// Call your WebService here
} catch(WebException wex){
StringBuilder sb = new StringBuilder();sb.Append(
String.Format("Messsage: {0}", wex.Message));sb.Append(
"\n");sb.Append(
"Status: " + wex.Status);sb.Append(
"\n"); if (null != wex.InnerException){
sb.Append(
"InnerException: " + wex.InnerException.ToString());sb.Append(
"\n");}
HttpWebResponse response = wex.Response as HttpWebResponse; if (null != response){
//Get the reason for the exception HttpStatusCode status = response.StatusCode; string _description = (int)status + "-" + status + response.StatusDescription; "\n");response.Close();
}
MessageBox.Show(sb.ToString());}
HTH.
Mark