none
how to call middle ware web service in DOTNET console application RRS feed

  • Question

  • Hi,

    I'm trying to use middle ware web service in my dot net code.

    Service is having username and password authentication.

    I'm passing the user name and password to the service, but still I'm getting the below error.

    The remote server returned an error: (403) Forbidden.

    Below is my code.

      

    var myRequest = (HttpWebRequest)WebRequest.Create(Url);
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
                myRequest.Proxy.Credentials = new System.Net.NetworkCredential(username, pwd);

               var response = (HttpWebResponse)myRequest.GetResponse();

    I'm sending correct username and password. still not working.



    k.Bhaskar.

    Friday, April 29, 2016 9:55 PM

All replies

  • Hi UdayBhaskar,

    I do not know if you can control the web service, if you can control it, please remove the username authentication in your config file, then please use the following configuration to disable the username authentication and make sure the service is working:

        <binding ...> 
            <security mode ="None"/> 
        </binding> 

    After that please call the web service from your console app again without providing the username and password to see if it works. If it does not work, then it seems that it may have something wrong in the client side code, please try to do the troubleshooting in your client side. If it works, then it seems that the issue is related incorrect username and password configuration in the service side or the incorrect username and password credential in the client side.
    For more information, please try to refer to:
    #How to: Use a Custom User Name and Password Validator:
    https://msdn.microsoft.com/en-us/library/aa702565(v=vs.110).aspx .
    Besides, please also try to enable the WCF trace to get more detailed information.

    If you can not control the web service, please try to use the Fiddler to check the response and request to see if it can provide your some detailed information.
    #Fiddler:
    http://www.telerik.com/fiddler .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Tuesday, May 3, 2016 7:46 AM
    Moderator
  • Hi Amy,

    We don't have control on the service. We are just consuming it.

    And we can able to connect the service without username password authentication.

    Thanks,

    Bhaskar.


    k.Bhaskar.

    Thursday, May 5, 2016 4:13 PM
  • Hello,

    >>We don't have control on the service. We are just consuming it.

    Since you can not control the web service, as my first reply said could you please try to use the Fiddler to check the response and request to see if it can provide your some detailed information? If you can also post the Fiddler information in here.
    #Fiddler:
    http://www.telerik.com/fiddler .

    >>And we can able to connect the service without username password authentication.

    Do you mean that the service support the both anonymous authentication and username authentication?

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 9, 2016 1:46 AM
    Moderator