View Javadoc
1   package org.kuali.ole.deliver.service;
2   
3   import java.io.BufferedReader;
4   import java.io.InputStream;
5   import java.io.InputStreamReader;
6   import java.io.OutputStream;
7   import java.net.HttpURLConnection;
8   import java.net.URL;
9   
10  /**
11   * Created by sheiksalahudeenm on 5/5/15.
12   */
13  public class OLESOAPService {
14  
15      public static String sendSoapRequest(String url,String requestContent){
16          String responseString = "";
17          try {
18              URL oURL = new URL(url);
19              HttpURLConnection con = (HttpURLConnection) oURL.openConnection();
20              con.setRequestMethod("POST");
21              con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
22              // con.setRequestProperty("SOAPAction",
23              //   "http://192.168.55.223:8080/olefs/remoting/olePatronService");
24              con.setDoOutput(true);
25              OutputStream reqStream = con.getOutputStream();
26              reqStream.write(requestContent.getBytes());
27              InputStream resStream = con.getInputStream();
28              BufferedReader in = new BufferedReader(new InputStreamReader(resStream));
29              String line = null;
30              StringBuilder responseContentBuilder = new StringBuilder();
31              while((line = in.readLine()) != null) {
32                  responseContentBuilder.append(line);
33              }
34              responseString = responseContentBuilder.toString();
35          } catch (Exception ex) {
36              ex.printStackTrace();
37          }
38          return responseString;
39      }
40  }