0

Going straight to the point, I have a WCF project and Host project(which I want to launch Service), when I make the WCF as a startUp project, it hosts the service, I receive a confirmation message(bottom right) and everything works fine, but when I try to host from the Host project, it does not host, no confirmation message anything.

Here is my Host code:

static void Main(string[] args)
    {
        using (ServiceHost host = new ServiceHost(typeof(MovieService)))
        {

                host.Open();
                Console.WriteLine("The host is online.");
                Console.ReadLine();
                host.Close();
            }


    }

Host app.config:

<system.serviceModel>
<services>
  <service name="CinemaProject.WCF.MovieService">
    <endpoint address="" binding="wsHttpBinding" contract="CinemaProject.WCF.IMovieService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/CinemaProject.WCF/MovieService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

And my WCF code:

public class MovieService : IMovieService
{
    static MovieCtr movieCtr = new MovieCtr();

    public void Add(Movie movie)
    {
         movieCtr.add(movie);
    }

    public void SearchById(int id)
    {
    }

    public void Update(Movie movie)
    {
    }

    public void Delete(Movie movie)
    {
    }

    public void DeleteById(int id)
    {
    }

    public IEnumerable<MovieDTO> All()
    {
        return movieCtr.All();
    }
}

And WCF app.config:

<system.serviceModel>
<services>
  <service name="CinemaProject.WCF.MovieService">
    <endpoint address="" binding="wsHttpBinding" contract="CinemaProject.WCF.IMovieService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/CinemaProject.WCF/MovieService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Can somebody look at it and point me in the right direction, and post a solution aswell if possible.

Thank you, Marius J.

MariusJ
  • 83
  • 8
  • Thus you launch your Host code as a Console application, but the message `The host is online.` does not appear? – Sjips Nov 06 '14 at 13:14
  • It appears, but I do not get the confirmation message on the bottom right corner and the Client cannot connect aswell, but if I launch WCF everything works just fine. – MariusJ Nov 06 '14 at 13:17
  • 1
    Not sure if you get the conformation message, because you are now using your Console application as the host. You can check if your PC is actually listening on incoming connections on port 8733 by using `netstat -a` in a CMD window. – Sjips Nov 06 '14 at 13:25
  • Ehh, it is not listening to 8733, but when I try to change it to which is it listening, I get `HTTP could not register URL http://+:1037/Design_Time_Addresses/CinemaProject.WCF/MovieService/. Your process does not have access rights to this namespace`. – MariusJ Nov 06 '14 at 13:45

1 Answers1

0

Try to run this from a CMD window:

netsh http add urlacl url=http://+8733:/ user=DOMAIN\user

Specify the correct DOMAIN and user

Sjips
  • 1,248
  • 2
  • 11
  • 22