Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

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.openConnection();
      connection.setRequestMethod("POST");
      connection.setDoOutput(true);
      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.getInputStream());
      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
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks very much. I'll give that a try