0
votes

I have added ServiceReference with WSDL file, Client is throwing error:

Could not find endpoint element with name 'Endpoint1' and contract 'ServiceReference.IService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

I am not sure why the app.config endpoint is not picked up?

app.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>            
        <binding name="wsHttpPoint">
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName" establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://example.com:5555/Service.svc"
        binding="wsHttpBinding" bindingConfiguration="wsHttpPoint" contract="ServiceReference.IService"
        name="Endpoint1" />
    </client>
  </system.serviceModel>
</configuration>    

Manually creating Proxy:

WSHttpBinding binding = new WSHttpBinding();

binding.Security.Mode = SecurityMode.Transport;            

EndpointAddress address = new EndpointAddress("https://example.com:5555/Service.svc");

Client.ClientCredentials.UserName.UserName = "";    
Client.ClientCredentials.UserName.Password = "";

Client = new ConnectionServiceClient(binding, address);

Now there is a new error:

connectionSecure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint.

Am I setting the Binding correctly? Every post I see talks about basichttpBinding, is there any wsHttpbinding example for Security Transport?

1
Is the generated app.config in a different project than the executing assembly? - Marc
its in the same project - SniperVeera

1 Answers

0
votes

In your app.config, the client needs to know under which account the server runs. Just add:

<endpoint address="https://example.com:5555/Service.svc"
    binding="wsHttpBinding" bindingConfiguration="wsHttpPoint" contract="ServiceReference.IService"
    name="Endpoint1">
    <identity>
      <userPrincipalName value="AccountName@domain" />
    </identity>
  </endpoint>

As addition, it could be possible that you need to register your used port to the user that executes your service. Open your Developer Command Prompt as Administrator and run:

netsh http add urlacl url=http://+:{Port}/ user={Domain\User}

Exchange the Values in {} to your needs. This must only be run once.