views:

22

answers:

1

I have a WebService that I am trying to use NetTCPBinding on.

here is my code for setting up the binding

  private static void Run()
    {
        try
        {

            //set up the address configuration procedure: create a URI to serve as the base address

            Uri baseAddress = new Uri("net.tcp://10.0.0.14:3790/Service/QBService");
            ServiceHost selfHost = new ServiceHost(typeof(QBService), baseAddress);

            try
            {

                NetTcpBinding myBinding = new NetTcpBinding();
                myBinding.Security.Mode = SecurityMode.Transport;
                myBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

                myBinding.MaxReceivedMessageSize = 50000000;
                myBinding.MaxBufferPoolSize = 50000000;



                selfHost.AddServiceEndpoint(
                    typeof(IQBService),
                   myBinding,
                    "QBService");



                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                selfHost.Description.Behaviors.Add(smb);
                selfHost.Open();

                Console.WriteLine("The service is ready");

                bool terminate = false;
                //wait to read line as long as entertext is not equal to end
                while (!terminate)
                {
                    string entertext = Console.ReadLine();
                    if (entertext.Equals("end"))
                        terminate = true;
                    else
                        Console.WriteLine("\n Unknown Command \n");

                }



                selfHost.Close();

            }
            catch (CommunicationException ce)
            {

                Console.WriteLine(ce.Message, ce);
                selfHost.Abort();
            }

        }
      }

When I start the service I get this error

"The service certificate is not provided. Specify a service certificate in serivcecredentials"

Do I have to use a certificate with this binding? or is there another way? Thanks!

+1  A: 

You specified that Security.Mode = SecurityMode.Transport. If you don't want to use certificates, specify Security.Mode = SecurityMode.None instead to indicate no security.

Bernard
so with transport I have to use a certificate? We do want some sort of security though so is there another option or should I just do the certificate?Thanks.
twal
The only way to setup a secure web service properly is to use certificates.
Bernard