Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have added a service reference i.e. a WSDL in my .NET visual studio code. But its not generating app.config file. I have also tried using the svcutil.exe in visual studio command prompt. I have also tried unchecking the 'Resuse types in referenced assemblies' by clicking the Advanced button while adding the service reference. But still App.config file is not generating.

So I have added the following code in my class. But still it is giving the error'could not find default endpoint element that references contract'.

client = new SalesLeadServiceClient();
_client.ClientCredentials.UserName.UserName = "***";
_client.ClientCredentials.UserName.Password = "***";

EndpointAddress endPointAddr = new EndpointAddress(address);
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
_client = new SalesLeadServiceClient(binding, endPointAddr);
BindingElementCollection elements = _client.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
_client.Endpoint.Binding = new CustomBinding(elements);
igcomp.PrepareConnectSession(_client.ChannelFactory);


It will be grateful if anyone can suggest any solution on this?
Posted
Updated 17-Aug-15 4:48am
v2

1 solution

 
Share this answer
 
v2
Comments
puneetkabra123 18-Aug-15 0:54am    
I have added the app.config file manually.But still it is not able to connect to the wsdl endpoint address(web services). It is giving the error 'could not find default endpoint element that references contract in the ServiceModel Client Configuration section.This is because no configuration file was found for your application or no endpoint element matching this contract could be found in the client element'.
Maciej Los 18-Aug-15 2:21am    
Please, see updated answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900