首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Silverlight + WCF通信异常

Silverlight + WCF通信异常
EN

Stack Overflow用户
提问于 2011-02-15 18:29:24
回答 3查看 165关注 0票数 0

我有一个silverlight应用程序,其中有一个WCF。当调用wcf时,它会失败,并出现以下异常:

代码语言:javascript
复制
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运行于:

代码语言:javascript
复制
...\SilverlightApplication1\SilverlightApplication1\Bin\Release\SilverlightApplication1TestPage.html

这是WCF web.config服务标签:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
<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中,但是没有帮助。

请帮帮我!

EN

回答 3

Stack Overflow用户

发布于 2011-02-15 18:34:21

您需要一些额外的配置来进行跨域调用,请参阅:http://www.dotnetcurry.com/ShowArticle.aspx?ID=208&AspxAutoDetectCookieSupport=1

您可能将clientaccesspolicy.xml放在了错误的位置,请检查您的IIS日志中是否存在未找到文件的错误。

票数 0
EN

Stack Overflow用户

发布于 2011-02-15 19:43:42

客户端访问策略文件必须位于wwwroot文件夹中

票数 0
EN

Stack Overflow用户

发布于 2011-02-17 22:02:40

与从web服务器运行Silverlight相比,在本地运行Silverlight存在问题。访问权限不同,Silverlight将无法访问任何won服务。不久前我在SL2上遇到了这个问题,我想它可能已经改变了。

您应该在Visual Studio中创建一个新的WebApplication项目,并在其中托管Silverlight。然后,您的SL客户端将不会出现连接到服务的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5002503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档