Correctly set HTTP status code on SOAP 1.2 fault

SOAP v1.2 specifies that for SOAP Fault's with Code of "env:Sender" the
HTTP response status code should be 400 (rather than 500 for all other
faults). This commit changes both client and server-side to reflect
this.

Issue: SWS-868
This commit is contained in:
Arjen Poutsma
2014-04-23 11:37:41 +02:00
parent d43b880637
commit ded1efd456
22 changed files with 1033 additions and 192 deletions

View File

@@ -25,6 +25,8 @@ import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPConstants;
import com.sun.net.httpserver.HttpExchange;
@@ -174,4 +176,18 @@ public class HttpExchangeConnection extends AbstractReceiverConnection
}
}
@Override
public void setFaultCode(QName faultCode) throws IOException {
if (faultCode != null) {
if (SOAPConstants.SOAP_SENDER_FAULT.equals(faultCode)) {
responseStatusCode = HttpTransportConstants.STATUS_BAD_REQUEST;
}
else {
responseStatusCode = HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR;
}
}
else {
responseStatusCode = HttpTransportConstants.STATUS_OK;
}
}
}