开发者

WCF Service Creation

I am trying to build a small WCF service and wanted to utilize it in a test application.

PFB serv开发者_运维问答ice code:

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

namespace HelloIndigo
{
    [ServiceContract(Namespace="http://www.thatindigoirl.com/samples/2006/06")]
    public interface IHelloIndigoService
    {
        [OperationContract]
        string HelloIndigo();
    }
    public class HelloIndigoService : IHelloIndigoService
    {
        public string HelloIndigo()
        {
            return "Hello indigo";
        }
    }
}

Host Code:

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

namespace Host
{
    class Program
    {
        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");
                host.Open();
                Console.WriteLine("Press <ENTER> to terminate the service hosy");
                Console.ReadLine();
            }
        }
    }
}

Whenever I am trying to run Host I am getting below mentioned error in host.Open() statement.

HTTP could not register URL http://+:8000/HelloIndigo/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

Can anyone help me with this


You need to run the host app with elevated privileges (i.e., "As Administrator"). Under Vista/Win7, only administrative accounts have the permission to register socket listeners.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜