0

私は wsDualHttpBinding を使用しています。サーバーは自己ホスト型です。クライアントの ClientBaseAddress にアクセスできないという問題が発生しています。この問題を解決する方法がわかりません。

これが私のサービス構成です:

<system.serviceModel>
<services>
  <service name="GuiEndpoint.GuiService">
    <endpoint address="" 
              binding="wsDualHttpBinding"
              bindingConfiguration="GuiEndpoint" 
              name="dualHttpBinding" 
              contract="Common.IGuiService">
      <!--<identity>
        <dns value="localhost"/>
      </identity>-->
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://192.168.1.199:8733/Design_Time_Addresses/GuiEndpoint/IGuiService/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsDualHttpBinding>
    <binding name="GuiEndpoint">
      <security mode="None">
        <message clientCredentialType="None"/>
      </security>
    </binding>
  </wsDualHttpBinding>
</bindings>
<diagnostics>
  <messageLogging logEntireMessage="true"
                  maxMessagesToLog="300"
                  logMessagesAtServiceLevel="true"
                  logMalformedMessages="true"
                  logMessagesAtTransportLevel="true" />
</diagnostics>

私のクライアントでは、次のコードを使用してプログラムで接続しています。

WSDualHttpBinding binding = new WSDualHttpBinding();

binding.Security.Mode = WSDualHttpSecurityMode.None;
binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
binding.ClientBaseAddress = new Uri("192.168.1.189:8080/TempUri");

EndpointAddress endpoint = new EndpointAddress(Helper.CreateUri(client.Connection.ServerAddress));

context = new InstanceContext(this);

serviceClient = new GuiServiceClient(context, binding, endpoint);
serviceClient.InnerDuplexChannel.Faulted += InnerChannelOnFaulted;

try
{
    if (serviceClient.Subscribe())
    {
        startKeepAliveTimer();
    }
}
catch (EndpointNotFoundException)
{
    this.Error("Couldn't Connect!");
}

ここで、Fidler を使用して、メッセージが行き来するのを確認できます。

サーバ: ここに画像の説明を入力

クライアント: ここに画像の説明を入力

ご覧のとおり、クライアントはサーバーと通信できますが、サーバーはクライアントと通信できないようです。

クライアントに名前空間も登録しました。

ここに画像の説明を入力

クライアント ポートにもアクセスできます。

Starting Nmap 6.25 ( http://nmap.org ) at 2013-01-03 14:05 Mountain Standard Time

Nmap scan report for 192.168.1.189

Host is up (0.10s latency).

PORT     STATE SERVICE

8080/tcp open  http-proxy

MAC Address: xx:0B:A9:57:xx:xx (Intel Corporate)

Nmap done: 1 IP address (1 host up) scanned in 13.42 seconds

ここでどんな種類の助けも素晴らしいでしょう!

4

1 に答える 1

1

マイクロソフトがドキュメントに記載できなかったのは、次のことです。

ClientBaseAddress で指定する IP アドレスは、ホスト名に解決可能でなければなりません。つまり、サーバーがホスト名でクライアントに ping を送信できない場合、接続を確立することはできません。

あなたが発見したように、それはうまくいきません!

次のように、192.168.1.189 をクライアント PC のホスト名に置き換えてみてください。

 http://ClientHostName:8080/TempURI

また、ヒントとして、ポートを登録する必要がない場合は、アドレスを使用してください

http://MyClientHostName/Temporary_Listen_Addresses/TempUri

で始まる任意の URL を登録できるためです。

http://+80/Temporary_Listen_Addresses/
于 2013-11-28T01:29:24.877 に答える