2017-03-06 15 views
0

WCF 및 해당 구성에 대한 충분한 경험이 없으며이 문제를 해결하는 방법을 모르겠습니다. 그래서 나는 이것을 유감스럽게 생각한다. 아마 바보 같은 질문 일 것이다.VM에서 Windows 서비스로 호스팅되는 WCF를 사용하는 방법

가상 컴퓨터에 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 주소를 지정해야합니다. 하지만 먼저 액세스 할 수 있도록해야합니다. 오순절 텔넷 연결을 시도하십시오. 연결할 수 없다면 먼저 VM 방화벽 (새 규칙 -> 포트 선택 -> 다음 -> wcf 서비스 포트 입력 -> 완료)에서 인바운드 규칙을 추가하십시오. 대부분의 경우 방화벽은 VM wcf 포트에서 연결을 차단합니다. - Reniuz