当我将基于CSLA的DataPortal放在Azure的云服务中时,我的WinForms应用程序在尝试访问我的业务对象时会抛出以下异常:
System.ServiceModel.Security.SecurityNegotiationException:安全 由于与远程安全协商,无法打开通道 端点失败了。这可能是由于缺席或不正确 用于创建的EndpointAddress中指定的EndpointIdentity 渠道。请验证指定或暗示的EndpointIdentity EndpointAddress正确识别远程端点。
(和这个内部异常)System.ServiceModel.FaultException:The 带有动作的消息 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue'不能 由于ContractFilter不匹配而在接收器处理 EndpointDispatcher。这可能是因为合同不匹配 (发送方和接收方之间不匹配的操作)或绑定/安全性 发送者和接收者之间不匹配。检查发件人和 接收者具有相同的合同和相同的约束力(包括 安全要求,例如消息,传输,无)。
的web.config :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="DalManagerType"
value="DataAccess.Mock.DalManager,DataAccess.Mock" />
<add key="CslaAuthentication" value="Csla" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxRequestLength="2147483647" targetFramework="4.5" />
<pages controlRenderingCompatibilityVersion="4.0" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider"
type=
"System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider,
System.Web.Extensions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider"
type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""
cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Csla.Server.Hosts.WcfPortal"
behaviorConfiguration="returnFaults">
<endpoint binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding_IWcfPortal"
contract="Csla.Server.Hosts.IWcfPortal" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding"
address="mex" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_IWcfPortal"
maxReceivedMessageSize="2147483647">
<security mode="None">
<message establishSecurityContext="false" />
<transport clientCredentialType="None" />
</security>
<readerQuotas maxBytesPerRead="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647"
maxDepth="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<useRequestHeadersForMetadataAddress />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
我的WinForms应用的app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="CslaPropertyChangedMode" value="Windows" />
<add key="CslaDataPortalProxy"
value="Csla.DataPortalClient.WcfProxy, Csla" />
<add key="CslaDataPortalUrl" value="http://127.0.0.2:81/WcfPortal.svc" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IWcfPortal"
maxReceivedMessageSize="2147483647">
<security mode="None" />
<readerQuotas
maxBytesPerRead="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647"
maxDepth="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint
address="http://127.0.0.2:81/WcfPortal.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IWcfPortal"
contract="Csla.Server.Hosts.IWcfPortal"
name="WSHttpBinding_IWcfPortal"/>
</client>
</system.serviceModel>
</configuration>
当我在本地或Azure中浏览WcfPortal.svc文件时,我没有收到任何错误。当我在本地或Azure中浏览WcfPortal.svc?wsdl时,我得到了正确的XML响应;没有错误。
我已将整个解决方案上传到GitHub:AzureHostTest。有两个分支:master
分支只包含我试图在Azure中工作的项目。另一个分支traditionalWCF
包含三个其他项目,用于演示在Azure中工作的标准WCF服务;我希望使用这组工作文件作为设置CSLA项目的比较和指导。
我不确定如何设置我的配置文件并可以使用一些指导。
答案 0 :(得分:0)
我认为问题在于你的终端地址... http:// 127.0.0.2:81/WcfPortal.svc
应该是http://yourNamespace.cloudapp.net/WcfPortal.svc或http:// 127.0.0.1/WcfPortal.svc
您可能会在本地环境中获得127.0.0.2:81作为主机,因为系统中的某些其他应用程序可能会使用默认主机。但是在azure中,您的应用程序默认部署到端口80。