江湖救急!!! 论坛上一定有高手能解决我这个sliverlight的跨域问题
现在遇到一个Sliverlight跨域的问题。我在Sliverlight里访问一个windows程序为宿主的wcf服务一直
报跨域错误,弄了几天了一直没解决。相信坛子里的高手一定有人能搞定
已经修改windows程序的app.config文件。添加了crossDomain服务
<?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="isLog" value="true"/> <add key="debugFile" value="c:\mydebug.txt"/> <add key="filepath" value="c:\"/> <add key="wcfpwserviceurl" value="http://localhost:7654/PWDB/"/> <add key="wcfwfserviceurl" value="http://localhost:7655/WFDB/"/> <add key="wcfrpserviceurl" value="http://localhost:7656/RPDB/"/> </appSettings> <connectionStrings> <add name="myconstring" connectionString="Data Source=IBM-QIANZHIYU\MSSQL2008R2;Initial Catalog=BPMDB;User ID=sa;Password=5595600" /> <add name="trackingConnectionString" connectionString="Data Source=.;Initial Catalog=Tracking;Integrated Security=True" providerName="System.Data.SqlClient" /> <add name="persistenceConnectionString" connectionString="Data Source=.;Initial Catalog=SqlPersistenceService;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <behaviors> <endpointBehaviors> <behavior name="crossDomainService.crossDomainServiceBehavior"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> </serviceBehaviors> </behaviors> <services> <service name="crossDomainService.crossDomainService"> <endpoint address="" behaviorConfiguration="crossDomainService.crossDomainServiceBehavior" binding="webHttpBinding" contract="crossDomainService.IcrossDomainService" /> <host> <baseAddresses> <add baseAddress="http://localhost:7654" /> </baseAddresses> </host> </service> </services> </system.serviceModel></configuration>
BPM.Foundation.PWService.WCFService pws; BPM.Foundation.WFService.WCFService wfs; BPM.RepotrService.WCFService rps; private void button_Start_Click(object sender, EventArgs e) { string pwserurl = MyConfig.getAppValue("wcfpwserviceurl"); pws = new BPM.Foundation.PWService.WCFService(new Uri(pwserurl)); int? v = pws.open(); if (v == null) { MyDebug.write("权限服务已启动"); } else { MyDebug.write("权限服务启动失败"); MessageBox.Show("权限服务启动失败"); return; } //- string rpserurl = MyConfig.getAppValue("wcfrpserviceurl"); rps = new BPM.RepotrService.WCFService(new Uri(rpserurl)); int? v1 = rps.open(); if (v1 == null) { MyDebug.write("报表服务已启动"); } else { MyDebug.write("报表服务启动失败"); MessageBox.Show("报表服务启动失败"); return; } //- string wfserurl = MyConfig.getAppValue("wcfwfserviceurl"); wfs = new BPM.Foundation.WFService.WCFService(new Uri(wfserurl)); int? v2 = wfs.open(); if (v2 == null) { button_Start.Enabled = false; button_stop.Enabled = true; button_refresh.Enabled = true; groupBox2.Enabled = true; MyDebug.write("工作流服务已启动"); this.Text = "服务已启动"; } else { MyDebug.write("工作流务启动失败"); MessageBox.Show("工作流务启动失败"); } crossDomainService.crossDomainService crs = new crossDomainService.crossDomainService(); }
<?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>
[解决办法]
哪有什么“跨域服务”概念?
如果端口不同,那么localhost之后跟着三个端口的地址,根目录下都要能够下载到授权xml文件。