Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to consume WCF in silverlight app
    text
    copied!<p>I want to know how I can consume a normal WCF service (not Silverlight enabled WCF service) in my Silverlight application. Here is what I tried</p> <ol> <li>I have created a simple normal WCF service</li> <li>I changed the binding to <code>basicHttpBinding</code> in the <code>web.config</code> file</li> <li>I have placed <code>clientaccesspolicy.xml</code> and <code>crossdomain.xml</code> files in <code>wwwroot</code> folder.</li> </ol> <p>But even though I am unable to consume the WCF service. I get this exception</p> <blockquote> <p>System.ServiceModel.CommunicationException was unhandled by user code<br> Message=An error occurred while trying to make a request to URI 'http://localhost/HWT/HelloWorldService.svc'. 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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.<br> StackTrace:<br> at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)<br> at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)<br> at System.ServiceModel.ClientBase<code>1.ChannelBase</code>1.EndInvoke(String methodName, Object[] args, IAsyncResult result)<br> at ServiceRef.HelloWorldServiceClient.HelloWorldServiceClientChannel.EndGetName(IAsyncResult result)<br> at ServiceRef.HelloWorldServiceClient.TestSilClient.ServiceRef.IHelloWorldService.EndGetName(IAsyncResult result)<br> at TestSilClient.ServiceRef.HelloWorldServiceClient.OnEndGetName(IAsyncResult result)<br> at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) </p> <p>InnerException: System.Security.SecurityException<br> Message=""<br> StackTrace:<br> at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)<br> at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)<br> at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) </p> <p>InnerException: System.Security.SecurityException<br> Message=Security error.<br> StackTrace:<br> at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)<br> at System.Net.Browser.BrowserHttpWebRequest.&lt;>c_<em>DisplayClass5.b</em>_4(Object sendState)<br> at System.Net.Browser.AsyncHelper.&lt;>c_<em>DisplayClass4.b</em>_1(Object sendState) </p> </blockquote> <p>Can anyone explain what is the best way to consume normal WCF service in a Silverlight app? An example will help me.</p> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload