ByteArrayInputStream inputStream = new ByteArrayInputStream(envStr.getBytes());
MessageFactory factory = new MessageFactoryImpl();
SOAPMessage soapMsg = factory.createMessage(null, inputStream);
String expected = DOMWriter.printNode(soapMsg.getSOAPPart().getEnvelope(), true);
WSSecurityAPI sec = new WSSecurityDispatcher();
try
{
sec.encodeMessage(configuration, soapMsg, null, "kermit", "thefrog");
sec.decodeMessage(configuration, soapMsg, null);
String actual = DOMWriter.printNode(soapMsg.getSOAPPart().getEnvelope(), true);
assertEquals(expected, actual);
}
finally
{
sec.cleanup();
}
}