Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Webservice POST to secure site

Reply
Thread Tools

Webservice POST to secure site

 
 
Xakware
Guest
Posts: n/a
 
      11-21-2003
Hello All,
I am new to this group, so please forgive me if this
question has been addressed. I have written a function that posts data
to a secure website. It works fine when in a console application or a
form, but the same code fails when used as a web method in a
webservice. The error message says that the number of bytes exceeds
the number of bytes specified in the ContentLength of the httprequest
object. Can anyone help me?? The code is below....


[WebMethod]

public string Send_Req(string strRequest)

{

string result;

HttpWebRequest httpRequest =
(HttpWebRequest)WebRequest.Create("https://www.securesite.com/CGI-BIN/CGIProg.exe");

httpRequest.Method = "POST";

httpRequest.ContentLength = strRequest.Length;

httpRequest.ContentType = "application/x-www-form-urlencoded";


X509Certificate myCert =
X509Certificate.CreateFromCertFile(@"C:\test.cer") ;

httpRequest.ClientCertificates.Add(myCert);


StreamWriter requestWriter = new
StreamWriter(httpRequest.GetRequestStream());

requestWriter.Write(strRequest);

requestWriter.Close();


HttpWebResponse httpResponse =
(HttpWebResponse)httpRequest.GetResponse();

StreamReader resultReader = new
StreamReader(httpResponse.GetResponseStream());

result = resultReader.ReadToEnd();

resultReader.Close();

return result;

}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Secure your digital information assets with Secure Auditor. SecureWindows with Secure Auditor alannis.albert@googlemail.com Cisco 0 04-14-2008 06:53 AM
Secure your digital information assets with Secure Auditor SecureWindows with Secure Auditor alannis.albert@googlemail.com Cisco 0 04-14-2008 06:52 AM
This page contains both secure and non secure items. A.M ASP .Net 5 06-08-2004 05:43 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM



Advertisments