2011-04-16 39 views
1

我一直试图找到一种方法来替代默认退伍军人会REST 4.0 helppage我自己一个,和整个此帖一:改变默认的WCF REST 4.0 helppage

http://code.msdn.microsoft.com/WCF-Custom-Help-Page-6f5a90f0

我已经一直在尝试用同样的方法在IIS托管服务使用下面的代码:

namespace WcfHelpRestService 
{ 
    public class Global : HttpApplication 
    { 
     void Application_Start(object sender, EventArgs e) 
     { 
      RegisterRoutes(); 
     } 

     private void RegisterRoutes() 
     { 
      // Edit the base address of Service1 by replacing the "Service1" string below 
      var factory = new MyServiceHostFactory(); 

      RouteTable.Routes.Add(new ServiceRoute("Service1", factory, typeof(Service1))); 
     } 
    } 
} 

namespace WcfHelpRestService 
{ 
    public class MyServiceHostFactory : WebServiceHostFactory 
    { 
     public MyServiceHostFactory() 
     { 

     } 
     protected override System.ServiceModel.ServiceHost CreateServiceHost(Type    serviceType, Uri[] baseAddresses) 
     { 
      return new MyServiceHost(serviceType, baseAddresses); 
     } 
    } 
} 

namespace WcfHelpRestService 
{ 
    public class MyServiceHost : WebServiceHost 
    { 
     public MyServiceHost(Type serviceType, Uri[] baseAddresses): base(serviceType, baseAddresses) 
     { 

     } 
     public override void AddServiceEndpoint(System.ServiceModel.Description.ServiceEndpoint endpoint) 
     { 
      endpoint.Behaviors.Add(new HelpPageEndpointBehavior("ACME LLC")); 
      base.AddServiceEndpoint(endpoint); 
     } 
    } 
} 

但我不断收到错误:

[AddressAlreadyInUseException: HTTP could not register URL http://+:51443/Service1/help/ because TCP port 51443 is being used by another application.]
System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() +1106

不太清楚我在做什么错,所以任何帮助将不胜感激。

TIA

瑟伦

回答

0

貌似这个地址仅仅通过一些其他应用程序锁定。

这可能是情况:

  • 当您使用同一地址为其它应用程序。
  • 当你开始相同的应用程序两次相同的地址时,IIS 5.1中使用的是专门的端口锁定你的情况51443.

从上面

  • ,看起来像第三个。