dev@saaj.java.net

HTTPS SOAPConnection.call

From: Murthy Antyakula <murthy.antyakula_at_outlook.com>
Date: Mon, 16 Feb 2015 17:55:27 -0800

Hi,
    Does SOAPConnection.call support https url ?
    

            MessageFactory msgFactory = MessageFactory.newInstance();

            SOAPMessage sMessage = msgFactory.createMessage();

            SOAPPart sPart = sMessage.getSOAPPart();

            SOAPEnvelope sEnvelope = sPart.getEnvelope();



            //Add Header Content

            SOAPHeader sHeader = sEnvelope.getHeader();



            //Security Elements

            SOAPHeaderElement security = sHeader.addHeaderElement(new
QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
"Security"));

            security.setMustUnderstand(true);

            security.addNamespaceDeclaration("wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");

            security.addNamespaceDeclaration("wsu",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");


            SOAPElement usernameToken =
security.addChildElement("UsernameToken", "wsse");

            SOAPElement username =
usernameToken.addChildElement("Username", "wsse");

            username.setValue("username".trim());



            SOAPElement password =
usernameToken.addChildElement("Password", "wsse");

            password.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");

            password.setValue("password".trim());


          
...
           Add Soap Body
          ...
            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();
            SOAPMessage soapResponse = soapConnection.call(sMessage, url);

            Above always results in below fault. What are the other security header elements i need to include?

          <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">

<env:Header/>

<env:Body>

    <env:Fault
xmlns:ns0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

    <faultcode>ns0:InvalidSecurityToken</faultcode>

    <faultstring>InvalidSecurityToken : The security token is not
valid.</faultstring>

    <faultactor></faultactor>

    </env:Fault>

</env:Body>



            

-Murthy.