Return Map so we can get more information
This commit is contained in:
parent
3f2b24fe19
commit
db528c70cd
@ -10,9 +10,14 @@ import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
public class soapProcessor {
|
||||
|
||||
public static String getCredentials(String username, String password) throws Exception
|
||||
@ -60,14 +65,16 @@ public class soapProcessor {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println(ex.toString());
|
||||
out.println(ex.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String send(HttpURLConnection thisConn, String varInputFile, Map hashMap, byte[] document) throws Exception
|
||||
public static Map send(HttpURLConnection thisConn, byte[] document) throws Exception
|
||||
{
|
||||
StringBuilder response = new StringBuilder(500);
|
||||
Map thisMap = new HashMap();
|
||||
int thisCode = -1;
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream outstr = new ByteArrayOutputStream();
|
||||
@ -77,13 +84,14 @@ public class soapProcessor {
|
||||
thisConn.setDoOutput(true);
|
||||
thisConn.setDoInput(true);
|
||||
|
||||
OutputStream out = thisConn.getOutputStream();
|
||||
out.write(document);
|
||||
out.close();
|
||||
OutputStream thisOut = thisConn.getOutputStream();
|
||||
thisOut.write(document);
|
||||
thisOut.close();
|
||||
|
||||
InputStreamReader ireader = new InputStreamReader(thisConn.getInputStream());
|
||||
|
||||
BufferedReader in = new BufferedReader(ireader);
|
||||
thisCode = thisConn.getResponseCode();
|
||||
String inputLine;
|
||||
while ((inputLine = in.readLine()) != null)
|
||||
{
|
||||
@ -94,11 +102,18 @@ public class soapProcessor {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println(ex.toString());
|
||||
return ex.toString();
|
||||
thisMap.put("success", false);
|
||||
thisMap.put("sent", new String(document, StandardCharsets.UTF_8));
|
||||
thisMap.put("response", ex.toString());
|
||||
thisMap.put("code", thisCode);
|
||||
return thisMap;
|
||||
}
|
||||
|
||||
return response.toString();
|
||||
thisMap.put("success", true);
|
||||
thisMap.put("sent", new String(document, StandardCharsets.UTF_8));
|
||||
thisMap.put("response", response.toString());
|
||||
thisMap.put("code", thisCode);
|
||||
return thisMap;
|
||||
}
|
||||
|
||||
static
|
||||
|
Loading…
x
Reference in New Issue
Block a user