2012-01-27 9 views
0

リモートマシン上にWCFサービスがホストされています。私はそれに接続し、WPFアプリケーションでサービスを完全に使用することができます。私はまた別のマシン上の別のWindowsサービスからWCFサービスに接続できるようにしたい。私はapp.configをWPFアプリケーションと同じように設定していますが、WindowsサービスはWCFサービスに接続しません。ここでエラーがある:WindowsサービスからWCFサービスに接続する

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.

ここではWindowsのサービスからのapp.configです:

<?xml version="1.0"?> 
<configuration> 
    <appSettings> 
    <add key="ServiceIP" value="127.0.0.1"/> 
    </appSettings> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <probing privatePath="lib" /> 
    </assemblyBinding> 
    </runtime> 
    <system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="NetTcpBindingEndpoint" closeTimeout="00:01:00" 
      openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:15" 
      transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" 
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" 
      maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.tcp://localhost:8731/WCFService/" binding="netTcpBinding" 
     bindingConfiguration="NetTcpBindingEndpoint" contract="WCFService.IWCFService" 
     name="NetTcpBindingEndpoint"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 
</configuration> 

私はなく、Windowsのサービスから、WPFアプリで罰金接続することができますなぜ任意のアイデア?

EDIT:Huusomに

おかげで、私はそれを得ることができた:2

EndpointAddress ep = new EndpointAddress("net.tcp://" + remoteIP + ":8731/WCFService/"); 
InstanceContext context = new InstanceContext(this); 
wcfObj = new WCFService.WCFServiceClient(context, "NetTcpBindingEndpoint", ep); 
wcfObj.Subscribe(); 

EDIT:ここ

が、私はコードで接続を作成しています方法ですサービスが実行されているアカウントを変更して作業します。問題は、サービスをインストールするユーザーにサービスアカウントを迷惑にするように頼む必要はないということです。それを動作させるためにこれ以外に何かできることはありますか?無効にすることのできるセキュリティはありますか?

+2

コードに接続を設定して、実際の接続の問題であり、.configファイルの読み込みではないことを確認しようとしましたか? – ChrFin

+0

それは多くのことができます。このエラーは、DataContractのすべてのフィールドが提供されていない場合、EmitDefaultValue = falseでマークされていない場合に最も発生しました。ここに示すようにWCF通信をトレースする場合は、http://msdn.microsoft.com/en-us/library/ms733025.aspxを追跡することができます。 – Josh

+1

デフォルトでは、Windowsサービスには、実行可能ファイルの現在の作業ディレクトリがありません。これは設定ファイルの混乱の原因となります。 –

答えて

0

質問のコメントから続行してください。 ip portに名前空間の予約を設定する必要があります。msdn

+0

その記事が適切かどうかはわかりません。私はHTTPまたはHTTPSを使用していませんが、むしろnet.tcp – Brian