views:

135

answers:

4

Using Silverlight 3, Windows XP, IIS 5.1, I've written a small app which uses the channel method of calling the server rather than the 'add service reference' as per this MSFT article.

The application opens and the call to the server work when running it on the development computer in VS 2008 using the address localhost plus the port number. When I change the address to the computer name, dellnov2006, and publish the application to IIS, the application opens, but the call to the web service does not work.

Watching the call in Web Dev Helper, I see that the app was trying to call the service file, http://dellnov2006/Service1.svc, and is getting a 404 error.

So far, I've:

-In IIS mapped the .svc type to aspnet-isapi.dll -Run the utility CleanIISScriptMaps -Run aspnet_regiis.exe -i –enable

Any help would be appreciated - I am running out of ideas on this.

--

Here is the call back to the server, and the contents of the Service1.svc file:

 private void Button_Click(object sender, RoutedEventArgs e)
    {
      // create a custom binding that uses HTTP and binary encoding
      var elements = new List<BindingElement>();
      elements.Add(new BinaryMessageEncodingBindingElement());
      elements.Add(new HttpTransportBindingElement());
      var binding = new CustomBinding(elements);

      // create a channel factory for the service endpoint configured
      //   with custom binding

      //var cf = new ChannelFactory<IService1>(binding,
      //   new EndpointAddress("http://localhost:1042/Service1.svc"));

      var cf = new ChannelFactory<IService1>(binding,
         new EndpointAddress("http://dellnov2006/Service1.svc"));

      // save the syncronized context for the ui thread
      uiThead = SynchronizationContext.Current;

      // open the channel
      IService1 channel = cf.CreateChannel();

      // invoke the method asychrnoously
      channel.BeginGetPerson(4, GetPersonCallback, channel);
    }

Here are the contents of the svc file for what they are worth:

<%@ ServiceHost Language="C#" Debug="true" Service="SilverlightChannelApp1.Web.Service1" CodeBehind="Service1.svc.cs" %>

Many thanks Mike Thomas

A: 

Could be one of the following:

  • A problem with the web.config of the service. For example that localhost was part of the address.
  • That the service cannot find the dll which should be in the bin directory

Try browsing to the service with a web browser

Shiraz Bhaiji
A: 

Try adding the port number to the computer name. Whenever I'm testing local sites through a virtual machine that is always a necessity for me.

Change this:

new EndpointAddress("http://dellnov2006/Service1.svc"));

To this:

new EndpointAddress("http://dellnov2006:1042/Service1.svc"));
dhulk
A: 

The solution to this was very simple, but it took both of your answers for me to think of it.

Browsing to the service as suggested by Shiraz worked, so problem with calling service.

Suggestion to change endpoint address to include port # sounded good, but did not work.

Solution was to change:

new EndpointAddress("http://dellnov2006/Service1.svc"));

to this:

new EndpointAddress("http://dellnov2006/Silverlight/Service1.svc"));

where 'Silverlight' is the alias of the virtual directory. In other words, I open the app on IIS as 'http://dellnov2006/Silverlight/

Many thanks, I cannot believe how simple that was after so much time spent looking. I work alone and if it were not for this forum I'd be in serious trouble. Mike Thomas

A: 

thanks for the answer,dhulk. I am new to silverlight and i too faced same problem and i spent 5-6 hrs finding the solution.

maharshi