How to diagnose client-side WCF issues in Silverlight environment? - wcf

It seems that WCF diagnostics is not available in SL. Is it because of limited System.Diagnostics support or something else? Anyway, how do you track client-side WCF issues when server-side diagnostics is not enough?

This is how I solved my problem of correctly obtaining exceptions at the Silverlight Client. Similar to Rus' but does not require wrapping of exceptions. Though it does require the version number to be exact in web.config (still working on solving that)
Programmatic configuration of Exception-sending in WCF

I think this article will help.
http://msmvps.com/blogs/theproblemsolver/archive/2009/01/27/returning-exception-information-to-a-silverlight-client-through-wcf.aspx

If you're getting a 'Not Found' Error the most likely cause is the cross domain access policy. What I use to try diagnose those problems is Fiddler2, and look at the raw traffic.

Are you sure that your WCF service is not faulting on the call? If something is going wrong on the server-side the returned message will be of HTTP status code 500. Due to security restrictions, the browser will not pass any non-200 messages back to the silverlight plugin which results in silverlight throwing the classic CommunicationException "The remote server returned an error: NotFound."
There are some pretty well documented work-arounds for using a WCF behavior to change the HTTP status code on the fault from 500 to 200 so silverlight will actually have access to the details of what went wrong. More info here:
http://msdn.microsoft.com/en-us/library/dd470096(VS.95).aspx
http://www.netfxharmonics.com/2009/07/Understanding-WCF-Faults-in-Silverlight-3

Related

WCF RIA Services fail with authentication error if service call is more than 20 seconds

I have a Silverlight application which uses WCF RIA services and WindowsAuthentication mode. When I deploy to our web server calls that are greater than 20 seconds in length seem to lose authentication and I get a dialog box from IE to re-enter my username and password.
Does anyone know how to fix this issue?
UPDATE: I found out that the issue had nothing to do with what Fiddler was indicating and the authentication dialog was a side effect of another issue.
When I turned on WCF diagnostic tracing I found that what was really happening was that the service was throwing an exception due to the max number of items in graph. My bindings in my web.config to override the service had an old service name so it was not picked up.
Based on this I would highly suggest that anyone having an issue turn on WCF diagnostic tracing on the web server and see what that says before following an error out of fiddler...
Thanks for the response to the post and your will to help out...
I think it should be caused by the timeout issue, take a look at following link:
receiveTimeout
Hope it help you. If it doesn't work, you may try to look at other timeouts, for example inactivityTimeout in reliable session.

Getting a MethodAccessException(in event log of server) and HTTP Error 401 Unauthorized(at client side) in WCF Rest Service in IIS6.0 Win2K3 enviorn

I wrote a WCF REST based service that uses webHttpBinding and uses JSON to post data.This service works fine in all of our internal environments. But in one of our environment which is exact replica of Production. It is not working. If I inspect in Firebug, I see "HTTP Error 401 Unauthorized" and in server I See following in the event log.
System.MethodAccessException
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous
MethodAccessException: System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(System.Web.HttpApplication, Boolean) at System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context)
I haven't pasted the whole event log. But,afore are the key parts of it.
I am not able to figure out what is happening, we are using custom httpmodule for authentication.
Need urgent help on this
Thanks in advance
From MSDN, a MethodAccessException occurs when you try to call a private/protected method from somewhere that you aren't allowed. This is thrown during reflection, which is more than likely what WCF is doing under the covers.
My bet is that one of your service methods is marked as private or protected.
This would work in your local environment because it's under Full Trust. Your production environment is most likely running in Medium Trust. (Under Medium Trust, you aren't allowed to bypass the accessibility modifiers.)
-- Tatham

Why do I get a 403 error when calling a WCF Webservice?

I'm really posting this question so that others searching for the answer can find it.
Scenario:
WCF Service: Has worked fine at some point but currently is returning 403 errors. The web.config looks fine as far as I can tell. This machine has set the web.config to disable transport and message security and is using BasicHTTPBinding.
When I call it with my client generated from the Service Reference in Visual Studio, I get a 403 error. The error indicates there is some problem with the authentication, but as far as I can tell there is no such problem.
To solve this problem, I used Fiddler to get the actual error code - in this case, a 403.1. This indicated that the executable for the service couldn't be run.
The actual problem ended up being that the ASP.NET version was set to 1.1, not 2.0+. So setting that to 2.0 resolved the 403 permission error.
Http 403 error is "Forbidden". There is something that is blocking access.
In cases where it worked at one point and then stopped, it is often a windows update that has tightend up the security.
Where is your WCF service installed?
What are the ACL's on these files?
What is the security context of your service? (Which account will be used to access the files)
Does that user have access to the files?

Self hosted cross domain WCF service called from silverlight hosted in sharepoint

as the title already states I am trying to call a self hosted WCF service (hosted in a windows service) from a silverlight 4.0 application which is hosted in sharepoint 2010. I use the basicHttpBinding and I already tried a lot of things as suggested here:
http://www.dotnetfunda.com/articles/article416.aspx
or here
http://blogs.msdn.com/b/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx
but none of them worked I still get the error:
An error occurred while trying to make a request to URI 'serviceuri'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. Please see the inner exception for more details.
The inner exception states:
when deploying an Office solution, check to make sure you have fullfilled all security requirements.
The two files clientaccesspolicy.xml and crossdomain.xml are accessible on http://myserver/clientaccesspolicy.xml and http://myserver/crossdomain.xml
Does anybody have an idea on how to solve this?
All these things helped me out. But the biggest thing for me was turning on Fiddler and tracing the request/responses from Sharepoint + Silverlight. I was getting a 502 error back for some reason. I noticed that my Url in my code was "http://localhost:", however the request from silverlight was "http://[servername]:" you would think that this should work, however it didn't.
I remembered I had run into issues before where "localhost" was giving me problems, thus what I did was to edit my Host file from /windows/system32/drivers/etc and simply add the line::
127.0.0.1 [servername]
I did a iisreset, I left fiddler running and I unchecked the Enable IPv6 option (Tools->Fiddler Options) and everything started working. The Clientaccesspolicy.xml could be accessed, and sharepoint + silverlight could call out into the wcf world :)!!!
There was one major issues however, when you turn Fiddler off, it stopped working... Now I have to figure this one out...
I hope this hellps you.

WCF Service Error

I have a WCF service deployed on a windows 2003 server. We are using a WPF application to consume this service. The trouble is if we deploy a new version of WCF service or leave the IIS and WPF application idle for sometime and then try to execute a functionality, we are get the following exception:
The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 119 bytes of the response were:'<HEAD><TITLE>500: Server Error [20-0004]</TITLE></HEAD>
<BODY>
<H1>500: Server Error [20-0004]<H1>
</BODY>
</HTML>
Thanks and Regards,
A 500 error usually means there was an unhandled exception in the service. Look in the Windows event logs to see what happened.
It looks like you are creating a proxy / connection to the server, then leaving it open and using this proxy when needed.
There are two problems with this:
The problem you are getting due to timeout in periods of inactivity.
That the connection is maintained when it is not used reduces scalability.
A better way to do it is to create the proxy connection when you require it, then close / dispose of it after it gas been used. Normally I use the using statement for this.
when you get below mentioned error
500: Server Error [20-0004]
This is siteminder Web Agent error, If your website is SSO protected, then it might have Siteminder ISAPI issue with initializing.
Check Event and SSO logs.
Origin Blog