各位好!请教个问题:
我有一个silverlight网站与wcf通信。silverlight网站与WCF服务在不同域内,WCF服务的ENDPOINT使用的是内网IP。当我用内网IP访问silverlight时能正常访问到WCF服务,但当我通过外网IP去访问silverlight时就出现以下错误,不知道怎么解决?是不是WCF服务的ENDPOINT也要暴露到外网才可以?
补充下:我测试的电脑跟silverlight网站在同一个域内,用out brower模式不会出现此问题。但是用公司以外的电脑,两种模式都不行,而且没有请示错误
消息: Unhandled Error in Silverlight Application 安全性错误。 位于 System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
位于 System.Net.Sockets.HttpPolicyDownloaderProtocol.DownloadCallback(IAsyncResult ar)
位于 System.Net.Sockets.HttpPolicyDownloaderProtocolCallbacks.DownloadCallback(IAsyncResult result)
位于 System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass1a.<InvokeGetResponseCallback>b__18(Object state2)
位于 System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
位于 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
位于 System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
位于 System.Threading.ThreadPoolWorkQueue.Dispatch()
行: 1
字符: 1
代码: 0
WCF配置:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpBindConfig" maxReceivedMessageSize="2147483647" transferMode="Buffered" receiveTimeout="00:30:00" closeTimeout="24.00:00:00" openTimeout="24.00:00:00">
<reliableSession inactivityTimeout="00:05:00" />
<!--每次最大发送数据流大小-->
<readerQuotas maxArrayLength="2147483647" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="PSIMServer.Behavior" name="PSIMServer.Service">
<host>
<baseAddresses>
<add baseAddress="net.tcp://10.60.6.126:4502/Service" />
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" contract="PSIMServer.IService" bindingConfiguration="netTcpBindConfig" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PSIMServer.Behavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
策略文件:
<?xml version="1.0" encoding ="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*" />
</allow-from>
<grant-to>
<socket-resource port="4502-4503" protocol="tcp" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
有没有配置好跨域访问策略文件。
有的
你应该把跨域文件跟wcf配置贴出来。这样才好给你找错误
跨域文件没有问题。用内网IP访问是正常的。用外网IP时的out brower模式打开silverlight也是正常的,就是用web 打开silverlight会出现js提示错误
@jomoleo:
策略文件换下试试呢
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
换Binding方式试下,别用tcp绑定,改成bacishttpbinding试下