• I wrote a C# program to call the web service. The web service keep failing with authentication failure. The user name and password information are correct.  Still I am not sure why it's failing.

     

    <font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">HttpWebRequest</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> wr;</font></font>

    <font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">HttpWebResponse</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> wResp;</font></font>

    <font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">string</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> results;</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wr = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">WebRequest</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">.CreateHttp(webUrl);</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wr.UseDefaultCredentials = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">false</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">;</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wr.PreAuthenticate = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">true</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">;</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wr.Credentials = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">new</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">NetworkCredential</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">(</font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">"domainfile://username"</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">, </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">"password"</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">);</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wr.PreAuthenticate = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">true</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">;</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wr.Method = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">"GET"</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">;</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">wResp = (</font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">HttpWebResponse</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">)wr.GetResponse();</font></font>

    <font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">Stream</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> dataStream = wResp.GetResponseStream();</font></font>

    <font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">StreamReader</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> reader = </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">new</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2"> </font></font><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2"><font color="" face="Consolas" size="2">StreamReader</font></font></font><font face="Consolas" size="2"><font face="Consolas" size="2">(dataStream);</font></font>

    <font face="Consolas" size="2"><font face="Consolas" size="2">results = reader.ReadToEnd();</font></font>

  • 1 Reply
  • Saravanakumar,

    There are two approaches we would recommend taking with this to troubleshoot the issue.

    1)   Verify the username/password combination is correct and that it follows the format we recommend.  Make  sure you're putting in your account name ahead of your username such as accountnameusername in that order, then the password.  Without the account name ahead of the username, connections simply won't work..

    2)  If the above doesn't work, we would recommend working with a developer or seeking help in forum setting that works exclusively with C# to see where the issue may lie.


    Thank you
    P.J. Bocek
    Webtrends Lead Support Engineer