Silverlight 2 + WCF Service Deployment Issue - Rudi Grobler

Silverlight 2 + WCF Service Deployment Issue

While deploying a very simple Silverlight application using a Silverlight enabled WCF service, I ran into this little problem:

On my development machine hosting the app using the normal VS host (By running the app using F5) everything works perfectly (Creating a random port number for the app and service)

If I now deploy this app and service to my production machine, the Silverlight app works but it can’t access the WCF service!!!

Things I double checked:

  1. Make sure the Silverlight application runs. If not, add the MIME types
  2. Make sure the service is working

My service is called MISService.svc so to check that it worked, I opened it in IE (http://localhost/MISService.svc)

If both your Silverlight application and service work, it might indicate a cross domain boundaries problem, here is a document how to fix it.

If it still doesn’t work, try the following:

The problem is that in the ServiceReference.ClientConfig file (Created by using VS Add Service Reference), the endpoint is setup with a specific port number (1192 in the following example)

<client>
  <endpoint address="http://localhost:1192/MISViewerWeb/MISService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MISService"
        contract="MISViewer.MISServiceReference.MISService" name="BasicHttpBinding_MISService" />
</client>

 

 

 

Now if I create the client, I get a UnexpectedHttpResponseCode exception. Here is the code that creates the service client

MISServiceClient client = new MISServiceClient()

To make it work again, I changed this to the following


Uri address = new Uri(Application.Current.Host.Source, "../MISService.svc");

MISServiceReference.MISServiceClient client = new MISServiceReference.MISServiceClient("BasicHttpBinding_MISService", address.AbsoluteUri);

This bypasses the ServiceReference.ClientConfig file!

If you found this useful, please kick it on DotNetKicks.com

Published Monday, August 18, 2008 9:13 AM by rudi

Comments

# Silverlight 2 WCF Service Deployment Issue

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Monday, August 18, 2008 9:15 AM by DotNetKicks.com

# re: Silverlight 2 + WCF Service Deployment Issue

Nice , have got WCF running locally (localhost) and ran out of time to find a solution for hosting it properly(cross-domain).

Monday, August 18, 2008 10:45 AM by Nice

# Dew Drop - August 18, 2008 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop - August 18, 2008 | Alvin Ashcraft's Morning Dew