1

PC @10.0.0.5:8732でホストされている「GetNameService」と呼ばれるwcf検出可能サービスがあります。これはwsHttpBindingでホストされ、UdpEndpointを介して検出できます。同じネットワーク内でそのようなサービスを検出するクライアント@10.0.0.9もあります。クライアントを実行すると、サービスを検出できますが、検出されたサービスのエンドポイントにはローカルホストが含まれています。どうすればこれが起こるのでしょうか、これで私を助けてください。

いくつかの詳細情報、

使用されるApp.config

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

 <system.web>
  <compilation debug="true" />
 </system.web>
 <!-- When deploying the service library project, the content of the config file must be added to the host's
 app.config file. System.Configuration does not support config files for libraries. -->
 <system.serviceModel>
  <services>
   <service name="NameService.GetNameService">
    <host>
     <baseAddresses>
      <add baseAddress = "http://10.0.0.5:8732/Design_Time_Addresses/NameService/GetNameService/" />
     </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address ="" binding="wsHttpBinding" contract="NameService.IGetNameService">
     <!--
       Upon deployment, the following identity element should be removed or replaced to reflect the
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
       automatically.
     -->
     <identity>
      <dns value="localhost"/>
     </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
   </service>
  </services>
  <behaviors>
   <serviceBehaviors>
    <behavior>
     <!-- To avoid disclosing metadata information,
     set the value below to false and remove the metadata endpoint above before deployment -->
     <serviceMetadata httpGetEnabled="True"/>
     <!-- To receive exception details in faults for debugging purposes,
     set the value below to true. Set to false before deployment
     to avoid disclosing exception information -->
     <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
 </system.serviceModel>

</configuration>

クライアントマシンでブラウザを開き、サービスアドレスを入力すると、サービスの詳細ページが表示されますが、wsdlリンクはローカルホストを指しています(以下を参照)。

svcutil.exe http:// localhost:8732 / Design_Time_Addresses / NameService / GetNameService /?wsdl

それ以外の

svcutil.exe http://10.0.0.5:8732/Design_Time_Addresses/NameService/GetNameService/?wsdl

また、同じアプリケーションは、DNSが利用可能で、システムがスイッチを介して接続されている私の職場では機能するようですが、PCがルーターを介して接続されている自宅では機能しません。これは何かに影響を与える可能性がありますか?!?

更新 IISで実行されておらず、通常のコンソールアプリケーションを介してホストされています

4

3 に答える 3

1

を使用してコードで解決しました(tcp.net接続用)。

// Add discovery feature.
m_Host.AddServiceEndpoint(new Discovery.UdpDiscoveryEndpoint());
m_Host.Description.Behaviors.Add(new Discovery.ServiceDiscoveryBehavior());
// Add ordinary service feature
var binding = new NetTcpBinding();
binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
m_Host.AddServiceEndpoint(
        typeof(IMyServiceContract),
        new NetTcpBinding(SecurityMode.None),
        new UriBuilder { Scheme = Uri.UriSchemeNetTcp, Port = 8732, Host = "10.0.0.5" , Path = "MyServiceContractPath" }.Uri
        );

残っている唯一の (おそらく小さい) 問題は、どのコンピューターの IP をホストとして設定するかということです...入力された Uri は、DiscoveryClient.Find(...) 応答で返されるものです。

于 2010-12-07T09:59:21.920 に答える
1

IIS で実行している場合は、サイトのデフォルトのホスト名規則が必要です。

  1. IIS を開く
  2. Web サイトを右クリックし、[プロパティ] をクリックします。
  3. [Web サイト] タブをクリックし、[Web サイトの識別] 見出しの下にある [詳細設定] ボタンをクリックします。
  4. Web サイトのデフォルトの ID (TCP ポート 8732) が必要です。それを編集し、ホスト ヘッダーの値が Web サイトのドメイン名であることを確認します (したがって、www.yourdomain.com と表示されるはずです)。

詳細については、 http://forums.asp.net/p/1096811/1659596.aspxを参照してください。

于 2010-09-17T06:24:23.700 に答える
0

それでもこれが必要な場合は、baseAddress でワイルドカードを使用できます。

<add baseAddress = "http://*:8732/Design_Time_Addresses/NameService/GetNameService/" />
于 2011-01-21T06:35:03.110 に答える