473,509 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send POST command to webserver

I need to communicate with a service that listens on a specific TCP/IP port.
I need to send an XML document using POST commands.

I know I need to use System.Net.HttpWebRequest and
System.Net.HttpWebResponse, but I am not sure how to use them.
Nov 21 '05 #1
6 2402
Look into using the WebClient class. If you want to post the data as form
fields, you use the UploadValues method. You can also use the OpenWrite
method, and write your XML document to that stream.

HTH.

"Philip Wagenaar" wrote:
I need to communicate with a service that listens on a specific TCP/IP port.
I need to send an XML document using POST commands.

I know I need to use System.Net.HttpWebRequest and
System.Net.HttpWebResponse, but I am not sure how to use them.

Nov 21 '05 #2
Phillip,

You might want to look at the following example on MSDN:
http://msdn.microsoft.com/library/de...treamtopic.asp

I don't have any experience pointing to a TCP/IP port other than the default
HTTP port 80 but you should be able to modify that as well in that class.
You also might want to check out the WebClient class which is similar to the
HTTPResponse/Request class @
http://msdn.microsoft.com/library/de...classtopic.asp.

Hopefully, that should point you in the right direction.

Curtis

"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:52**********************************@microsof t.com...
I need to communicate with a service that listens on a specific TCP/IP
port.
I need to send an XML document using POST commands.

I know I need to use System.Net.HttpWebRequest and
System.Net.HttpWebResponse, but I am not sure how to use them.

Nov 21 '05 #3
I found the webclient class and the openread and openwrite.

Openwrite can be used to data, but how do I receive the response? Openread
only requests a document.

"Curtis" wrote:
Phillip,

You might want to look at the following example on MSDN:
http://msdn.microsoft.com/library/de...treamtopic.asp

I don't have any experience pointing to a TCP/IP port other than the default
HTTP port 80 but you should be able to modify that as well in that class.
You also might want to check out the WebClient class which is similar to the
HTTPResponse/Request class @
http://msdn.microsoft.com/library/de...classtopic.asp.

Hopefully, that should point you in the right direction.

Curtis

"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:52**********************************@microsof t.com...
I need to communicate with a service that listens on a specific TCP/IP
port.
I need to send an XML document using POST commands.

I know I need to use System.Net.HttpWebRequest and
System.Net.HttpWebResponse, but I am not sure how to use them.


Nov 21 '05 #4
Found it:
Dim uri As String = "http://127.0.0.1:4012"
Dim postString As String = myXMLString

' Create a new WebClient instance.
Dim myWebClient As New WebClient

myWebClient.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")

Dim response As String =
Encoding.UTF8.GetString(myWebClient.UploadData(uri , "POST",
Encoding.UTF8.GetBytes(postString)))
MsgBox(response)

I hope this is a good usage of the webclient. Thank you both

"Philip Wagenaar" wrote:
I found the webclient class and the openread and openwrite.

Openwrite can be used to data, but how do I receive the response? Openread
only requests a document.

"Curtis" wrote:
Phillip,

You might want to look at the following example on MSDN:
http://msdn.microsoft.com/library/de...treamtopic.asp

I don't have any experience pointing to a TCP/IP port other than the default
HTTP port 80 but you should be able to modify that as well in that class.
You also might want to check out the WebClient class which is similar to the
HTTPResponse/Request class @
http://msdn.microsoft.com/library/de...classtopic.asp.

Hopefully, that should point you in the right direction.

Curtis

"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:52**********************************@microsof t.com...
I need to communicate with a service that listens on a specific TCP/IP
port.
I need to send an XML document using POST commands.

I know I need to use System.Net.HttpWebRequest and
System.Net.HttpWebResponse, but I am not sure how to use them.


Nov 21 '05 #5
UploadData was the way to go:

Dim response As String = Encoding.UTF8.GetString(myWebClient.UploadData(uri ,
"POST", Encoding.UTF8.GetBytes(postString)))

Thanks

"Scott Swigart" wrote:
Look into using the WebClient class. If you want to post the data as form
fields, you use the UploadValues method. You can also use the OpenWrite
method, and write your XML document to that stream.

HTH.

"Philip Wagenaar" wrote:
I need to communicate with a service that listens on a specific TCP/IP port.
I need to send an XML document using POST commands.

I know I need to use System.Net.HttpWebRequest and
System.Net.HttpWebResponse, but I am not sure how to use them.

Nov 21 '05 #6
Hi

Thanks for your experience sharing in the community.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #7

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

Similar topics

11
12039
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to...
2
3073
by: Martin Danielson | last post by:
Hello. I've been testing the WScript.Shell object and the Run command now for a server query. The file I am running generates a file with the server querys which i later on parse in my page. But...
5
10965
by: RK | last post by:
I am getting the "HTTP /1.1 405 - method not allowed" error when I am sending XML string over Msxml2.XMLHTTP object. I am sending data in POST, also passing querystring variable and here is the...
2
2517
by: Lisa Pearlson | last post by:
Hi, My php application (on Apache/Linux) needs to do the following: The PHP script receives a request from a client (binary), asking for certain records of data. My PHP script loops through...
6
5049
by: erdem kemer | last post by:
i cant send mail to yahoo mail or hotmail while i can send my other mail accounts (pop3) is it becouse yahoo and hotmail is web-based mail here is the code MailMessage mailMsg = new...
1
1615
by: Raichu | last post by:
Hi All, I'm new to VC++.net and I searched through the forums and couldn't find anything related to this. I'm trying to send a flat file from a VC++.net program to a PHP file residing on a...
0
1452
by: ultradiv | last post by:
I have a VB.NET application partly built that produces an xml output (just a file at present) I have a .NET webserver and SQLserver 2000 I need to be able to send the xml to the webserver/database...
9
77407
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
2
3738
by: xx75vulcan | last post by:
Howdy, I have successfully setup my php.ini file on a web server to communicate with my Microsoft Exchange Mail server, and can test the ability to send mail using the mail() function to...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
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...
1
7073
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...
0
7506
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...
0
5656
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,...
1
5062
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...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
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...

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.