2017-03-06 11 views
0

WCFとその設定に関する十分な経験がなく、この問題への対処方法がわかりません。だから、これは申し訳ありませんが、恐らく愚かな質問です。WindowsサービスでホストされているWCFをVMで使用する方法

私はWCFをホストするWindowsサービスの仮想マシンを持っています。この仮想マシンを実行するローカルマシン上で実行されているクライアントから、このWCFと通信したいと思います。ローカルでサービスを問題なく走らせることができますが、仮想マシン上のサービスと通信するには、正しく設定するのが難しいです。私はIISを使わずにTCP接続を使いたいです。

私は、VMのアドレス、代替アドレスとエンドポイントを指定することを試みましたが、成功しませんでした。正しい設定は何ですか?

<system.serviceModel> 

<bindings> 
    <netTcpBinding> 
    <binding name="NetTcpBindingConfiguration"> 
     <security mode="None" /> 
    </binding> 
    </netTcpBinding> 
</bindings> 

<services> 
    <service behaviorConfiguration="WCFHostBehaviour" name="TestRunnerWCF.Service"> 
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBindingConfiguration" 
     name="WCFHostNetTcpEndpoint" contract="TestRunnerWCF.IService" /> 
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
     name="WCFHostMexTcpEndpoint" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://192.168.10.25/Service" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="WCFHostBehaviour"> 
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

UPDATE 1: 私は私のクライアントにサービス参照を追加する方法を知りません。 localhostを使用している場合、ローカルマシン上でサービスを実行しますが、それは望ましくありません。

仮想マシンはHyper-Vで動作し、アドレスは192.168.10.25です。私はローカルマシンからpingできます。私はポート転送を使用しません。

私は、この設定を使用して仮想マシン上でクライアントを実行することができます

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
      <binding name="WCFHostNetTcpEndpoint"> 
       <security mode="None" /> 
      </binding> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.tcp://192.168.10.25/Service" binding="netTcpBinding" 
      bindingConfiguration="WCFHostNetTcpEndpoint" contract="ServiceReference1.IService" 
      name="WCFHostNetTcpEndpoint"> 
     </endpoint> 
    </client> 
</system.serviceModel> 

をしかし、私は、ローカルマシン上でクライアントを実行しようとすると、私は私の仮想マシンに接続することはできません。

Error: Cannot obtain Metadata from net.tcp://192.168.10.25/Service If this 
is a Windows (R) Communication Foundation service to which you have access, 
please check that you have enabled metadata publishing at the specified 
address. For help enabling metadata publishing, please refer to the MSDN 
documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata 
Exchange Error URI: net.tcp://192.168.10.25/Service Metadata contains 
a reference that cannot be resolved: 'net.tcp://192.168.10.25/Service'. 
Could not connect to net.tcp://192.168.10.25/Service. The connection attempt 
lasted for a time span of 00:00:21.0324561. TCP error code 10060: A 
connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed because 
connected host has failed to respond 192.168.10.25:808.  A connection 
attempt failed because the connected party did not properly respond after a 
period of time, or established connection failed because connected host has 
failed to respond 192.168.10.25:808 
+0

あなたが直面している問題の種類を詳しく説明できますか?これはあなたのサービスをどのように消費するのですか?多分問題はクライアント側にあるかもしれません。 – Reniuz

+0

クライアントのVMサービスにサービス参照を追加できません。 localhostをアドレスとして使用できますが、サービスはローカルマシン上でのみ実行されています。 – benderto

+1

VMのIPアドレスを指定する必要があります。しかし、まずそれにアクセスできるようにする必要があります。ウィット 'telnet 'に接続してみてください。接続できない場合は、VMのファイアウォール(新しいルール - >ポートの選択 - >次 - > wcfサービスポートの入力 - >終了)でインバウンドルールを追加するだけです。おそらくファイアウォールはあなたのVM wcfポートへの接続を妨げているでしょう。 – Reniuz

答えて

0

Reniuuzが指摘するように、VMのファイアウォールが私の接続をブロックしていました。 オリジナルコメント:

VMのIPアドレスを指定する必要があります。しかし、まずそれにアクセスできるようにする必要があります。ウィットtelnetに接続してみてください。接続できない場合は、VMのファイアウォール(新しいルール - >ポートの選択 - >次 - > wcfサービスポートの入力 - >終了)でインバウンドルールを追加するだけです。おそらくファイアウォールはあなたのVM wcfポートへの接続を妨げているでしょう。 - Reniuz

関連する問題