I need to deploy a silverlight 4 soltution where it consumes data from a WCF service. The challenge is this will be a production install and so I have no way of controlling the server name of the service and the silver light app will not be installed on the same server as the WCF.
Starting down this path here is what I have come up with thus far:
I will have to pass the server name of teh WCF to my silverligth app via initParams.
within the aspx file I have
<param name="initparams" value="servicepoint=http://myservice" />
then within the app.xaml.cs I call the param:
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage(e.InitParams); //pass parameter from html direclty to main page
}
I called this within app startup so the paramater would be in scope of the entire app.
Now within main page I assign this param to a variable
dswconnection = initParams["servicepoint"];
and then whenever I query the service I set the address to override what is defaulted within the service refernece.config file
QueryClient selAct = new QueryClient("BasicHttpBinding_IQuery");
selAct.Endpoint.Address = new System.ServiceModel.EndpointAddress(dswconnection);
My question is.... is this the best approach or is there another way to dynamically identify the server name of a service when you don't know what that server name could be. This the key point I can't use some of the features to detect host name or address within channelfactory as the silverlight app will reside on a different host than the WCF.
Right now the value that is passed to initparams is stored in a config file that is read by javascript and then assigend as the value. In my code here I hard coded it for brevity.
Thanks for any suggestions.