title: 400 Bad request when pass xml to webservice
body: <p>I'm new in webservice.</p>
  
  <p>I've to pass xml to aspx web service called plog.asmx</p>
  
  <p>here is my code</p>
  
  <pre><code>String xmldata = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;" + 
              "&lt;SOAP:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + 
                "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + 
                "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" &gt;" +
                "&lt;![CD[&lt;soap:Body&gt;" +
                "&lt;SubmitJob xmlns=\"http://www.xdel.biz/XWS/\"&gt; " +
                "&lt;APIKey&gt;"+ API_KEY +"&lt;/APIKey&gt;" +
                "&lt;Job&gt;" +
                 "&lt;Customer_Name&gt;"+ Customer_Name +"&lt;/Customer_Name&gt;" +
                 "&lt;Address1&gt;"+ Address1 +"&lt;/Address1&gt;" +
                  "&lt;Address2&gt;"+ Address2 +"&lt;/Address2&gt;" +
                  "&lt;Postal_Code&gt;"+ Postal_Code +"&lt;/Postal_Code&gt;" +
                  "&lt;Phone_Number&gt;"+ Phone_Number +"&lt;/Phone_Number&gt;" +
                  "&lt;Mobile_Number&gt;"+ Mobile_Number +"&lt;/Mobile_Number&gt;" +
                  "&lt;Order_Reference&gt;"+ Order_Reference +"&lt;/Order_Reference&gt;" +
                  "&lt;Delivery_Instructions&gt;"+ Delivery_Instructions +"&lt;/Delivery_Instructions&gt;" +
                "&lt;/Job&gt;]]&gt;" +
              "&lt;/SubmitJob&gt;" +
                "&lt;/soap:Body&gt;]]&gt;" +
                "&lt;/SOAP:Envelope&gt;";
  
               System.out.println(xmldata); 
  
  
                try{
                    //Create socket
                    String hostname = "www.xdel.biz";
                    int port = 80;
                    InetAddress  addr = InetAddress.getByName(hostname);                    
                    Socket sock = new Socket(addr, port);
                    System.out.println(sock.toString());                    
  
                    //Send header
                    String path = "/xws/plog.asmx";
                    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.1\r\n");
                    wr.write("Host: www.xdel.biz\r\n");
                    wr.write("Content-Type: text/xml; charset=utf-8\r\n");
                    wr.write("Content-Length: " + xmldata.length() + "\r\n");                   
                    wr.write("SOAPAction: \"http://www.xdel.biz/XWS/SubmitJob\" \r\n");
                    wr.write("\r\n");
  
                    //Send data
                    wr.write(xmldata);
                    wr.flush();
  
                    System.out.println("1");
  
                    // 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>when I run the code, I got error like this</p>
  
  <blockquote>
    <p>HTTP/1.1 400 Bad Request
    Cache-Control: private
    Content-Type: text/xml; charset=utf-8
    Server: Microsoft-IIS/7.5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Thu, 13 Dec 2012 09:37:12 GMT
    Content-Length: 0</p>
  </blockquote>
  
  <p>I googled the error and tried to fix but no solution come out..</p>