Example usage for javax.xml.soap SOAPBodyElement addTextNode

List of usage examples for javax.xml.soap SOAPBodyElement addTextNode

Introduction

In this page you can find the example usage for javax.xml.soap SOAPBodyElement addTextNode.

Prototype

public SOAPElement addTextNode(String text) throws SOAPException;

Source Link

Document

Creates a new Text object initialized with the given String and adds it to this SOAPElement object.

Usage

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);
}