How to pass the authentication in http header in .net while consuming Java web servic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • purudwivedi
    New Member
    • Jul 2007
    • 2

    How to pass the authentication in http header in .net while consuming Java web servic

    I am programming what is to be a web service client that will use an
    HTTP-POST to request and retrieve data. The remote server (written in java
    for what it's worth) requires basic authentication as per RFC 2617
    (http://www.faqs.org/rfcs/rfc2617.html). My attempts to authenticate are
    failing. The server requires the header to be present with the request.
    For security reasons, it will not reply in any way if the header is not
    present.

    i need a code in .net which consume Java web services that pass basic authentication as per RFC 2617 (http://www.faqs.org/rfcs/rfc2617.html).means basic authentication is required in header for every request. Please help me for the code .

    Code is:

    request = (HttpWebRequest ) WebRequest.Crea te(SomeURI);

    request.PreAuth enticate = true;
    request.Credent ials = new NetworkCredenti al("rts","rts") ;

    request.Timeout = 30 * 1000;
    request.Method = "POST";
    request.Content Type = "applicatio n/x-www-form-urlencoded";
    request.Content Length = reqBytes.Length ;

    Stream reqStream = request
    reqStream.Write (reqBytes,0,req Bytes.Length);
    reqStream.Close ();


    This code doesn't pass the header authentication

    Thanks
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Rather than ask someone else to code it for you...

    You say you have been working on this, but it is failing. Please provide your code for authentication along with the errors you are receiving and someone here should be able to help point out where you have gone awry.

    Comment

    • purudwivedi
      New Member
      • Jul 2007
      • 2

      #3
      this is my code but no header is passed

      Code:
      request = (HttpWebRequest) WebRequest.Create(SomeURI);
      
      request.PreAuthenticate = true;
      request.Credentials = new NetworkCredential("JoeBlow","MountainHo");
      
      request.Timeout = 20 * 1000;
      request.Method = "POST";
      request.ContentType = "application/x-www-form-urlencoded";
      request.ContentLength = reqBytes.Length;
      
      Stream reqStream = request
      reqStream.Write(reqBytes,0,reqBytes.Length);
      reqStream.Close();
      Last edited by tlhintoq; Mar 23 '10, 05:20 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]

      Comment

      Working...