title: How can i made soap Request and Response in Java?
body: <p>How can I execute the soap webservices and how can I print the data?</p>
  
  <p>Currently I am using the following code</p>
  
  <pre><code>package com.appulento.pack;
  
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.net.HttpURLConnection;
  import java.net.URL;
  
  public class SimpleHTTPRequest
  {
    public static void main(String[] args) throws Exception {
      final String url =
          "http://**********:8000/sap/bc/srt/rfc/sap/zmaterials_details/" +
            "800/zmaterials_details/zmaterials_details_bind",
        soapAction ="urn:sap-com:document:sap:soap:functions:mc-style/ZMATERIALS_DETAILS",
        envelope1="&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;" +
          "&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
            " xmlns:urn=\"urn:sap-com:document:sap:soap:functions:mc-style\"&gt;" +
          "&lt;soapenv:Header&gt;"+
          "&lt;soapenv:Body&gt;"+
          "&lt;urn:ZMATERIALS_DETAILS&gt;"+
          "&lt;Language&gt;D&lt;/Language&gt;"+
          "&lt;MaterialGroup&gt;00208&lt;/MaterialGroup&gt;"+
          "&lt;/urn:ZMATERIALS_DETAILS&gt;"+
          "&lt;/soap:Body&gt;"+
          "&lt;/soap:Envelope&gt;" ;
      HttpURLConnection connection = null;
      try {
        final URL serverAddress = new URL("http://*********:8000/sap/bc/srt/wsdl/"+
            "srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/" +
            "document?sap-client=800&amp;sap-user=************&amp;sap-password=****");
        connection = (HttpURLConnection)serverAddress.openConnection();
        connection.setRequestProperty("SOAPAction", soapAction);
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
        writer.append(envelope1);
        writer.close();
        final BufferedReader rd =
            new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) System.out.println(line);
      } finally { connection.disconnect(); }
    }
  }
  </code></pre>
  
  <p>I want send xml as input request and I want to display in xml too.</p>