Credentials and authentication on a web service

Last post 07-07-2009 11:21 AM by alaa9jo. 5 replies.

Sort Posts:

  • Credentials and authentication on a web service

    07-07-2009, 7:47 AM
    • Member
      6 point Member
    • elburs
    • Member since 01-21-2008, 5:11 PM
    • Posts 57

    Hello

    I want to consume a web service from a winform .net application (developed by an other firm in asp.net) and it requires an authentification


    So i tried to send a credential to it, but i receive an http 401  error unautorized


    So i checked out what is the soap message sent from my client, but it doesn't contain any authentification in the header 


    This is my code :


    CredentialCache v_Credential = new CredentialCache();
                ServiceCodaAuthentifie.InputService v_ServiceScoda = new ServiceCodaAuthentifie.InputService();
                string v_LoginAuthentificationToCodaWebService = ConfigurationSettings.AppSettings[CODA_LOGIN_WEB_SERVICE];
                string v_PassWordAuthentificationToCodaWebService = ConfigurationSettings.AppSettings[CODA_PASSWORD_WEB_SERVICE];
                v_Credential.Add(new Uri(v_ServiceScoda.Url), "Basic", new NetworkCredential(v_LoginAuthentificationToCodaWebService, v_PassWordAuthentificationToCodaWebService,""));
                //v_ServiceScoda.Credentials = v_Credential;
                
                
                
                v_ServiceScoda.Credentials = new NetworkCredential(v_LoginAuthentificationToCodaWebService, v_PassWordAuthentificationToCodaWebService, "");
                v_ServiceScoda.PostToBooks(new TestAuthentificationWebService.ServiceCodaAuthentifie.PostToBooksRequest());

    CredentialCache v_Credential = new CredentialCache();

               .InputService v_Service = new InputService();

                string login = "test";

               string password = "test";

                v_Credential.Add(new Uri(v_Service.Url), "Basic", new NetworkCredential(login,password,""));

                v_ServiceScoda.Credentials = v_Credential;

                v_Service.Method1();


    I tried also to change 'Basic' to 'Negotiate', to add a domain but nothing works

    and also saw on forums, that i needed to instantiate a class that derives from soapheader developed by the creator of the web service : http://www.codeproject.com/KB/cpp/authforwebservices.aspx


    so what is the good way ? use the specific class, or the properties 'Credentials'

    and why doesn't it work on my example

                

                

                


  • Re: Credentials and authentication on a web service

    07-07-2009, 8:20 AM
    • Contributor
      6,157 point Contributor
    • alaa9jo
    • Member since 07-01-2009, 1:17 PM
    • Jordan
    • Posts 1,126

    Have you tried this: 

    v_ServiceScoda.Credentials = CredentialCache.DefaultCredentials;

    Best Regards,
    Ala'a Alnajjar
    ----------------------------------------------------
    Please remember to click “Mark as Answer” on the post(s) that help(s) you even if they were for the same person.
    Also remember to close the thread by selecting “Resolved”,you will find it in your first post.

    Convert C# to VB.net and visa versus

    My Webblog
  • Re: Credentials and authentication on a web service

    07-07-2009, 8:26 AM
    • Member
      6 point Member
    • elburs
    • Member since 01-21-2008, 5:11 PM
    • Posts 57

    what for ?

    the web service expects a login password, not the default credential of the client

  • Re: Credentials and authentication on a web service

    07-07-2009, 10:26 AM
    • Contributor
      6,157 point Contributor
    • alaa9jo
    • Member since 07-01-2009, 1:17 PM
    • Jordan
    • Posts 1,126

    sorry,my mistake.

    BUT I've noticed that you didn't provide the domain name which is required.

    And for checking,If you type the url of your webservice in you browser,and provide these credentials,does it work or not.

    Best Regards,
    Ala'a Alnajjar
    ----------------------------------------------------
    Please remember to click “Mark as Answer” on the post(s) that help(s) you even if they were for the same person.
    Also remember to close the thread by selecting “Resolved”,you will find it in your first post.

    Convert C# to VB.net and visa versus

    My Webblog
  • Re: Credentials and authentication on a web service

    07-07-2009, 10:41 AM
    • Member
      6 point Member
    • elburs
    • Member since 01-21-2008, 5:11 PM
    • Posts 57

    impossible to call a web service on a browser, not supported

    and the domain is not required

    it doesnt answer my questions, why the wsdl doesnt contain any required information about security, and why my soap message doesnt contain the security

  • Re: Credentials and authentication on a web service

    07-07-2009, 11:21 AM
    Answer
    • Contributor
      6,157 point Contributor
    • alaa9jo
    • Member since 07-01-2009, 1:17 PM
    • Jordan
    • Posts 1,126
    Best Regards,
    Ala'a Alnajjar
    ----------------------------------------------------
    Please remember to click “Mark as Answer” on the post(s) that help(s) you even if they were for the same person.
    Also remember to close the thread by selecting “Resolved”,you will find it in your first post.

    Convert C# to VB.net and visa versus

    My Webblog
Page 1 of 1 (6 items)