Murray Brown
asked on
ASP.net VB.net post a string to an http server using some kind of http client using post method
Hi
In ASP.net VB.net how do I post a string to an http server using the post method. I was given the following link which helped but I still can't get my head around how to do this.
The java code below is an example of what I need to do in VB.net
http://www.codeproject.com/Articles/18034/HttpWebRequest-Response-in-a-Nutshell-Part-1
try {
// This will Post the xml string data...
URL url = new URL("http://IPAddress:Port/APIWebModule/APIServlet");
HttpURLConnection connection = (HttpURLConnection)url.ope nConnectio n();
connection.setRequestMetho d("POST");
connection.setDoOutput(tru e);
PrintWriter out = new PrintWriter( connection.getOutputStream ());
String data = "The XML string request";
out.print(data);
out.flush();
out.close();
// This will read the XML response data...
InputSource inSource = new InputSource(connection.get InputStrea m());
DOMParser dp = new DOMParser();
dp.parse(inSource);
Document doc = dp.getDocument();
// This gives you an XML DOM document to work with
}
catch (SAXException ex) {
}
catch (MalformedURLException ex) {
}
catch (IOException ex) {
}
In ASP.net VB.net how do I post a string to an http server using the post method. I was given the following link which helped but I still can't get my head around how to do this.
The java code below is an example of what I need to do in VB.net
http://www.codeproject.com/Articles/18034/HttpWebRequest-Response-in-a-Nutshell-Part-1
try {
// This will Post the xml string data...
URL url = new URL("http://IPAddress:Port/APIWebModule/APIServlet");
HttpURLConnection connection = (HttpURLConnection)url.ope
connection.setRequestMetho
connection.setDoOutput(tru
PrintWriter out = new PrintWriter( connection.getOutputStream
String data = "The XML string request";
out.print(data);
out.flush();
out.close();
// This will read the XML response data...
InputSource inSource = new InputSource(connection.get
DOMParser dp = new DOMParser();
dp.parse(inSource);
Document doc = dp.getDocument();
// This gives you an XML DOM document to work with
}
catch (SAXException ex) {
}
catch (MalformedURLException ex) {
}
catch (IOException ex) {
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER