views:

284

answers:

5

Hi

I have a silverlight project that calls into a wcf service. Everything works fine on my local machine.

However when I deploy to a virtual machine, with the exact same query the wcf service returns, but the result is empty.

I've tried debugging, but have not been able to get it to break in the wcf service.

Any ideas what the problem could be, or how I could go about debugging it?

Thanks


I figured out what the problem is, but am not sure what the solution is.

In my silverlight project the wcf service I am referencing is http://localhost/.../SilverlightApiService.svc

I used fiddler on my vm to see the request that was made and instead of trying to contact the above service, it was trying to contact:

http:///.../SilverlightApiService.svc

So, for some reason my machine name is getting inserted in there instead of localhost. Any thoughts on this would be appreciated.

A: 

Can you give us a bit more information? What kind of binding are you using? What does the service config and the client config look like? Where do you get your data from that gets returned? Could it be the service on the VM just doesn't get any data? (e.g. queries a database that just doesn't have the data requested?)

Marc

marc_s
It's using basicHttpBinding. The client service reference was added using add reference. I know the data is there because I created a console application, had it reference the service and it returned results using the query that returns no results when called from silverlight.
A: 

I have had that happen before. I would try this. Set you start page as the web service file and run the app. Then set the start page back to your default page. Then update all the server references in your SL project. Recompile everything and republish. This has helped me a bunch of times in the past.

Bill
A: 

I figured out what the problem is, but am not sure what the solution is.

In my silverlight project the wcf service I am referencing is http://localhost/.../SilverlightService.svc

I used fiddler on my vm to see the request that was made and instead of trying to contact the above service, it was trying to contact:

http:///.../SilverlightService.svc

So, for some reason my machine name is getting inserted in there instead of localhost. Any thoughts on this would be appreciated.

A: 

I had this exact problem when deploying to amazon ec2 - The machine name for the service was being returned in the wsdl rather than the dns.

There were a couple solutions (one involved creating static wsdl - yuck!)

But the other was creating a sort of factory pattern for the service

This thread (you can read it all, but the answers are at the bottom.) http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/c7fd51a2-773e-41d4-95a0-244e925597fe/

The slight downfall with this is that although it works - if you change the location of the server, you will need to remember to update your config - Which although isn't hard, it's easy to forget to do.

JSmyth
A: 

I figured it out.

Basically my machine name was hard coded in my ServiceReferences.ClientConfig file in my silverlight project.

What I had to do was specify programmatically what url to use for the service reference when instantiating my service client:

System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri
        (Application.Current.Host.Source, "../WebServices/SilverlightService.svc"));

        ServiceClient serviceClient = new ServiceClient("BasicHttpBinding_IService", address);