Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2006

Tip: Looking for answers? Try searching our database.

POST info to website from web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brad - 03 Oct 2006 22:46 GMT
I'm trying to fill out a form on a website from within a web service.  I know
there is one field on that form called "call" and I want to put the value
"register" in it.  I'm using the following code, but I can't get it to work.  
Any Suggestions?  I suspect the problem is in the way i'm specifying the
string to send because i get an answer saying the Call parameter was not set:

string myDataString= "<INPUT TYPE=\"hidden\" NAME=\"call\"
VALUE=\"register\">";

HttpWebRequest request = (HttpWebRequest)
    WebRequest.Create(ConfigurationSettings.AppSettings["AdidasCUDSite"]);
request.Method = "POST";
request.ContentType = "text/xml";
byte[] postInfo = System.Text.UnicodeEncoding.ASCII.GetBytes(myDataString);
request.ContentLength = postInfo.Length;
Stream s = request.GetRequestStream();
s.Write(postInfo,0,postInfo.Length);

// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// we will read data via the response stream
Stream resStream = response.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
string responseStr = reader.ReadToEnd();
bruce barker (sqlwork.com) - 04 Oct 2006 23:49 GMT
you are confusing  html  with the postback data. the browser posts data as
name value pairs. also the content type should be
application/x-www-form-.urlencoded.   webclient has an uploadvalues that
helps.

-- bruce (sqlwork.com)

> I'm trying to fill out a form on a website from within a web service.  I
> know
[quoted text clipped - 25 lines]
> StreamReader reader = new StreamReader(resStream);
> string responseStr = reader.ReadToEnd();
Brad - 05 Oct 2006 00:37 GMT
Thanks for the suggestions but still no love.  I tried the different encoding
string but it didn't help, and i tried the following call to uploadvalues but
it returned  "500 - internal server error".  If you have any more
suggestions, i'd love to hear them.

NameValueCollection myCol = new NameValueCollection();
myCol.Add( "call", "register2" );

string uriString = "http://www.myurl.com/form.asp";
WebClient myWebClient = new WebClient();
byte[] responseArray = myWebClient.UploadValues(uriString,myCol);

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.