2011-01-06 7 views
0

WCF 서비스를 만들고 콘솔을 통해 호스팅했습니다. 'net.tcp : //192.0.0.0 : 9100/ConsoleApplication3/커뮤니케이터 내가 다른 웹 응용 프로그램을 작성하려고 할 때하지만 콘솔을 통한 WCF 서비스 호스팅

메타 데이터 가 해결 될 수 없음을 참조가 포함

의주고 오류 서비스 참조를 추가합니다 .svc/mextcp '. net.tcp : //192.0.0.0 : 9100/ConsoleApplication3/Communicator.svc/mextcp에 연결할 수 없습니다. 연결 시도가 00 : 00 : 00.9843750 인 기간 동안 지속되었습니다. TCP 오류 코드 10061 : 대상 기계 이 적극적으로 192.0.0.0:9100을 거부했기 때문에 연결할 수 없습니다. 대상 컴퓨터가 적극적으로 거부했습니다. 192.0.0.0:9100 서비스가 현재 솔루션에 정의되어있는 경우 서비스를 빌드하고 서비스 참조를 다시 추가하십시오. 여기

코드입니다 :

namespace ConsoleApplication3 
{ 
class Program 
{ 
    static void Main(string[] args) 
    { 
     try 
     { 
      using (ServiceHost host = new ServiceHost(typeof(Communicator))) 
      { 
       host.Open(); 
       Console.WriteLine("Press <Enter> to terminate the Host application."); 
       Console.ReadLine(); 
      } 
     } 
     catch (Exception ex) 
     { 
      Console.WriteLine(ex.Message); 
      Console.ReadLine(); 
     } 
    } 
} 

[ServiceContract] 
public interface ICommunicator 
{ 
    [OperationContract] 
    string SayHello(); 
} 

public class Communicator : ICommunicator 
{ 
    public string SayHello() 
    { 
     return "I am here"; 
    } 
} 

을 그리고 여기에 구성입니다 :

<configuration> 
    <system.serviceModel> 
    <services> 
     <service name="ConsoleApplication3.Communicator" behaviorConfiguration="CommunicatorBehavior"> 
     <!-- Service Endpoints --> 
     <endpoint address="ConsoleApplication3" binding="netTcpBinding" 
      contract="ConsoleApplication3.ICommunicator"/> 
     <!-- This Endpoint is used for genertaing the proxy for the client --> 
     <!-- To avoid disclosing metadata information, set the value below to false and 
     remove the metadata endpoint above before deployment --> 
     <endpoint address="mex" contract="IMetadataExchange" binding="mexTcpBinding" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:9100/"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="CommunicatorBehavior"> 
      <serviceMetadata httpGetEnabled="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

답변

2

난 당신이 시도하고 당신의 서비스에 얻을 수있는 주소를 잘못 찾은 것 같아.

netTcpBinding과 같은 콘솔 앱에서 직접 서비스를 호스팅했으며 net.tcp://localhost:9100/의 기본 주소를 정의했으며 MEx 종단점은 net.tcp://localhost:9100/mex입니다. 서비스에 연결하려고 할 때

그래서 당신은 기본 주소

net.tcp://localhost:9100/ 

또는 MEX 주소

net.tcp://localhost:9100/mex 

중 하나를 사용해야합니다.

연결하려는 것 같은이 주소 (net.tcp://192.0.0.0:9100/ConsoleApplication3/Communicator.svc/mextcp)를 어떻게 생각해 냈는지 모르겠으나이 주소는 이 아니고이 유효합니다. 첫째 - 거기 netTcpBinding 웹 서비스를 자체 호스팅 할 때 사용 할 * SVC는 파일이 없습니다, 당신은에서이 /mextcp 주소를 어디서 얻었는지 모르겠어요 .....

업데이트 : 나는했다 당신의 난을 시작하려고 할 때 나는 Windows 방화벽에서 경고를 않았다

alt text

: 코드, 인터페이스 및 서비스 구현 및 서비스 구성에 새 콘솔 응용 프로그램을 만들어, 그것은 내 컴퓨터에서 잘 작동합니다 Visual Studio 내에서 액세스 허용에 대한 콘솔 응용 프로그램 - 허용 한 것.

+0

그래서 무엇이 주소가되어야합니까 'net.tcp : // localhost : 9100/mex '이긴하지만 여전히 같은 오류가 있습니다 – BreakHead

+0

@BreakHead : 또는이 하나가 궁극적으로 갈 것 같습니다. :'net.tcp : //192.168.168.145 : 9100 /' –

+0

고강도, 그래도 여전히 같은 오류 :( – BreakHead

관련 문제