How to properly format a SOAP message envelope using a custom SOAPHandler

后端 未结 3 669
花落未央
花落未央 2021-02-06 14:31

I have a class that implements the SOAPHandler interface. The handleMessage is defined as:

public boolean handleMessage(SOAPMessageContext context) {

  SOAPMes         


        
3条回答
  •  醉酒成梦
    2021-02-06 14:57

    Just posting my solution if someone is still wondering --

    Name name = soapenv.createName("Security", "sse", "URL");
    SOAPHeaderElement security = soapenv.getHeader().addHeaderElement(name);
    security.setMustUnderstand(true);
    SOAPElement usernameToken = security.addChildElement("UsernameToken", "sse");
    SOAPElement username = usernameToken.addChildElement("Username", "sse");
    username.addTextNode("TestUser");
    SOAPElement password = usernameToken.addChildElement("Password", "sse");
    password.addTextNode("TestPassword");
    

提交回复
热议问题