Tuesday, September 27, 2011

Deploying A Web Service

The Microsoft Visual Studio .NET logo.Image via WikipediaFor the past several months I've been working on a .Net program in Silverlight that employs a web service. IT took some time but I did make it work in Visual Studio 2010. The problem came when I wanted to deploy it to web server. It refused to work. The Silverlight App had the ASP.Net debugging activated and my webservice didn't so I had to add the following line to just before my web service's class instantiation:

And I had to make sure that the url in the ServiceReference.ClientConfig file and the configuration for the web service match the url for the web service *.svc file on the web server. I found this to be a problem when it came comes to trying to run the projects from inside Visual Studio 2010, I have to switch the url to match the local server. I also found out that I had to change the code for calling the web service.

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);
You can read the links I used to come up with this:



Deployment of Silverlight App + Silverlight-Enabled WCF Service to Production

Deploying Silverlight with WCF Services
Enhanced by Zemanta

No comments: