Hi everybody,
for some time I try to access Data of my Silverlight app via https using my local IIS (Win 8.1) . It was no problem to create a certificate. There is no problem to see my data via http - there must be some quirk in some of the config files...
I was hoping by changing security mode to "Transport" and http to https would do the trick but no success.
Here are my config files (working for http) - Maybe someone can help ?
TIA
Uwe
clientConfig:
<configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> <!--security mode="Transport" /--> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost/Sl_App_01/WcfPortal.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal" name="basicHttpBinding_IWcfPortal" /> </client> </system.serviceModel> </configuration>
Web.Config:
<?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <add name="SqlConnStr" connectionString="Data Source=localhost;Initial Catalog=***;Integrated Security= false;User ID=***;Password=***" providerName="System.Data.SqlClient" /> </connectionStrings> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="WcfPortalBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Mobile.WcfPortal"> <endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Mobile.IWcfPortal"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <bindings> <basicHttpBinding> <binding name="basicHttpBinding_IWcfPortal" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" > <!--security mode="Transport" --> <transport clientCredentialType="None"/> </security> </binding> </basicHttpBinding> </bindings> </system.serviceModel> <system.web> <compilation debug="true" targetFramework="4.5" /> <authentication mode="Windows" /> <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" /> </system.web> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Csla" publicKeyToken="93be5fdc093e4c30" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.601.0" newVersion="4.5.601.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
In current versions of CSLA the default is not to use the client config, but rather to use coded config by subclassing WcfProxy. As a result your client config might not be making any difference.
Hi Rocky,
thanks for the hint. Figured it out without client.config:
I provided my settings at the end of my post...
Is there a recommended way to avoid recompiling when having to change the endpoint like reading some kind of external config file and using an endpoint variable in Application_Startup as I would do in a winforms app ?
TIA
Uwe
Web.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add
name="SqlConnStr" connectionString="Data Source=localhost;Initial Catalog=***;Integrated Security= false;User ID=***;Password=***" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfPortalBehavior">
<!--for http and https -->
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<!--for http and https -->
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Mobile.WcfPortal">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal" contract="Csla.Server.Hosts.Mobile.IWcfPortal">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_IWcfPortal" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<!--for http -->
<security mode="None">
<!--for https -->
<!--security mode="Transport"-->
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<authentication mode="Windows" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Csla" publicKeyToken="93be5fdc093e4c30" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.601.0" newVersion="4.5.601.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
private void Application_Startup(object sender, StartupEventArgs e)
{
Csla.ApplicationContext.DataPortalProxy = typeof(Csla.DataPortalClient.WcfProxy).AssemblyQualifiedName;
Csla.ApplicationContext.DataPortalUrlString = "http://localhost/Sl_App_01/WcfPortal.svc";
// Diese Einträge machen die ClientConfig unnötig
var binding = new BasicHttpBinding();
binding.MaxBufferSize = int.MaxValue;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.ReceiveTimeout = TimeSpan.FromMinutes(1);
binding.SendTimeout = TimeSpan.FromMinutes(1);
binding.OpenTimeout = TimeSpan.FromMinutes(1);
binding.CloseTimeout = TimeSpan.FromMinutes(1);
// for https endpoint url
// binding.Security.Mode = BasicHttpSecurityMode.Transport;
// for http endpoint url
binding.Security.Mode = BasicHttpSecurityMode.None ;
Csla.DataPortalClient.WcfProxy.DefaultBinding = binding;
this.RootVisual = new MainPage();
}
Hi Uwe,
Here are my 2 cents.
Regarding: "recommended way to avoid recompiling when having to change the endpoint"
On my web (html) page, I customize the object container:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="... " value "..." /> <!-- keep all existing ones -->
<param name="initParams" value="WcfProxy=BasicHttpBinding_IWcfPortal_DEV" /> <!-- custom input, which does not exists in prod -->
</object>
In my Silverlight code, I do use:
private async void Application_Startup(object sender, StartupEventArgs e) {
if (e.InitParams.ContainsKey("WcfProxy")) {
string paramValue =e.InitParams["WcfProxy"]
Csla.DataPortalClient.WcfProxy.DefaultEndPoint = paramValue;
}
}
And it does work fine.
Gilles
Ps: I do use CSLA 4.5.500 with the endpoint(s) using configuration, but you can use this tip with hard coded end points too.
Hi Gilles,
sorry for the late response - works perfectly - exactly what I wanted.
Thanks
Uwe
Sorry if I'm hijacking this thread, but does this mean its not possible to add a binding via config to do things like compression?
Copyright (c) Marimer LLC