WCF / Csla 地狱
我正在尝试构建一个概念验证 Csla 3.7/Silverlight 3 应用程序,并一直在努力 Rocky 的教程。这是一个非常简单的单一表单/单一业务对象数据编辑应用程序,一切都很顺利,直到我尝试配置 Wcf 以便 Silverlight 应用程序可以与数据门户通信。
我得到的错误是:
CommunicationException was unhandled by user code
An error occurred while trying to make a request to URI 'http://localhost:1406/WcfPortal.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 和 Silverlight 有点不熟悉。世界CF。对于 Csla Silverlight 应用程序,我的设置非常简单。我有 4 个项目:
- CslaSilverlight :Silverlight 项目
- CslaSilverlight.Client :Silverlight 类库
- CslaSilverlight.Server :.NET 类库
- CslaSilverlight.Web :托管 SL 应用程序的 ASPNET 项目
一切都在我的笔记本电脑上的 Cassini 下本地运行。我希望 DataPortal 在 Silverlight 之外运行,以便我可以访问 SQL Server。我认为问题可能出在 ServiceReferences.ClientConfig 文件中指定的 Silverlight 应用程序中的 Wcf 配置:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="65536"
maxReceivedMessageSize="65536" receiveTimeout="10" sendTimeout="10">
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1406/WcfPortal.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal"
contract="Csla.WcfPortal.IWcfPortal" name="BasicHttpBinding_IWcfPortal" />
</client>
</system.serviceModel>
</configuration>
我想知道端口号是否重要,当我更改它时,我会收到不同的错误。我还想知道端点地址的格式是否正确。
不确定它是否重要,但 ASPNet web.config 中的 serviceModel 设置是:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfPortalBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
I'm trying to build a proof of concept Csla 3.7/Silverlight 3 app and have been working my way through Rocky's tutorials. It's a really simple one form/one business object data editing app and everything is just peachy right up until the point where I try to get the Wcf configured so that the Silverlight app can talk to the Data Portal.
The error I'm getting is:
CommunicationException was unhandled by user code
An error occurred while trying to make a request to URI 'http://localhost:1406/WcfPortal.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.
I'm totally mystified by this as I'm a bit of a n00b to Silverlight & WCF. My setup is pretty straight forward for a Csla Silverlight app. I have 4 projects:
- CslaSilverlight : Silverlight Project
- CslaSilverlight.Client : Silverlight Class Library
- CslaSilverlight.Server : .NET Class Library
- CslaSilverlight.Web : ASPNET Project to host the SL app
Everything is running locally on my laptop under Cassini. I want the DataPortal to run outside of Silverlight so that I can access SQL Server. I think that the problem may be with my Wcf Config in the Silverlight application which is specified in a ServiceReferences.ClientConfig file:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="65536"
maxReceivedMessageSize="65536" receiveTimeout="10" sendTimeout="10">
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1406/WcfPortal.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal"
contract="Csla.WcfPortal.IWcfPortal" name="BasicHttpBinding_IWcfPortal" />
</client>
</system.serviceModel>
</configuration>
I'm wondering if the port number important, when I change it I get a different error. I'm also wondering if the format of the endpoint address correct.
Not sure if it's important, but my serviceModel settings from the ASPNet web.config are:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfPortalBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我认为正确,那么错误可能会告诉您完全正确的事情,您缺少跨域策略。 silverlight 应用程序正在从远程位置访问 WCF 服务,需要授权才能接受请求。
我在开发阶段就遇到过这种情况,当时项目分为三个部分:SL 应用程序、WCF Web 服务和网站。该网站和 WCF 服务独立运行,尽管它们是同一解决方案的一部分。因此,卡西尼号运行了两次,您就跨越了边界。
我有一个 clientaccesspolicy.xml 文件以及正在开发的 Web 服务,其中包含以下内容:
该文件允许任何人和所有事物,您可以对其进行改进以用于生产,但在开发中这是最简单的方法。 Google wcf 客户端访问策略/wcf 跨域策略 - 这是一个常见问题。
If I am thinking it right, then the error may be telling you the entirely correct thing, you are missing a cross domain policy. The silverlight app is accessing the WCF service from a remote location and needs the authorisation to accept the request.
This occured for me in dev when the project was in three parts, the SL App, the WCF web service and the website. The web site and WCF service are run independantly, although they were a part of the same solution. As such Cassini is run twice and you are crossing a boundary.
I have a clientaccesspolicy.xml file along with the web service in development that has the following:
The file is a allowing anyone and everything, you would refine it for production, but in dev it was the easiest way. Google wcf client access policy / wcf cross domain policy - it is a common issue.