Good day,
public boolean handleMessage(SOAPMessageContext context) { SOAPMessage message = context.getMessage( ); ByteArrayOutputStream baos = new ByteArrayOutputStream( ); message.writeTo( baos ); System.out.println(baos.toString()); } From the above code, handleMessage() pass in a SOAPMessageContext, and I convert it to message, and then write to ByteArrayOutputStream.
Last step I print it out. For example, I get: <auditNo>577849</auditNo><userName>1159496maker1</userName>
I want to edit the output to become like <userName>1159496maker1</userName> only, means I will remove the auditNo element from this xml.
I can do it by using String replace method: baos.toString( ).replace()
But I think this is not a best practice, I think it should has some simple/best practice method that can control in SOAPMessage level.
Kindly advise.
No comments:
Post a Comment