.NET Framework Developer Center > .NET Development Forums > Windows Communication Foundation > User-Defined endpoint address ignores Identity?
Ask a questionAsk a question
 

AnswerUser-Defined endpoint address ignores Identity?

  • Thursday, June 14, 2007 7:08 AMa-_B3N_- Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi guys

     

    I've got a client app interacting with a remote service, which could be anywhere (I want the user to enter the IP address and port for the app to connect to and provide username/password for authentication).

     

    My client app.config has a TCP endpoint as follows:

     

    Code Snippet

    <endpoint address="net.tcp://localhost:4182/PCPLocalService"

    binding="netTcpBinding" bindingConfiguration="netTcpEndpoint"

    contract="IService1" name="netTcpEndpoint">

    <identity>

    <certificate encodedValue="AwAAAAEAAAAUAAAApT7D6........etc.........." />

    </< FONT>identity>

    </< FONT>endpoint>

     

    And my client code specifies the endpoint like this:

     

    Code Snippet

    string remoteaddress = "net.tcp://192.584.34.32:4182/PCPLocalService" //this is actually generated from user-inputted IP address and Port.

    proxy = new Service1Client("netTcpEndpoint", remoteaddress);

    proxy.ClientCredentials.UserName.UserName = username;

    proxy.ClientCredentials.UserName.Password = password;

    ds.Merge(proxy.tblUsers()); //this just fills a table if the credentials are returned as correct.

     

    Now...if I take out the 'remoteaddress' from ("netTcpEndpoint", remoteaddress) it all works fine, but as soon as I put remoteaddress in, I get an identity error, as if the certificate encodedvalue is no longer used. But because I'm still specifying netTcpEndpoint as the endpoint name, shouldn't it also use this endpoint's identity, even though I'm throwing in a new remoteaddress to connect to instead of he default "net.tcp://localhost:4182/PCPLocalService"?

Answers

  • Thursday, June 14, 2007 7:22 AMBrian McNamara - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This overload replaces it entirely.

     

    If you want to just change the Uri, you can do something like

    Code Snippet

    proxy = new Service1Client("netTcpEndpoint");

    EndpointAddressBuilder eab = new EndpointAddressBuilder(proxy.Endpoint.Address);

    eab.Uri = new Uri(remoteAddress);

    proxy.Endpoint.Address = eab.ToEndpointAddress();

     

    which will preserve the config'd identity.

All Replies

  • Thursday, June 14, 2007 7:22 AMBrian McNamara - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This overload replaces it entirely.

     

    If you want to just change the Uri, you can do something like

    Code Snippet

    proxy = new Service1Client("netTcpEndpoint");

    EndpointAddressBuilder eab = new EndpointAddressBuilder(proxy.Endpoint.Address);

    eab.Uri = new Uri(remoteAddress);

    proxy.Endpoint.Address = eab.ToEndpointAddress();

     

    which will preserve the config'd identity.

  • Thursday, June 14, 2007 7:42 AMa-_B3N_- Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks Brian. You're the man!