Deploying Webservice - File Not Found

Discussion in 'ASP.NET WebServices' started by pigi76, May 1, 2009.

  1. Hi to all,

    i have deployed this service on my dasp web:



    Code:
    namespace BrainEncrypted.Web
    <%@ ServiceHost Language="C#" Factory="BrainEncrypted.Web.MyServiceHostFactory" Debug="true" Service="BrainEncrypted.Web.DataBase" CodeBehind="DataBase.svc.cs" %>
    
    {
        [ServiceContract(Namespace = "")]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class DataBase
        {
           
            public   DataBase()
            { 
            
            
            }
        
    
            [OperationContract]
            public void DoWork()
            {
                // Aggiungere l'implementazione dell'operazione qui
                return;
            }
    
            [OperationContract]
            public string
                GetUsersName()
            {
     
    
    
                return "test";
    
    
    
            }
    
    
            // Aggiungere altre operazioni qui e contrassegnarle con [OperationContract]
        }
    
    
        public class MyServiceHostFactory : ServiceHostFactory
        {
    
    
            protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
            {
    
    
                // Specify the exact URL of your web service
    
    
                Uri webServiceAddress = new Uri("http://www.brainencrypted.com/database.svc");
    
    
                ServiceHost webServiceHost = new ServiceHost(serviceType, webServiceAddress);
                //ServiceHost webServiceHost = new ServiceHost(serviceType, baseAddresses[0]);
    
                return webServiceHost;
    
    
            }
    
    
        }
    
    
    }
    
    When i try to run it, i have a ComunicationException: "The remote server returned an error: NotFound".

    I have tryied to read some faq and post but i'm a little confused about this.


    I have to config somethink to iis7-dasp?
    I have to enable some features?

    trying to run it on localhost i no have problem.

    I hope that someone get me a light.

    Tnx in avd.
     
  2. What is the remote server you are making the call to? We do not block any outgoing calls. Its sounds like the issue may lie on the targetted server.
     
  3. This is the old .NET 3.0 way of making WCF work in IIS. With .NET 3.5 framework, you do not need to override the servicehost anymore.

    In Visual Studio 2008, create a new Web Site - WCF Service project. Then add the following to the system.serviceModel section of the web.config, where www.domain.com is the URL of your site where you want to expose the service.

    Code:
        <system.serviceModel>
            <serviceHostingEnvironment>
                <baseAddressPrefixFilters>
                  <add prefix="http://www.domain.com"/>
                </baseAddressPrefixFilters>
            </serviceHostingEnvironment>
        </system.serviceModel>
    
     
  4. Thank You so munch! It work. :)

    Now i have only al little problem:

    It's possible to switch dinamicly to localhost and mydomain?


    Thank's in adv.
     
  5. You could use the DEBUG flag. For example:

    Code:
    #if DEBUG
    Uri webServiceAddress = new Uri("http://localhost:4300/database.svc");
    #else
    Uri webServiceAddress = new Uri("http://www.brainencrypted.com/database.svc");
    #endif
     

Share This Page