开发者

WCF Service Library Called from Silverlight Crossdomain error

开发者 https://www.devze.com 2023-03-23 08:25 出处:网络
I have created a WCF Service library that is called from a Silverlight application. The .svc file (GVFileManagementService.svc) is hosted on the web project that host also the xap.

I have created a WCF Service library that is called from a Silverlight application.

The .svc file (GVFileManagementService.svc) is hosted on the web project that host also the xap.

Now, the GVFileManagementService.svc contains only a reference to the dll.

Locally, everything works fine. But when I deployed the solution on the server the xap didn't work and I noticed in Fiddler that the application is requesting the crossdomain.xml and the clientaccesspolicy.xml files.

The https are : http://localhost:1186/clientaccesspolicy.x开发者_如何学JAVAml

and http://localhost:1186/crossdomain.xml

Why it indicates a localhost URL ? And how can I resolve this issue ? Where should I place these files ?

Thanks


The client access and cross domain policy files need to be in your root web directory. Fiddler is showing the localhost address because you are running off of your local web server on a specific port.

You might check out this article. http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx


Your problem may be that the XAP file is being built with a reference to the local host service being used in your development environment. That is what is being put in the XAP file and why the silverlight client is looking to localhost when you try to use it. You need to create a relative binding so that when the silverlight client starts asking for the service, it substitutes the name of the service on the deployed machine.

This link Using relative URLs to access WCF services in Silverlight may help explain what is happening and how to do it.


Because of the sandbox nature of Silverlight, in order to access resources from different network you need to have client access policy and if you are accessing a different domain then a cross domain policy as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号