Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
this is the service that I created:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace HelloIndigo
{
    [ServiceContract(Namespace = "http://www.thatindigogirl.com/samples/2006/06")]
    public interface IHelloIndigoService
    {
        [OperationContract]
        string HelloIndigo();
    }

    public class HelloIndigoService:IHelloIndigoService
    {
        public string HelloIndigo()
        {
            return "Hello Indigo";
        }
    }
}


this is how i am hosting it:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace Host
{
    class HostProgram
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService),
                new Uri("http://localhost:8000/HelloIndigo")))
            {
                host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService),
                    new BasicHttpBinding(), "HelloIndigoService");
                
                Console.WriteLine("Press <enter> to exit the Host");
                Console.ReadLine();
            }
        }
    }
}


this is the code for the client:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace Client
{
    class ClientProgram
    {
        [ServiceContract(Namespace = "http://www.thatindigogirl.com/samples/2006/06")]
        public interface IHelloIndigoService
        {
            [OperationContract]
            string HelloIndigo();
        }


        static void Main(string[] args)
        {
            
                EndpointAddress ep =
                    new EndpointAddress("http://localhost:8000/HelloIndigo/HelloIndigoService");

                IHelloIndigoService proxy = ChannelFactory<ihelloindigoservice>.
                    CreateChannel(new BasicHttpBinding(), ep);

                string s = proxy.HelloIndigo();
                Console.WriteLine(s);

                Console.WriteLine("Press <enter> to terminate Client.");
                Console.ReadLine();
    
        }
    }
}

my application is running in windows 7 and it has 3 projects. The host application runs first then the client.

the host is working fine, meaning I get Press <enter> to exit the Host in host console window.
But when the client runs I get the EndpointNotFoundException in the cient code at string s = proxy.HelloIndigo();

I am guessing maybe windows 7 has an added layer of security and I need to register a port 8000 for listening or something. I am not sure.

Your help is greatly appreciated.
Posted
Updated 14-May-12 8:13am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900