首页 新闻 赞助 找找看

请教各位一个silverlight与WCF通信问题,

0
悬赏园豆:100 [已关闭问题] 关闭于 2012-01-13 14:41

各位好!请教个问题:
我有一个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>

jomoleo的主页 jomoleo | 初学一级 | 园豆:105
提问于:2012-01-12 10:19
< >
分享
所有回答(3)
0

有没有配置好跨域访问策略文件。

LCM | 园豆:6876 (大侠五级) | 2012-01-12 10:25

有的

支持(0) 反对(0) jomoleo | 园豆:105 (初学一级) | 2012-01-12 11:01
0

你应该把跨域文件跟wcf配置贴出来。这样才好给你找错误

aaroncao | 园豆:205 (菜鸟二级) | 2012-01-12 16:15

跨域文件没有问题。用内网IP访问是正常的。用外网IP时的out brower模式打开silverlight也是正常的,就是用web 打开silverlight会出现js提示错误

支持(0) 反对(0) jomoleo | 园豆:105 (初学一级) | 2012-01-12 16:28

@jomoleo: 

策略文件换下试试呢

<grant-to>

                <resource path="/include-subpaths="true"/>

            </grant-to>

 

支持(0) 反对(0) aaroncao | 园豆:205 (菜鸟二级) | 2012-01-12 18:52
0

换Binding方式试下,别用tcp绑定,改成bacishttpbinding试下

菩提树下的杨过 | 园豆:554 (小虾三级) | 2012-01-13 12:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册