1 package com.ca.jndiproviders.dsml; 2 3 4 17 18 import java.io.*; 19 import java.net.*; 20 import java.util.logging.Logger ; 21 22 public class SoapClient 23 { 24 private static Logger log = Logger.getLogger(SoapClient.class.getName()); 25 26 32 68 79 public static String sendSoapMsg(String SOAPUrl, byte[] b, String SOAPAction) 80 throws IOException 81 { 82 log.finest("HTTP REQUEST SIZE " + b.length ); 83 84 if (SOAPAction.startsWith("\"") == false) 86 SOAPAction = "\"" + SOAPAction + "\""; 87 88 90 URL url = new URL(SOAPUrl); 93 HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); 94 95 httpConn.setRequestProperty("SOAPAction", SOAPAction); 97 httpConn.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\""); 98 httpConn.setRequestProperty("Content-Length", 99 String.valueOf(b.length)); 100 httpConn.setRequestProperty("Cache-Control", "no-cache"); 101 httpConn.setRequestProperty("Pragma", "no-cache"); 102 httpConn.setRequestMethod("POST"); 103 httpConn.setDoOutput(true); 104 httpConn.setDoInput(true); 105 106 OutputStream out = httpConn.getOutputStream(); 108 out.write(b); 109 out.close(); 110 111 113 InputStreamReader isr = new InputStreamReader(httpConn.getInputStream()); 114 BufferedReader in = new BufferedReader(isr); 115 116 StringBuffer response = new StringBuffer (1024); 117 118 String inputLine; 119 while ((inputLine = in.readLine()) != null) 120 response.append(inputLine); 121 122 in.close(); 123 124 log.finest("HTTP RESPONSE SIZE: " + response.length()); 125 126 return response.toString(); 127 } 128 129 154 } | Popular Tags |