Re: Deployment of Silverlight App + Silverlight-Enabled WCF Service to Production
Check the url set for your Service in your ServiceReference.ClientConfig file. If the URL is like http://localhost:Port#/YourService.svc then that is your problem.
When you add Service Reference when you develop, The URL is generated by the Dev Web Server which contains a Port number. When you deploy your project to IIS. This url for your service is no longer valid. You have several options.
1) Change the URL to a real URL in the ServiceReference.ClientConfig before your final build.
2) If you already deployed your .Xap file to the server, and you do not
want to rebuild it. You can use a WinRar (download for free) tool to
extract the ServiceReference.ClientConfig file out, edit the url, then
use the same tool to zip it back to the .Xap file.
3) Do not rely on the URL set in the ServiceReference.ClientConfig. Set your URL in the code. Change your WebSerivice Calling code to the following:
var webService = new YourWebService.YourWebServiceClient() // This is the default constructor, url will be read from the clientconfig file.
Uri address = new Uri(Application.Current.Host.Source, "../YourService.svc"); // this url will work both in dev and after deploy.
var webService = new YourWebService.YourWebServiceClient("YourServiceEndPointName", address.AbsolutePath);
I like the option 3 better if you sure WebService file will stay at the same Web Site as your Silverlight page.
During development, the Port number is also changing from time to time. If you close your VS, then come back again later, that port number might changed to a new one. So unless you update your Service reference regularly, your Port number for your page might be not consistant with the port number in the service url in the clientconfig file. This causes cross-domain call even both service and page are in the same project. Setting the URL in the code should avoid this problem.
sladapter
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question