Silverlight自托管WCF

我有一个Silverlight应用程序,里面有一个WCF。 由于它是一个自托管的WCF我明白我必须添加一个类似的界面:
[ServiceContract]
public interface IPolicyRetriever
{
    [OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")]
    Stream GetSilverlightPolicy();
    [OperationContract, WebGet(UriTemplate = "/crossdomain.xml")]
    Stream GetFlashPolicy();
}
和实施:
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);
    }
    public Stream GetFlashPolicy()
    {
        string result = @"<?xml version=""1.0""?>
        <!DOCTYPE cross-domain-policy SYSTEM ""http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"">
        <cross-domain-policy>
            <allow-access-from domain=""*"" />
        </cross-domain-policy>";
        return StringToStream(result);
    }
但我不明白我必须做的下一步,以便对WCF的Silverlight调用不会引发通信异常。 你能告诉我我要写的代码吗? (当我google它时,我不明白WCF何时调用以检索clientaccesspolicy,以及我必须添加的端点是什么,我是Silverlight和WCF的新手,并且不知道为什么我必须添加端点的exaclty ...) 这是我的ServiceReference.ClientConfig:
    <configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:4693/MapService.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService"
                name="BasicHttpBinding_IMapService" />
        </client>
    </system.serviceModel>
</configuration>
谢谢!     
已邀请:
Silverlight Http堆栈(HTTP clientaccesspolicy.xml) 必须托管在目标域的根目录中。可以使用Web浏览器轻松检查。 Silverlight会自动检查一次。 Silverlight 3套接字(自定义策略服务器) 我已经为Silver2 for Log2Console app制作了这个策略服务器。 我认为此代码可能有助于SL Policy Server。 它必须托管在特殊端口TCP端口943上。 Silverligt 4个套接字(默认情况下与SL3一样,但可以选择加入HTTP) 将传递给Socket.ConnectAsync的SocketAsyncEventArgs上的SocketAsyncEventArgs.SocketClientAccessPolicyProtocol属性设置为SocketClientAccessPolicyProtocol.Http。 Silverlight可能的端口范围 80,443,4502-4532(如果在clientaccesspolicy.xml中允许) 详细文档     

要回复问题请先登录注册