View Full Version : Problems deploying WCF REST service
JohnCC
09-23-2009, 05:31 PM
I seem to be suffering from a multitude of problems here and I'd appreciate some help to find my way through. I created a WCF-based REST web service using the WCF Rest Starter Kit. When running with the ASP.NET development server in VS2008 it works fine.
When I built a release and run the local ASP.NET development server against it, I get a 404 error when I look at the .svc file. I then uploaded this version to my hosting environment, and I got:-
This collection already contains and address with scheme http.
I followed some advice that I found and added <baseAddressPrefixFilters> to my web.config file. I uploaded this change to the hosting, and now I get the a 404 on the service file!
Please help... I'm totally mystified here.
JohnCC
09-23-2009, 05:33 PM
Here is some of the code.
web.config
(system.service model section only, for brevity)
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.geonixlocate.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service name="RemoteAPI.Remote">
<endpoint address="" binding="webHttpBinding" bindingName="web" contract="RemoteAPI.Remote" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="web" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
~/Remote.svc
<%@ ServiceHost Language="C#" Debug="true" Service="RemoteAPI.Remote" Factory="RemoteAPI.AppServiceHostFactory" CodeBehind="~/App_Code/Services/Remote/Remote.cs" %>
using System;
using System.ServiceModel;
using System.ServiceModel.Activation;
using Microsoft.ServiceModel.Web;
namespace RemoteAPI
{
class AppServiceHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
WebServiceHost2 result = new WebServiceHost2(serviceType, true, baseAddresses);
result.Interceptors.Add(new CredentialsVerifyingRequestInterceptor());
return result;
}
}
}
JohnCC
09-23-2009, 05:34 PM
One more part. I've simplified this a bit but it should show the basics.
~/App_code/Services/Remote/Remote.cs
using System.ServiceModel.Web;
using System.ServiceModel.Activation;
using System.ServiceModel.Syndication;
using Microsoft.ServiceModel.Web;
using System.Globalization;
using System.Net;
using System.IO;
using System.Security;
using System.Reflection;
using System.Web.Security;
[assembly: ContractNamespace("", ClrNamespace = "RemoteAPI")]
namespace RemoteAPI
{
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceContract]
public partial class Remote
{
[WebHelp(Comment = "Read information about a site user.")]
[WebGet(UriTemplate = "users/{user}")]
[OperationContract]
public User GetUser(string user)
{
SiteUser su = UserManager.GetUser(user);
return new User(su);
}
}
}
vBulletin® ©Jelsoft Enterprises Ltd.