繁体   English   中英

如何为Azure配置CSLA WCF DataPortal?

[英]How do I configure a CSLA WCF DataPortal for Azure?

当我将基于CSLA的DataPortal放在Azure的云服务中时,我的WinForms应用程序在尝试访问我的业务对象时会抛出以下异常:

System.ServiceModel.Security.SecurityNegotiationException:无法打开安全通道,因为与远程端点的安全协商失败。 这可能是由于在用于创建通道的EndpointAddress中缺少或错误指定了EndpointIdentity。 请验证EndpointAddress指定或暗示的EndpointIdentity是否正确标识远程端点。

(以及此内部异常)System.ServiceModel.FaultException:由于ContractFilter,无法在接收方处理带有Action“ http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue ”的消息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项目的比较和指导。

我不确定我应该如何设置我的配置文件,并可以使用一些指导。

我认为问题出在你的终端地址... 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。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM