Hi guys, I have WCF service installed and I was working for couple of time I have added the ServiceHostFactory to make it work on hosted site like discount, but after a couple of update of the site I found WCF service not working with the following error . Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. I attached the shot below. I check also the .ASMX file that was created in .NET 2.0 and all are working. I recyle the poll and restert the webserver in the discountasp.net control panel and still have the same problem. I would be happy if you can help me on this matter. best regards, Simplicio Jiosn
I have search a lot of this error and my problem is How can I perform this operation on discountasp.net hosting? http://forums.iis.net/p/1112705/1716896.aspx http://bloggingabout.net/blogs/jpsmit/archive/2007/01/17/wcf-http-404-when-hosted-in-iis.aspx
Please mark this one as solve. I got the problem at CreateServiceHostClass public class MyServiceHostFactory : ServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { // Specify the exact URL of your web service //Uri webServiceAddress = new Uri(baseAddresses[1]); //Uri webServiceAddress = new Uri(baseAddresses[0].AbsoluteUri.ToString()); //Uri webServiceAddress = new Uri(baseAddresses[1].AbsoluteUri.ToString()); Uri webServiceAddress = new Uri("xxxxxxservice.svc"); MyServiceHost webServiceHost = new MyServiceHost(serviceType, webServiceAddress); return webServiceHost; } } public class MyServiceHost : ServiceHost { public MyServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { } protected override void ApplyConfiguration() { base.ApplyConfiguration(); } }
Hi, I read your example and and I replaced my code with the following and i am getting an exception:Invalid URI: The format of the URI could not be determined here is my code: Uri webServiceAddress = new Uri("PhotoService.svc"); return new ServiceHost(serviceType, webServiceAddress); Did you say you got this to work? I am getting a 404 still...ugh. thanks, bill
Hi, Ok, found a fix. Here is what I had to do. I found that the baseAddress[0].AbsoluteUri did not contain http://www. It only contained http://mydomain.com/resOfrequest.... so i did the following in my override... protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { Uri newAddress = baseAddresses[0]; if (!newAddress.AbsoluteUri.Contains("localhost")) { if (!newAddress.AbsoluteUri.Contains(http://www.)) { newAddress = new Uri(newAddress.AbsoluteUri.Replace("http://", "http://www.")); } } return new ServiceHost(serviceType, newAddress); } This worked for me...The way Ifound this out by putting a throw new ApplicationException(baseAddresses[0].AbsoluteUri) at the beginning of method, published my site and then browsed to my .svc file. Thanks for your help! bill