3

When I put my CSLA-based DataPortal up in Azure's Cloud Services, my WinForms application throws the following exception when it tries to access my business objects:

System.ServiceModel.Security.SecurityNegotiationException: Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint.

(and this inner exception) System.ServiceModel.FaultException: The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

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>

app.config for my WinForms app:

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

When I browse to the WcfPortal.svc files locally or in Azure, I do not get any errors. When I browse to WcfPortal.svc?wsdl locally or in Azure, I get the proper XML response; no errors.

I have uploaded this entire solution to GitHub: AzureHostTest. There are two branches: the master branch just contains the projects that I'm trying to get to work in Azure. The other branch, traditionalWCF, contains three additional projects that demonstrate a standard WCF service working in Azure; I was hoping to use that working set of files as comparison and guidance to setup the CSLA projects.

I'm unsure how I should be setting up my config files and could use some guidance.

Brad Rem
  • 6,036
  • 2
  • 25
  • 50
  • If you try ....cloudapp.net/wcfportal.svc?wsdl what happens? – Rikalous Jul 09 '13 at 22:46
  • @Rikalous, I get the valid XML data. – Brad Rem Jul 09 '13 at 23:01
  • Could it be something to do with authentication? Are you using Csla authentication (not Windows)? – Rikalous Jul 09 '13 at 23:08
  • @Rikalous, Yes, I'm using Csla autherication. – Brad Rem Jul 09 '13 at 23:26
  • @Rikalous, I've removed the use of the certificate and I encourage you to hit the actual service: http://azurehosttest.cloudapp.net/WcfPortal.svc. This was actually based on the AzureHost example CSLA project that goes along with Rocky's DataPortal book. I'm trying to get it to work in this project before I try getting it to work in my actual project. The example was originally designed for Silverlight and I've added a WinForm app. Silverlight works fine in this situation, but not WinForms. – Brad Rem Jul 10 '13 at 00:10
  • I've hit it and it works OK. Try NavaRajan's suggestion next. – Rikalous Jul 13 '13 at 22:58
  • @Rikalous, browsing to the .svc file locally or in Azure works for me, but what does not work is connecting my CSLA WinForm app, even after removing the port numbers. – Brad Rem Jul 13 '13 at 23:29
  • No access to workstation right now to look at source. – Rikalous Jul 13 '13 at 23:33

1 Answers1

0

I think the problem is with your endpoint address... http:// 127.0.0.2:81/WcfPortal.svc

It should be probably http://yourNamespace.cloudapp.net/WcfPortal.svc or http:// 127.0.0.1/WcfPortal.svc

You may get 127.0.0.2:81 as your host in local environment because the default host may be used by some other application in your system. But in azure, Your app is deployed to the port 80 as default.

NavaRajan
  • 1,850
  • 1
  • 17
  • 22
  • Just tried it again and in my CSLA app when it tries to connect to Azure `http://azurehosttest.cloudapp.net/WcfPortal.svc` or the local address with the port specified, I still get the exception listed in my question. If I try to connect to the local instance without specifying the port number, I get the exception that there is not endpoint listening at etc. So, it doesn't see it in that latter case. I encourage you run my GitHub project even just locally. – Brad Rem Jul 13 '13 at 23:50