List of usage examples for javax.xml.soap SOAPBodyElement addTextNode
public SOAPElement addTextNode(String text) throws SOAPException;
From source file:test.integ.be.fedict.hsm.ws.WSS4JTest.java
@Test public void testSecurity() throws Exception { QName serviceName = new QName("http://www.example.com/test", "TestService"); Service service = Service.create(serviceName); QName portName = new QName("http://www.example.com/test", "TestPort"); String endpointAddress = this.baseURL + "test"; LOG.debug("endpoint address: " + endpointAddress); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); BindingProvider bindingProvider = (BindingProvider) dispatch; SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding(); List handlerChain = soapBinding.getHandlerChain(); handlerChain.add(new WSS4JTestSOAPHandler()); soapBinding.setHandlerChain(handlerChain); MessageFactory messageFactory = soapBinding.getMessageFactory(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPBody soapBody = soapMessage.getSOAPBody(); QName payloadName = new QName("http://www.example.com/test", "Payload", "prefix"); SOAPBodyElement soapBodyElement = soapBody.addBodyElement(payloadName); soapBodyElement.addTextNode("hello world"); SOAPMessage replyMessage = dispatch.invoke(soapMessage); }