How to change WcfProxy Url or EndPoint?

How to change WcfProxy Url or EndPoint?

Old forum URL: forums.lhotka.net/forums/t/8782.aspx


Roy_MA posted on Thursday, April 08, 2010

 Hi -

In my project I am trying to change WcfProxy Url after the Silverlight (also the OOB) application starts. My focus is to change the Url to my WebServer or AppServer depending on the Network status. In other words, if the Silverlight app is running in the corporate Network I want to use the AppServer. If the AppServer is not available, the application should contact the WebServer.

My Application_Startup, looks like:

Csla.DataPortal.ProxyTypeName = (typeof(Csla.DataPortalClient.SynchronizedWcfProxy<>).AssemblyQualifiedName);

Csla.DataPortalClient.WcfProxy.DefaultUrl = redirectToUrl;
this.RootVisual = new MainPage();

I see that although I am changing the DefaultUrl property, the controls bound to the DataPortal is not refreshing. What is the process to refresh the DataPortal? I tried dp.Refresh() that did not reload the data. I have tried changing the DefaultEndPoint and that does not reload the DataPortal either. I would appreciate your help.

Thanks.

RockfordLhotka replied on Thursday, April 08, 2010

I am not sure I understand. You are binding UI controls to the data portal? That's not normal. What properties of the data portal would you bind to the UI?

Or are you saying you are binding by using a CslaDataProvider? I'll assume so, as that makes sense.

It should work to Refresh() a data provider after changing WcfProxy.DefaultUrl. The DefaultUrl property is used (by default) when a new WcfProxy is created, and that should occur any time one of your business object's factory methods creates an instance of DataPortal<T>. When you call Refresh() on the CslaDataProvider, the data provider invokes your business object's factory method.

Copyright (c) Marimer LLC