Silverlight + WCF通讯异常 [英] Silverlight + WCF commnication exception

查看:81
本文介绍了Silverlight + WCF通讯异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight应用程序,其中包含WCF.当调用wcf时,它将失败,并出现以下异常:

I have a silverlight application which has a WCF in it. when the wcf is called it fails with this exception:

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都在本地运行.

Both silverlight and WCF are running from local.

我的Silverlight正在运行:

My silverlight is running from:

...\SilverlightApplication1\SilverlightApplication1\Bin\Release\SilverlightApplication1TestPage.html

这是WCF web.config服务标签:

this is the WCF web.config services tag:

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

and this is the 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中,但无济于事.

I've placed the clientaccesspolicy.xml in bin\release but doesn't help.

请帮助!

推荐答案

在本地运行Silverlight而不是在Web服务器上运行存在一些问题. 访问权限不同,Silverlight将无法访问任何Web服务. 我很早以前就遇到过SL2这个问题,我想可能已经改变了.

There are issues with running Silverlight locally as opposed to from a web server. The access permissions are different and Silverlight won't be able to access ANY webservice. I ran into that issue somne time ago with SL2 I think, it might have changed.

您应该在Visual Studio中创建一个新的WebApplication项目并在其中托管Silverlight. 这样您的SL客户端就可以毫无问题地连接到服务了.

You should create a new WebApplication project in Visual Studio and host Silverlight in it. Then you SL client will have no problem connecting to the service.

这篇关于Silverlight + WCF通讯异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆