Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight to self hosted WCF
    primarykey
    data
    text
    <p>I have a silverlight application which has a WCF in it. Since it is a self hosted WCF I've understand I have to add an interface something like:</p> <pre><code>[ServiceContract] public interface IPolicyRetriever { [OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")] Stream GetSilverlightPolicy(); [OperationContract, WebGet(UriTemplate = "/crossdomain.xml")] Stream GetFlashPolicy(); } </code></pre> <p>and the implemetation:</p> <pre><code>Stream StringToStream(string result) { WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml"; return new MemoryStream(Encoding.UTF8.GetBytes(result)); } public Stream GetSilverlightPolicy() { string result = @"&lt;?xml version=""1.0"" encoding=""utf-8""?&gt; &lt;access-policy&gt; &lt;cross-domain-access&gt; &lt;policy&gt; &lt;allow-from http-request-headers=""*""&gt; &lt;domain uri=""*""/&gt; &lt;/allow-from&gt; &lt;grant-to&gt; &lt;resource path=""/"" include-subpaths=""true""/&gt; &lt;/grant-to&gt; &lt;/policy&gt; &lt;/cross-domain-access&gt; &lt;/access-policy&gt;"; return StringToStream(result); } public Stream GetFlashPolicy() { string result = @"&lt;?xml version=""1.0""?&gt; &lt;!DOCTYPE cross-domain-policy SYSTEM ""http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd""&gt; &lt;cross-domain-policy&gt; &lt;allow-access-from domain=""*"" /&gt; &lt;/cross-domain-policy&gt;"; return StringToStream(result); } </code></pre> <p>but I don't understand the next steps I have to do in order the silverlight calls to WCF will not raise communcation exception.</p> <p>Can you please show me the code I have to write and where? (when I google it I didn't understand when the WCF calls to retrive the clientaccesspolicy, and what is the endpoint I have to add, I'm new to silverlight and WCF and don't know exaclty why I have to add an endpoint...)</p> <p>this is my ServiceReference.ClientConfig:</p> <pre><code> &lt;configuration&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"&gt; &lt;security mode="None" /&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="http://localhost:4693/MapService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService" name="BasicHttpBinding_IMapService" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </code></pre> <p>thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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