title: Java: How to post this XML request?
body: <p>i'm working with SOA using WebServices.
  So i need to send a XML request to receive another XML with the response.</p>
  
  <p>I create this class:</p>
  
  <pre><code>package com.ws.test;
  
  import java.net.*;
  import java.io.*;
  
  public class SendXML {
  
      public static void main(String[] args) {
  
          try {
              String strSOAP = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;";
  
              strSOAP += "&lt;SOAP-ENV:Envelope ";
  
              strSOAP += " xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/";
  
              strSOAP += " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/";
  
              strSOAP += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance";
  
              strSOAP += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema";
  
              strSOAP += " xmlns:ns=\"urn:bacnet_ws\"&gt;";
  
              strSOAP += " &lt;SOAP-ENV:Body SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"&gt;";
  
              strSOAP += " &lt;ns:getValue&gt;";
  
              strSOAP += " &lt;ns:options&gt;&lt;/ns:options&gt;";
  
              strSOAP += " &lt;ns:path&gt;/.sysinfo/.vendor-name&lt;/ns:path&gt;";
  
              strSOAP += " &lt;/ns:getValue&gt;";
  
              strSOAP += " &lt;/SOAP-ENV:Body&gt;";
  
              strSOAP += "&lt;/SOAP-ENV:Envelope&gt;";
  
  
              //Create socket
              String hostname = "192.168.1.2";
              int port = 8080;
              InetAddress addr = InetAddress.getByName(hostname);
              Socket sock = new Socket(addr, port);
  
              //Send header
              String path = "/rcx-ws/rcx";
              BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(), "UTF-8"));
              // You can use "UTF8" for compatibility with the Microsoft virtual machine.
              wr.write("POST " + path + " HTTP/1.0\r\n");
              wr.write("Host: 192.168.1.2\r\n");
              wr.write("Content-Length: " + strSOAP.length() + "\r\n");
              wr.write("Content-Type: text/xml; charset=\"utf-8\"\r\n");
              wr.write("\r\n");
  
              //Send data
              wr.write(strSOAP);
              wr.flush();
  
              // Response
              BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
              String line;
              while ((line = rd.readLine()) != null) {
  
                  System.out.println(line);
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>But this is not right because i receive this message error:</p>
  
  <blockquote>
    <p>HTTP/1.1 500 Internal Server Error
    Server: gSOAP/2.7 Content-Type:
    text/xml; charset=utf-8
    Content-Length: 570 Connection: close</p>
    
    <p>
    SOAP-ENV:VersionMismatchSOAP
    version mismatch or invalid SOAP
    message</p>
  </blockquote>
  
  <p>I need to send this parameter to the another system :</p>
  
  <pre><code>strSOAP += " &lt;ns:getValue&gt;";
  
  strSOAP += " &lt;ns:options&gt;&lt;/ns:options&gt;";
  
  strSOAP += " &lt;ns:path&gt;/.sysinfo/.vendor-name&lt;/ns:path&gt;";
  
  strSOAP += " &lt;/ns:getValue&gt;";
  </code></pre>
  
  <p>How i could do that in Java ?</p>
  
  <p>Best regards,
  Valter Henrique.</p>