Im calling a locally hosted wcf service from silverlight and I get the exception below.
Iv created a clientaccesspolicy.xml, which is situated in the route of my host.
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
An error occurred while trying to make a request to URI 'http://localhost:8005/Service1.svc'. This could be due to a cross domain configuration error. Please see the inner exception for more details. --->
{System.Security.SecurityException ---> System.Security.SecurityException: Security error. at MS.Internal.InternalWebRequest.Send() at System.Net.BrowserHttpWebRequest.BeginGetResponseImplementation() at System.Net.BrowserHttpWebRequest.InternalBeginGetResponse(AsyncCallback callback, Object state) at System.Net.AsyncHelper.<>c__DisplayClass4.b__3(Object sendState) --- End of inner exception stack trace --- at System.Net.AsyncHelper.BeginOnUI(BeginMethod beginMethod, AsyncCallback callback, Object state) at System.Net.BrowserHttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteSend(IAsyncResult result) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.OnSend(IAsyncResult result)}
Any ideas on how to progress?
there are some debugging techniques listed here..one more useful post..
I know the service is working correctly, because I added it as a reference to a basic website and it worked. I'll try to play with Fiddler, although there is a slight issue as the xaml control is not embedded into a web page, its using the inbuilt testpage renderer.
Here is a few pointers that iv found that need to be checked:
Adding a clientaccesspolicy.xml as a shown my question.
Adding a crossdomain.xml to the host route:
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
Ensure binding is basicHttp as this is the only one supported by silverlight(currently)
The service needs this attribute:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
Useful reads: http://weblogs.asp.net/tolgakoseoglu/archive/2008/03/18/silverlight-2-0-and-wcf.aspx
http://timheuer.com/blog/archive/2008/06/06/changes-to-accessing-services-in-silverlight-2-beta-2.aspx
http://silverlight.net/forums/t/19191.aspx
http://timheuer.com/blog/archive/2008/04/09/silverlight-cannot-access-web-service.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With