The SoapClient class is using the StringEntity constructor without a defined characterset, if you now want to send some UTF-8 characters the post execute will fail with the error message UnsupportedEncodingException. This is why the default is set to an ISO-characterset, if no characterset is defined. So I suggest to use the UTF-8 character set as a default in your code to avoid UnsupportedEncodingExceptions especially when your SoapRequest contains some special characters like in german language (p.e. ÄÜÖäüö).
// ----------------------------------------------------------------
// TRANSMISSION API
// ----------------------------------------------------------------
private HttpPost generatePost(String soapAction, String requestEnvelope) {
try {
HttpPost post = new HttpPost(endpointUri.toString());
// ----------------------------------------------------------------
// This is the changed code to avoid using ISO characterset.
StringEntity contentEntity = new StringEntity(requestEnvelope, "UTF-8");
// ----------------------------------------------------------------
post.setEntity(contentEntity);
if (requestEnvelope.contains(SOAP_1_1_NAMESPACE)) {
soapAction = soapAction != null ? "\"" + soapAction + "\"" : "";
post.addHeader(PROP_SOAP_ACTION_11, soapAction);
post.addHeader(PROP_CONTENT_TYPE, MIMETYPE_TEXT_XML);
client.getParams().setParameter(PROP_CONTENT_TYPE, MIMETYPE_TEXT_XML);
} else if (requestEnvelope.contains(SOAP_1_2_NAMESPACE)) {
String contentType = MIMETYPE_APPLICATION_XML;
if (soapAction != null) {
contentType = contentType + PROP_DELIMITER + PROP_SOAP_ACTION_12 + "\"" + soapAction + "\"";
}
post.addHeader(PROP_CONTENT_TYPE, contentType);
}
return post;
} catch (UnsupportedEncodingException ex) {
throw new SoapClientException(ex);
}
}
The SoapClient class is using the StringEntity constructor without a defined characterset, if you now want to send some UTF-8 characters the post execute will fail with the error message UnsupportedEncodingException. This is why the default is set to an ISO-characterset, if no characterset is defined. So I suggest to use the UTF-8 character set as a default in your code to avoid UnsupportedEncodingExceptions especially when your SoapRequest contains some special characters like in german language (p.e. ÄÜÖäüö).