473,804 Members | 3,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

submit form via HttpWebRequest or WebClient

has anyone successfully used HttpWebRequest or WebClient class to simulate
submission of a simple HTML form?

for example: a very simple plain-vanilla form with a textbox and a button.
when the button is clicked the form is submitted with the textbox contents.

could you please post some sample code? thanks.
Nov 18 '05
14 12145

"Joerg Jooss" <jo*********@gm x.net> wrote in message
news:uf******** ******@TK2MSFTN GP11.phx.gbl...
John A Grandy wrote:
very interesting ....

unfortunately, i'm in a stickier situation than communicating with a
public-facing website. [...]
i can't disclose the actual url -- but its similar to
"https://www.somecompany .com:5555/someservice.asm x/somefunction"

... so apparently the web-server is hosting a .net web-service.


Yes.
i tried your method. i constructed using the data-string
successfully used in the Java applet :

postData = "myTextArea=dat aString";

encodingName = "utf-8";

request.GetResp onse();

triggered a runtime error : "500 : internal server error"
do you think the problem might be with encodingName? what do you
think good possibilities are ?

or could the problem be in some other area ?


I guess the whole approrach could be wrong then. My sample code showed a
programmatic web form submission, but you probably need a SOAP client.
Actually, if it is a "proper" Web Service, VS .NET should be able to
generate the necessary client-side code for you. The test code you've

posted doesn't fit into the picture at all, though.

I guess you'll need to talk to the Web Service guys to find out what
requests their web service can handle.

Cheers,

--
Joerg Jooss
jo*********@gmx .net

Nov 18 '05 #11
are the web.config <webServices> settings related to successfully posting to
a remote web-service ?

or do these settings only relate to the hosting of web-services of
web-servers ... ?
for example, by default , the HttpPost setting is not present in web.config
.....

web.config file

<webServices>

<protocols>

<add name="HttpPost" />

</protocols>

</webServices>

"Joerg Jooss" <jo*********@gm x.net> wrote in message
news:uf******** ******@TK2MSFTN GP11.phx.gbl...
John A Grandy wrote:
very interesting ....

unfortunately, i'm in a stickier situation than communicating with a
public-facing website. [...]
i can't disclose the actual url -- but its similar to
"https://www.somecompany .com:5555/someservice.asm x/somefunction"

... so apparently the web-server is hosting a .net web-service.


Yes.
i tried your method. i constructed using the data-string
successfully used in the Java applet :

postData = "myTextArea=dat aString";

encodingName = "utf-8";

request.GetResp onse();

triggered a runtime error : "500 : internal server error"
do you think the problem might be with encodingName? what do you
think good possibilities are ?

or could the problem be in some other area ?


I guess the whole approrach could be wrong then. My sample code showed a
programmatic web form submission, but you probably need a SOAP client.
Actually, if it is a "proper" Web Service, VS .NET should be able to
generate the necessary client-side code for you. The test code you've

posted doesn't fit into the picture at all, though.

I guess you'll need to talk to the Web Service guys to find out what
requests their web service can handle.

Cheers,

--
Joerg Jooss
jo*********@gmx .net

Nov 18 '05 #12
John A Grandy wrote:
are the web.config <webServices> settings related to successfully
posting to a remote web-service ?

or do these settings only relate to the hosting of web-services of
web-servers ... ?
for example, by default , the HttpPost setting is not present in
web.config ....

web.config file

<webServices>

<protocols>

<add name="HttpPost" />

</protocols>

</webServices>


You're right, these lines control whether an ASP.NET based web service
accepts "pure" (non SOAP) requests. The line <add name="httPost"/> should
enable posting. Note this is *disabled* in ASP.NET 1.1 by default.

Cheers,

--
Joerg Jooss
jo*********@gmx .net
Nov 18 '05 #13
so, for my purposes of communicating with a remote web service (hosted by a
commercial company) ...

it is *their* responsibility to make sure that their web.config (or
machine.config) is properly setup to accept HTTPPost requests ... ?
"Joerg Jooss" <jo*********@gm x.net> wrote in message
news:eL******** *****@TK2MSFTNG P12.phx.gbl...
John A Grandy wrote:
are the web.config <webServices> settings related to successfully
posting to a remote web-service ?

or do these settings only relate to the hosting of web-services of
web-servers ... ?
for example, by default , the HttpPost setting is not present in
web.config ....

web.config file

<webServices>

<protocols>

<add name="HttpPost" />

</protocols>

</webServices>


You're right, these lines control whether an ASP.NET based web service
accepts "pure" (non SOAP) requests. The line <add name="httPost"/> should
enable posting. Note this is *disabled* in ASP.NET 1.1 by default.

Cheers,

--
Joerg Jooss
jo*********@gmx .net

Nov 18 '05 #14
John A Grandy wrote:
so, for my purposes of communicating with a remote web service
(hosted by a commercial company) ...

it is *their* responsibility to make sure that their web.config (or
machine.config) is properly setup to accept HTTPPost requests ... ?


*Technically* yes.

But in the end, this is decision between business partners ("We want POST!"
"We have SOAP!") and of course of IT security. If I was concerned: They
offer the service, they make they rules, and they need to tell you what you
can do and what you should do.

Cheers,

--
Joerg Jooss
jo*********@gmx .net
Nov 18 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
520
by: Brent | last post by:
Hi, I want to build an app (C#, windows app, or web app, shouldn't make a difference) that submits an address to the canada post website's address lookup and then scrape the postal code out of the resulting page. Here is their page. http://www.canadapost.ca/tools/pcl/bin/advanced-e.asp It uses a form post. I would like a basic rundown of how to submit my own info into their results page (post), and then scrape out the info I need....
10
19364
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
5
60920
by: Darran | last post by:
Hi I want to be able to retrieve the data from a given URL, fill in the necessary form fields and submit the form back to the server, all from within a Windows Application. I can retrieve the HTML from the page, using the HttpWebRequest class but that is where I have become stuck. These are the remaining items I would like to be able to do 1 Fill in the necessary fields on the form. 2 Submit the data back to the server
1
11942
by: Jason Manfield | last post by:
What is the difference (pros and cons) between retrieving data from the web using System.Web.WebClient and using HttpWebRequest and Response to get the data? The WebClient download methods seem to neatly encapsulate the multiple steps (request.Create; request.GetResponse; response.GetResponseStream ...) required with the traditional HttpWebRequest/Response approach. I am trying to crawl urls and download data.
1
1237
by: Steve Klett | last post by:
Hello- I would like to implement something like what is covered in this article: http://www.netomatix.com/HttpPostData.aspx It shows how to post a form programtically vs with an actual form from a web page. Basically, I will have a desktop application that will post a form to an ..aspx page.
0
1473
by: natzol | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great advices but still having troubles... it might some obvious error that I am making but I just dont see it. ==================FIRST - Webclient=================================
4
12717
by: Natalia | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great advices but still having troubles... it might some obvious error that I am making but I just dont see it. ==================FIRST - Webclient=================================
12
7990
by: Mark Rae | last post by:
Hi, The following code works: HttpWebRequest objRequest = null; try { HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); using (HttpWebResponse objResponse =
1
3712
by: ERobishaw | last post by:
Using Winform app writing a HTTP Post using the following... on the server side, I get no form fields. Request.Form.AllKeys.Length = 0. If I put the field/value paris in the URL I can use Request to retrieve the values, but POST doesn't work. There is NO Proxy... the only thing I can think is that ASP.NET is somehow filtering out the page because I'm obviously not posting the viewstate??? Seems like there was some setting for this,...
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.