diff --git a/pom.xml b/pom.xml
index 793ac32..4ac0ee5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
uk.co.jbuncle.hnapclient
hnap-client
- 2.0.0
+ 2.0.1
jar
0
diff --git a/src/main/java/uk/co/jbuncle/hnapclient/soap/BasicSoapClient.java b/src/main/java/uk/co/jbuncle/hnapclient/soap/BasicSoapClient.java
index 972df81..8003afc 100644
--- a/src/main/java/uk/co/jbuncle/hnapclient/soap/BasicSoapClient.java
+++ b/src/main/java/uk/co/jbuncle/hnapclient/soap/BasicSoapClient.java
@@ -5,6 +5,8 @@
import java.net.URL;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import uk.co.jbuncle.hnapclient.http.HttpClientI;
@@ -31,17 +33,35 @@ private String soapBody(final String payload) {
+ "" + payload + "";
}
- public String soapPost(final URL url, final String soapAction,
- final Map headers, final String body) throws SoapException {
+ public String soapPost(
+ final URL url,
+ final String soapAction,
+ final Map headers,
+ final String body
+ ) throws SoapException {
+ final String soapBody = this.soapBody(body);
+ headers.put("Content-Type", "text/xml; charset=utf-8");
+ headers.put("SOAPAction", '"' + soapAction + '"');
+
+ final String urlString = url.toString();
+
+ final String result;
+ try {
+ result = this.httpClient.post(urlString, headers, soapBody);
+ }
+ catch (HttpException ex) {
+ throw new SoapException("Request to '" + urlString + "' failed", ex);
+ }
+
+ if (result.isEmpty()) {
+ throw new SoapException("Recieved empty response body from '" + urlString + "'");
+ }
+
try {
- final String soapBody = this.soapBody(body);
- headers.put("Content-Type", "text/xml; charset=utf-8");
- headers.put("SOAPAction", '"' + soapAction + '"');
- String result = this.httpClient.post(url.toString(), headers, soapBody);
return getSoapBody(result);
}
- catch (HttpException | XMLException ex) {
- throw new SoapException(ex);
+ catch (XMLException ex) {
+ throw new SoapException("Response body from '" + urlString + "' is not valid XML'" + result + "'", ex);
}
}