Skip to main content

Microsoft Silverlight

Answered Question Application unable to find a web service when hosted remotely on IIS7RSS Feed

(0)

Neil5544
Neil5544

Member

Member

0 points

4 Posts

Application unable to find a web service when hosted remotely on IIS7

Hi

 

I am unable to move my Silverlight application from my development environment to the web site host. I am switching the <endpoint address> before uploading the app. I have followed very closely the steps laid out at http://msdn.microsoft.com/en-us/library/cc197964(VS.95).aspx but with no luck.

 

The application works correctly locally but when moved to my web site host there is an error.

 

Here is a picture of the VS8 solution environment:  http://www.labelease.com/SilverLightQuestion/DevEnv.png

 

The error:

The Silverlight application renders but the service, Service1, cannot be found. The result code returned and viewed in Fiddler is 500. The service when it works returns an int of value 2.

 

Development environment:

VStudio 2008 SP1

Silverlight 2.0

host: DiscountASP.net IIS 7

Fiddler

 

Note: These MIME extensions have been added to IIS 7 at DiscountAsp.net

.xap     application/x-silverlight-app

.xaml    application/xaml+xml

.xbap    application/x-ms-xbap

 

// This is the Service.

using System.ServiceModel;

using System.ServiceModel.Activation;

 

 

namespace NR3.Web

{

[
ServiceContract(Namespace = "")]

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

public class Service1

{

 

// Add more operations here and mark them with [OperationContract]

 

[OperationContract]public int GetThis()

{

return 2;

}

}

}

 

// This is the client.

using System;

using System.Windows.Controls;

using System.ServiceModel;

using NR3.ServiceReference1;

 

namespace NR3

{

public partial class Page : UserControl

{

public Page()

{

InitializeComponent();

 

Service1Client proxy = new Service1Client();

 

proxy.GetThisCompleted +=

new EventHandler<GetThisCompletedEventArgs>

(proxy_GetThisCompleted);

 

proxy.GetThisAsync();

}

 

void proxy_GetThisCompleted(object sender,GetThisCompletedEventArgs e)

{

//throw new NotImplementedException();

this.userCountResult.Text ="Number of users = " + e.Result;

}

}

}

 

// This is the ServiceRerences.ClientConfig configured for DiscountAsp.net hosting

<configuration>

<system.serviceModel>

<bindings>

<basicHttpBinding>

<binding

name="BasicHttpBinding_Service1"

maxBufferSize="2147483647"

maxReceivedMessageSize="2147483647"

closeTimeout="00:59:00"

openTimeout="00:53:00"

receiveTimeout="00:15:00"

sendTimeout="00:21:00">

<security mode="None" />

</binding>

</basicHttpBinding>

</bindings>

<client>

<endpoint address="http://www.myWebSite.com/Service1.svc"

binding="basicHttpBinding"

bindingConfiguration="BasicHttpBinding_Service1"

contract="ServiceReference1.Service1"

name="BasicHttpBinding_Service1" />

</client>

<!-- This is used for local operation: http://localhost:1306/Service1.svc -->

<!-- This is used for remote operation: http://www.myWebSite.com/Service1.svc -->

</system.serviceModel>

</configuration>

 

// Here is Page.xaml

<UserControl x:Class="NR3.Page"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Width="400" Height="300">

<Grid x:Name="LayoutRoot" Background="White">

<StackPanel>

<TextBlock x:Name="userCountResult" Text="not filled" />

<TextBlock Height="Auto" Width="Auto" Text="Site Renders" TextWrapping="Wrap" x:Name="tbRenders"/>

</StackPanel>

 

</Grid>

</UserControl>

 

If anybody can point what I'm missing it is greatly appreciated.

 

Thanks ... Neil

davidezordan
davidezo...

Contributor

Contributor

5690 points

875 Posts

Silverlight MVP

Re: Application unable to find a web service when hosted remotely on IIS7

Hi,

DiscountAsp.net is a shared hosting environment, you have to use a ServiceHostFactory. Read these threads/articles for more details:

http://silverlight.net/forums/p/65972/161839.aspx#161839

http://forum.discountasp.net/showthread.php?t=7719

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts

Neil5544
Neil5544

Member

Member

0 points

4 Posts

Re: Application unable to find a web service when hosted remotely on IIS7

 

Still no luck.

 I've edited Service1.svc to this 

<%@ ServiceHost Factory="NR3.Web.myHostFactory" Language="C#" Debug="false" Service="Service1" CodeBehind="Service1.svc.cs" %>

 

And added this class, a HostFactory.

namespace NR3.Web

{

public class myHostFactory : ServiceHostFactory

{

protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)

{

// Specify the exact URL of your web service

var webServiceAddress = new Uri("http://www.myWebSite.com/Service1.svc");

var webServiceHost = new ServiceHost(serviceType, webServiceAddress);

return webServiceHost;

}

}

}

Absolutely no luck/change.

I'm stuck!

Neil 

 

 

davidezordan
davidezo...

Contributor

Contributor

5690 points

875 Posts

Silverlight MVP

Re: Re: Application unable to find a web service when hosted remotely on IIS7

Try to follow the steps described here: http://msdn.microsoft.com/en-us/library/cc197938(VS.95).aspx

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts

Neil5544
Neil5544

Member

Member

0 points

4 Posts

Re: Re: Application unable to find a web service when hosted remotely on IIS7

Tried that a week ago.  Fails on step 1.  Can't find the service or service is not running. 

Thanks... Neil

Neil5544
Neil5544

Member

Member

0 points

4 Posts

Answered Question

Re: Re: Application unable to find a web service when hosted remotely on IIS7

Well, I finally figured it out.  Thanks Davide for the direction toward the ServiceHostFactory.  MSDN link is here: http://msdn.microsoft.com/en-us/library/aa702697.aspx

The error I encountered implementing the ServiceHostFactory is detailed below:

This is the correct line of code that appears in Service.sc

<%@ ServiceHost Factory="NR3.Web.myHostFactory" Language="C#" Debug="false" Service="NR3.Web.Service1" CodeBehind="Service1.svc.cs" %>

I had entered this which was incorrect:

<%@ ServiceHost Factory="NR3.Web.myHostFactory" Language="C#" Debug="false" Service="Service1" CodeBehind="Service1.svc.cs" %>

A very good example of deploying an app to DiscountASP.net can be found at:

http://www.codeproject.com/KB/silverlight/SilverlightWcfDatabase.aspx

 

davidezordan
davidezo...

Contributor

Contributor

5690 points

875 Posts

Silverlight MVP

Re: Re: Re: Application unable to find a web service when hosted remotely on IIS7

Hi Neil5544,

thanks for the link, I'll add it to my favorites!

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities