我有一个silverlight应用程序,其中有一个WCF。当调用wcf时,它会失败,并出现以下异常:
An error occurred while trying to make a request to URI 'http://localhost:4693/MapService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.silverlight和WCF都是从本地运行的。
我的silverlight运行于:
...\SilverlightApplication1\SilverlightApplication1\Bin\Release\SilverlightApplication1TestPage.html这是WCF web.config服务标签:
<services>
<service behaviorConfiguration="FileUpAndDownload.Web.MapServiceBehavior" name="FileUpAndDownload.Web.MapService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MapBinding" contract="FileUpAndDownload.Web.IMapService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>这是ServiceReference.ClientConfig:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4693/MapService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService"
name="BasicHttpBinding_IMapService" />
</client>
</system.serviceModel>
我已经将clientaccesspolicy.xml放在了bin\release中,但是没有帮助。
请帮帮我!
发布于 2011-02-15 18:34:21
您需要一些额外的配置来进行跨域调用,请参阅:http://www.dotnetcurry.com/ShowArticle.aspx?ID=208&AspxAutoDetectCookieSupport=1
您可能将clientaccesspolicy.xml放在了错误的位置,请检查您的IIS日志中是否存在未找到文件的错误。
发布于 2011-02-15 19:43:42
客户端访问策略文件必须位于wwwroot文件夹中
发布于 2011-02-17 22:02:40
与从web服务器运行Silverlight相比,在本地运行Silverlight存在问题。访问权限不同,Silverlight将无法访问任何won服务。不久前我在SL2上遇到了这个问题,我想它可能已经改变了。
您应该在Visual Studio中创建一个新的WebApplication项目,并在其中托管Silverlight。然后,您的SL客户端将不会出现连接到服务的问题。
https://stackoverflow.com/questions/5002503
复制相似问题