Я хотел бы изменить исходящий запрос SOAP. Я хотел бы удалить 2 узла xml из тела конверта. Мне удалось настроить Interceptor и получить порожденное значение String сообщения, установленного в конечную точку.
Однако следующий код, похоже, не работает, поскольку исходящее сообщение не редактируется, как ожидалось. Есть ли у кого-нибудь код или идеи о том, как это сделать?
public class MyOutInterceptor extends AbstractSoapInterceptor {
public MyOutInterceptor() {
super(Phase.SEND);
}
public void handleMessage(SoapMessage message) throws Fault {
// Get message content for dirty editing...
StringWriter writer = new StringWriter();
CachedOutputStream cos = (CachedOutputStream)message.getContent(OutputStream.class);
InputStream inputStream = cos.getInputStream();
IOUtils.copy(inputStream, writer, "UTF-8");
String content = writer.toString();
// remove the substrings from envelope...
content = content.replace("<idJustification>0</idJustification>", "");
content = content.replace("<indicRdv>false</indicRdv>", "");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(content.getBytes(Charset.forName("UTF-8")));
message.setContent(OutputStream.class, outputStream);
}