2017-02-22 25 views
0

WCFでWCFをObserver Design Pattern、クライアントとしてコンソールアプリケーションを実装しようとしています。クライアントで参照としてWCFサービスを追加しようとすると、以下のエラーが表示されます。WCFでのnet tcp設定

There was an error downloading 'http://localhost:20814/MessageService.svc/_vti_bin/ListData.svc/$metadata'. 
The request failed with the error message: 
-- 
<!DOCTYPE html> 
<html> 
    <head> 
     <title>Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].</title> 
     <meta name="viewport" content="width=device-width" /> 
     <style> 
     body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
     p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} 
     b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} 
     H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } 
     H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } 
     pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} 
     .marker {font-weight: bold; color: black;text-decoration: none;} 
     .version {color: gray;} 
     .error {margin-bottom: 10px;} 
     .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } 
     @media screen and (max-width: 639px) { 
      pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } 
     } 
     @media screen and (max-width: 479px) { 
      pre { width: 280px; } 
     } 
     </style> 
    </head> 

    <body bgcolor="white"> 

      <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> 

      <h2> <i>Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].</i> </h2></span> 

      <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> 

      <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

      <br><br> 

      <b> Exception Details: </b>System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].<br><br> 

      <b>Source Error:</b> <br><br> 

      <table width=100% bgcolor="#ffffcc"> 
       <tr> 
        <td> 
         <code> 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code> 

        </td> 
       </tr> 
      </table> 

      <br> 

      <b>Stack Trace:</b> <br><br> 

      <table width=100% bgcolor="#ffffcc"> 
       <tr> 
        <td> 
         <code><pre> 

[InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].] 
    System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +6065812 
    System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost) +701 
    System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +69 
    System.ServiceModel.ServiceHostBase.ApplyConfiguration() +162 
    System.ServiceModel.ServiceHost.ApplyConfiguration() +178 
    System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +184 
    System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +46 
    System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +235 
    System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +32 
    System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +524 
    System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1420 
    System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +52 
    System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +641 

[ServiceActivationException: The service '/MessageService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]..] 
    System.Runtime.AsyncResult.End(IAsyncResult result) +488839 
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174 
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174 
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174 
    System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +350822 
    System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9670421 
    System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9670421 
</pre></code> 

        </td> 
       </tr> 
      </table> 

      <br> 

      <hr width=100% size=1 color=silver> 

      <b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0 

      </font> 

    </body> 
</html> 
<!-- 
[InvalidOperationException]: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]. 
    at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) 
    at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost) 
    at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) 
    at System.ServiceModel.ServiceHostBase.ApplyConfiguration() 
    at System.ServiceModel.ServiceHost.ApplyConfiguration() 
    at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) 
    at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) 
    at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) 
    at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) 
    at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) 
[ServiceActivationException]: The service '/MessageService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].. 
    at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) 
    at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) 
    at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) 
    at System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) 
    at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) 
    at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) 
--> 
--. 
Metadata contains a reference that cannot be resolved: 'http://localhost:20814/MessageService.svc'. 
The requested service, 'http://localhost:20814/MessageService.svc' could not be activated. See the server's diagnostic trace logs for more information. 
If the service is defined in the current solution, try building the solution and adding the service reference again. 

しかし、私は以下の通りであるWCFのweb.configファイルに結合net.tcp定義されています:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="mexBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="mexBehavior" name="AtlasCommunicationServer.MessageService"> 
     <endpoint address="MessageService" binding="netTcpBinding" bindingConfiguration="" 
      contract="AtlasCommunicationServer.IMessageService" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8080" /> 
      <add baseAddress="net.tcp://localhost:20814" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    </system.serviceModel> 
</configuration> 

契約と契約の実装が

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Text; 

namespace AtlasCommunicationServer 
{ 
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. 
    [ServiceContract(CallbackContract = typeof(IMessageServiceCallback))] 
    public interface IMessageService 
    { 
     [OperationContract] 
     void SendData(string UserID, string Message); 
     bool Attach(string UserID, IMessageServiceCallback Callback); 
    } 

    public interface IMessageServiceCallback 
    { 
     [OperationContract] 
     bool Update(string Message); 
    } 

    [DataContract] 
    public class Message 
    { 
     public string MessageData; 
     public string UserID; 

     public Message(string UserID, string MessageData) 
     { 
      this.UserID = UserID; 
      this.MessageData = MessageData; 
     } 
    } 
} 

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Text; 

namespace AtlasCommunicationServer 
{ 
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together. 
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging. 
    public class MessageService : IMessageService 
    { 
     public Queue<Message> MessageQueue = new Queue<Message>(); 
     public Dictionary<string, IMessageServiceCallback> Notify = new Dictionary<string, IMessageServiceCallback>(); 

     public void SendData(Message _Message) 
     { 
      SendData(_Message.UserID, _Message.MessageData); 
     } 

     public void SendData(string _UserID, string Message) 
     { 
      if (Notify.Keys.Contains(_UserID)) 
      { 
       try 
       { 
        Notify[_UserID].Update(Message); 
       } 
       catch (Exception ex) 
       { 
        MessageQueue.Enqueue(new Message(_UserID, Message)); 
        //TODO handle the exception 
       } 
      } 
     } 

     public bool Attach(string _UserID, IMessageServiceCallback _Callback) 
     { 
      if (!Notify.Keys.Contains(_UserID)) 
      { 
       Notify.Add(_UserID, _Callback); 
       return true; 
      } 
      return false; 
     } 

     public bool Detach(string _UserID) 
     { 
      if (!Notify.Keys.Contains(_UserID)) 
      { 
       Notify.Remove(_UserID); 
       return true; 
      } 
      return false; 
     } 

    } 
} 
の下に示されています

エラーが表示されたら、私はここで何が間違っていますか?

+0

あなたの設定では、 'がありません。 – Venky

答えて

0

あなたのIIS/Webサイトの構成を確認してください:

プロトコルを有効にする

:HTTP、net.tcp

は、このウェブサイトのデフォルトの設定ではありません。 「プロトコルを有効にする」に「net.tcp」を手動で追加する必要があります。

関連する問題