2014-04-28 1 views
1

NetTcpBinding을 사용하는 WCF 서비스가 있으며이를 WPF 응용 프로그램에서 호스팅하고 싶습니다. 이 서비스는 제대로 시작하는 것 같다,하지만 난 노력하고있어 때 나는이 예외 얻을 비주얼 스튜디오에서 '서비스 참조 추가'를 사용하여 메타 데이터의 활용하려면 다음netTcpBinding을 사용하여 클라이언트 프로젝트에 WCF 서비스 참조를 추가 할 수 없습니다.

The URI prefix is not recognized. 
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8000/Mandrake/mex'. 

내 서비스 프로젝트의 app.config 파일 :

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 

<appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
</appSettings> 
<system.web> 
    <compilation debug="true" /> 
</system.web> 
<system.serviceModel> 
    <services> 
    <service name="Mandrake.Service.OTAwareService"> 
     <endpoint address="OTService" binding="netTcpBinding" contract="Mandrake.Service.IOTAwareService"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint name="MEX" address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
     <host> 
     <baseAddresses> 
      <add baseAddress="net.tcp://localhost:8000/Mandrake/" /> 
     </baseAddresses> 
     </host> 
    </service> 
    </services> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior> 
     <serviceMetadata/> 
     <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

</configuration> 

그리고 호스팅 응용 프로그램의 코드 : 나는 문제에 발견

Uri baseAddress = new Uri("net.tcp://localhost:8000/Mandrake"); 
ServiceHost host = new ServiceHost(typeof(OTAwareService), baseAddress); 

try 
{ 
    host.AddServiceEndpoint(typeof(IOTAwareService), new NetTcpBinding(), "OTService"); 

} 
catch (CommunicationException e) 
{ 
    Console.WriteLine(e.Message); 
    host.Abort(); 
} 

용액은 MEX 엉 서비스 설정에 'serviceMetaData'를 추가 또는 제공에 대해 주로했다 dpoint. 뭔가 제안 해 주시겠습니까?

편집

:는 최종 설정

:

<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="NewBehavior0"> 
     <serviceMetadata /> 
     <serviceDebug includeExceptionDetailInFaults="True" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="Mandrake.Service.OTAwareService" behaviorConfiguration="NewBehavior0"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://localhost:8036/OTService"/> 
     </baseAddresses> 
    </host> 

    <endpoint address="" binding="netTcpBinding" name="TcpEndpoint" contract="Mandrake.Service.IOTAwareService" /> 
    <endpoint address="mex" binding="mexTcpBinding" name="MetadataEndpoint" contract="IMetadataExchange" /> 

    </service> 
</services> 
</system.serviceModel> 

호스팅 응용 프로그램 : 나는 그것을 알아 내기 위해 관리했습니다

host = new ServiceHost(typeof(OTAwareService)); 
host.Open(); 
+0

wsdl을 얻기 위해 http를 사용하여 서비스에 액세스하려면 webHttpBinding을 추가해야 할 수도 있습니다. –

+0

우리는 항상 mex 종점이있는 WindowsService에서 호스팅하는 net.tcp WCF 서버를 사용하며 저에게 도움이되었습니다. – user957902

+0

서비스 참조를 추가 할 수 있습니다. 참조 http://stackoverflow.com/questions/15270680/add-service-reference-when-using-nettcp-binding –

답변

2

는 serviceDebug의 includeExceptionDetailInFaults를 활성화 한 후 그것은 꽤 분명했다 .

Mandrake.Service.IOTCallback.Send operation references a message element [http://tempuri.org/:Send] that has already been exported from the Mandrake.Service.IOTAwareService.Send operation 

따라서 서비스 계약 및 콜백 인터페이스에도 Send (OTMessage) 작업이있었습니다. 오히려 추한 실수지만 누군가를 돕기 위해 해결책을 남겨 둘 것이라고 생각했습니다.

관련 문제