1

wcf サービスがあり、Windows サービスとしてインストールします。192.168.2.6 マシンからこのサービスにアクセスできます。

"net.tcp://192.168.2.5:2025/Services/mex".

静的 IP とポートを使用して、別のコンピューターからこのサービスにアクセスしたいと考えています。

このサービスにアクセスするにはどうすればよいですか?

net.tcp://staticIp:port/Services/mex に接続しようとしましたが、エラーが発生しました:

Metadata contains a reference that cannot be resolved: 'net.tcp://[staticIP]:[port]/Services/mex'.If the service is defined in the current solution, try building the solution and adding the service reference again.

([ポート] を内部ポート 2025 に移動します)

私の設定:

<system.serviceModel>
<diagnostics>
  <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
  <netTcpBinding>
    <binding name="NetTcpBinding_IServices" />
  </netTcpBinding>
</bindings>
<client>
  <endpoint address="net.tcp://192.168.2.5:2025/Services" binding="netTcpBinding"
    bindingConfiguration="NetTcpBinding_IServices" contract="myServices.IServices"
    name="NetTcpBinding_IServices">
    <!--<identity>
      <dns value="localhost" />
    </identity>-->
  </endpoint>
</client>
<services>
  <service name="F8ShadowWcfLib.Services">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
      contract="F8ShadowWcfLib.IServices">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://192.168.2.5:2025/Services" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="false"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

編集1:

構成からタグを削除し、実行時に追加します。

myService.ServicesClient myServ = new myService.ServicesClient();
            EndpointAddress myEndpointAdd = new EndpointAddress(new Uri("net.tcp://[staticIP]:[port]/Services") ,
                                                EndpointIdentity.CreateDnsIdentity("net.tcp://f8srv.f8.com.tr:2299/Services"));

myServ.Endpoint.Address = myEndpointAdd;

別のエラーが発生しました: サーバーはクライアントの資格情報を拒否しました。

4

2 に答える 2

0

別の接続を許可するには、 AddressFilterMode : Any を設定し、サービス側とクライアント側の両方で ID を設定します。

ID 設定に関するこの記事:

http://msdn.microsoft.com/en-us/library/ms733130.aspx

 [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
   public class Services : IServices
   {
        .
        .
        .
   }
于 2013-09-14T14:08:19.177 に答える