Silverlight - WCF get clientaccesspolicy on localhost -


i have silverlight application uses wcf communications server. both silverlight , wcf running on local machine (localhost). when silverlight makes call service fails aa communication exception. understand because don't have clientaccesspolicy file, since wcf endpoint running on http://localhost:port defined interface, ipolicyretriver, , added implementation service returning clientaccesspolicy in stream.

my question is, have configure run without problem? understand have change or add servicereference.clientconfig file, don't understand what. i've included servicereference.clientconfig below. please let me know change or add it, , in silverlight add code. please not paste links here me have opened every link during last 2 days - still don't understand.

<configuration> <system.servicemodel>     <bindings>         <basichttpbinding>             <binding name="basichttpbinding_imapservice" maxbuffersize="2147483647"                 maxreceivedmessagesize="2147483647">                 <security mode="none" />             </binding>         </basichttpbinding>     </bindings>     <client>         <endpoint address="../mapservice.svc" binding="basichttpbinding"             bindingconfiguration="basichttpbinding_imapservice" contract="mapservice.imapservice"             name="basichttpbinding_imapservice" />     </client> </system.servicemodel> 

help me please!

you haven't included ipolicyretriever implementation mention, here sample can use.

the interface specification:

[servicecontract] public interface ipolicyretriever {     [operationcontract, webget(uritemplate = "/clientaccesspolicy.xml")]     stream getsilverlightpolicy();      //[operationcontract, webget(uritemplate = "/crossdomain.xml")]     //stream getflashpolicy(); } 

the implementation of interface:

    // ipolicyretriever implementation     private stream stringtostream(string result)     {         weboperationcontext.current.outgoingresponse.contenttype = "application/xml";         return new memorystream(encoding.utf8.getbytes(result));     }      public stream getsilverlightpolicy()     {         string result = @"<?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>";          return stringtostream(result);      } 

then can include following in server's configuration xml file. needs on server side, not on client side. i'm emphasising because included client config above in question.

<behaviors>   <endpointbehaviors>     <behavior name="webhttpnewbehavior">       <webhttp />     </behavior>   </endpointbehaviors>   ... </behaviors> <services>   <service behaviorconfiguration="newbehavior">     <endpoint behaviorconfiguration="webhttpnewbehavior" binding="webhttpbinding"                 bindingconfiguration="" name="policyendpoint" contract="wcfservice.ipolicyretriever" />     ...   </service> </services> 

alternatively if decide create host programmatically (this how it, rather use clientconfig file, above sample might not 100% correct):

servicehost host = new servicehost(servicetype); host.addserviceendpoint(typeof(ipolicyretriever), new webhttpbinding(), "").behaviors.add(new webhttpbehavior()); 

i know asked not provide links used http://blogs.msdn.com/b/asiatech/archive/2010/05/07/how-to-consume-a-self-hosted-wcf-service-in-a-cross-domain-environment-by-silverlight-client.aspx reference refresh memory, because don't have access silverlight/wcf project right @ minute.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -