惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
J
Java Code Geeks
G
Google Developers Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Vercel News
Vercel News
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
Y
Y Combinator Blog
博客园_首页
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
A
About on SuperTechFans
B
Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - MonkChen

使用阿里云Java SDK 实现 DDNS Ehcache3.4 XML配置硬盘存储 Tesseract训练 Postgresql Jsonb字段内含数组属性的删除元素操作 Activiti开启SQL Log Drools mvel方言drl断点调试方法 Openfire 编译插件 mysql数据备份 Silverlight 缓存控制策略 Silverlight ComboBox with TreeView WCF CustomBinding 身份验证 CMF Android !No Launcher activity found错误 Android SDK Manager 无法获取列表的解决 Silverlight跨域调用gSoap/Java web service 以及wsdl文件的修改 gSOAP契约函数返回结构体(返回多个值) java jax-ws发布含有DateTime字段的实体的webservice gSoap中文乱码解决 RTMP协议
silverlight5 net.tcpBinding 跨域策略的解决
MonkChen · 2013-04-14 · via 博客园 - MonkChen

为了研究silverlight5的特性,下载了vs2012,测试Silverlight调用WCF,起初basicHttpBinding没问题,跨域解决了;试用net.tcp的时候还是遇到跨域的问题:

Could not connect to net.tcp://localhost:4502/Service1. The connection attempt lasted for a time span of 00:00:00.0550032. TCP error code 10013: 试图以其访问权限所禁止的方式访问套接字。. This could be due to attempting to access a service in a cross-domain way while the service is not configured for cross-domain access. You may need to contact the owner of the service to expose a sockets cross-domain policy over HTTP and host the service in the allowed sockets port range 4502-4534.

起初看到异常信息始终不得其解,后来google了N多资料也没有解决---很多谈的都是IIS Host,而我用的是Self-Host,后来逐字逐句看异消息,发现expose a sockets cross-domain policy over HTTP and host the service这句很有玄机,HTTP难道说的就是默认的80端口?尝试修改WCF的配置文件,将ICrossDomainService中的baseAddress端口设为80,加以辅助修改,测试成功!

ps:测试代码的背景

http://silverlightchina.net/html/tips/2010/1208/4010.html

注意:经测试发现ClientAccessPolicy.xml中grant-to一节写法对于不同的Binding有所区别:

basicHTTPBinding:

<?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>

net.tcpBinding

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
 <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
       <socket-resource port="4502" protocol="tcp" />
</grant-to> </policy> </cross-domain-access> </access-policy>


 源代码下载