Tôi muốn sửa đổi Yêu cầu SOAP gửi đi. Tôi muốn xóa 2 nút xml ra khỏi cơ thể của phong bì. Tôi đã quản lý thiết lập Trình chặn và nhận giá trị Chuỗi được tạo của thông điệp được đặt thành điểm cuối.Làm thế nào để sửa đổi thông điệp XML thô của một yêu cầu CXF đi?
Tuy nhiên, mã sau dường như không hoạt động vì thư gửi đi không được chỉnh sửa như mong đợi. Có ai có một số mã hoặc ý tưởng về làm thế nào để làm điều này?
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);
}
Cảm ơn bạn đã nhập John. Các yếu tố khác liên quan đến câu hỏi đó có thể được tìm thấy ở đây: http://stackoverflow.com/questions/6906499/how-to-modify-the-generated-soap-request – kiwifrog