Consuming webservice from wsdl with basic authentication from asp.net - c#

I have a WSDL file. I want to consume webservice from this WSDL. I have added service reference by using this WSDL and created proxy. I have created required parameter for invoking my service method. Actually webservice is protected by a basic authentication. But in the client proxy no option found to provide the user name and password. How could I invoke webservice?
I want to provide basic authentication credentials.
I am getting the following error when invoking service method without giving credentials.
System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
Please help me

Try this:
client.ClientCredentials.UserName.UserName = "xxxxxx";
client.ClientCredentials.UserName.Password = "xxxxx";
https://msdn.microsoft.com/en-us/LIbrary/ms733775.aspx

Related

Using Hixny web service for Query, Add etc

Is Anyone aware of using Hixny web service "https://integration.hixny.com/csp/public/hsbus/EnsLib.IHE.PIXv3.Manager.Services.cls" for Query,Add etc.
I Tried connecting to hixny endpoints by passing the sample XML and Certificate but it is not working. Getting Error "The request was aborted: Could not create SSL/TLS secure channel"
All the request to hixny requires valid SAML headers i.e UserName and UserOrganization.
Error occured as I was passing incorrect values.

Create Identity without CN at the certificate

I have a p12 certificate for a WebService (I've tested the certificate with SoapUI and it works, and I can access the URL with a WebBrowser).
The problem is that I can't consume the WebService with my c# development. When I try to access the webservice, returns the error message "Cannot create DNS identity probably due to the lack of CN parameter".
How can I override this? I've tried the CreateX509CertificateIdentity, but the error remains.
When you access your webservice on i.e. http://localhost/webservice url then your CN=localhost. If you want to make the webservice available at multiple urls then you need to specify all DNS addresses in subject alternative name (SAN) in the extensions of your certificate. Of course the certificate has to be trusted by client and server.

Cannot consume webservice over ssl

I am trying to consume webservice over https protocol. I have password-protected p12 file with certificate. After importing this file I can view service methods over browser and I can add service as a ServiceReference in VisualStudio client application. Problem appears while invoking methods of this service. I tried almost everything and still get error 'Could not establish secure channel for SSL/TLS with authority {server_name}'.
What can be wrong?
There are at least few possible causes but I would start by redefining the certificate validation callback:
ServicePointManager.ServerCertificateValidationCallback = (a,b,c,d) => true;
Put this like in your client code before you access the service.

How to make a call to secured web service(HTTPS) using basic http binding?

I need to import some model file into a Sharepoint central admin(HTTPS) from my local machine. What should be the configuration(using service.model)?
I am using the following configuration...
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_BusinessDataCatalogSharedService"
contract="BusinessDataCatalogSharedService" name="BasicHttpBinding_BusinessDataCatalogSharedService" />
And i am using the following c# code...
BusinessDataCatalogSharedServiceClient client =
new BusinessDataCatalogSharedServiceClient("BasicHttpBinding_BusinessDataCatalogSharedService1");
client.ClientCredentials.UserName.UserName = "...";
client.ClientCredentials.UserName.Password = "....";
I am getting the following error
MessageSecurityException was unhandeled
The HTTP request was forbidden with client authentication scheme 'Basic'.
I dont have enough knowledge about the authentication...Please help me out.
Thanks
Take a look at this information http://blog.adnanmasood.com/2008/07/16/https-with-basichttpbinding-note-to-self/
Most likely the problem is that you are running the service over HTTP not HTTPS. This will not work with username/password authentication. WCF is secure by default such that it will disallow calls with this type of authentication over HTTP.
You need to configure your service with a certificate to run over HTTPS and then also make the appropriate changes to you config (as is described in the link renu has posted).

Proxy Authentication Error while calling FedEx webservice

I am trying to call the FedEx tracking webservice. Currently I am running the sample application provided by FedEx itself (Added my test account number and other details). When I run the application, I get the following error:
The remote server returned an error: (407) Proxy Authentication Required.
I am inside a proxy at my organization and I tried provided the proxy server details to the webservice client using the WebProxy class as:
trackService.Proxy = WebProxy.GetDefaultProxy();
and also by providing the proxy server details as:
trackService.Proxy = new WebProxy("IP",8080);
But I still keep getting the same error!! Could somebody help me how to resolve this problem?
Thanks in advance,
Regards,
Abdel Olakara
What you seem to be missing is the proxy credentials. Try this:
trackService.Proxy = new WebProxy("IP", 8080);
trackService.Proxy.Credentials = new NetworkCredential(
username, password, domain);

Categories

Resources