I don't think this kind of behavior is really supported since it (in my opinion) violates the SOAP protocol. The standard way to handle this would be sending a SOAP fault for your use case.
If a SOAP fault is really no option you could maybe try to trick the application server with an invalid SOAP response.
== Here be dragons! ==
You could e.g. try to add a SOAPHandler
(for brevity i assume you know this concept and how to implement it) which constructs an invalid SOAP response:
public class DuplicateDetectingSOAPHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleMessage(SOAPMessageContext context) {
if (isDuplicate(context)) {
MessageFactory messageFactory;
try {
messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage message = messageFactory.createMessage();
// detaching the SOAPBody violates api and causes an error
message.getSOAPBody().detachNode();
context.setMessage(message);
} catch (SOAPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
return true;
}
private boolean isDuplicate(SOAPMessageContext context) {
// determine if message is duplicate
}
I tried this with the standard JDK webservice implementation and it caused your desired behavior. I don't know if this works on WebSphere too. Keep in mind that this triggers some kind of error in the webservice implementation itself and could lead to other side-effects.
To be clear: I don't think you should implement this kind of behavior at all and search for a different solution.
Maybe an empty SOAP response also serves your need:
SOAPMessage message = messageFactory.createMessage();
context.setMessage(message);
This results in an empty SOAP reponse:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body/>
</env:Envelope>