Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That will set the username and password for Basic HTTP authentication. If you've tested it in SoapUI, I'm guessing the 'PasswordText' value you speak of is the 'WSS-Password Type' in the request details pane. That sets WSS security, not HTTP security.</p> <p>With JAX-WS in Java6 you need to attach a SOAPHandler to inject the WSS-Usertoken into the SOAP Header. There are plenty of bits and bobs about this round the net, but I couldn't find one single link to post, so here's some code instead to get you going...</p> <p>To add a handler you need something like:</p> <pre><code>final Binding binding = ((BindingProvider) servicePort).getBinding(); List&lt;Handler&gt; handlerList = binding.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList&lt;Handler&gt;(); handlerList.add(new SecurityHandler()); binding.setHandlerChain(handlerList); // &lt;- important! </code></pre> <p>Then the SecurityHandler class will do the deed. Handlers are general things and get called for both successful messages and for faults, but perhaps more importantly they get called in <em>both</em> message directions - for the outgoing request and then again for the incoming response. You only want to handle outgoing messages. So you'll need something like:</p> <pre><code>public final class SecurityHandler implements SOAPHandler&lt;SOAPMessageContext&gt; { ... @Override public boolean handleMessage(final SOAPMessageContext msgCtx) { // Indicator telling us which direction this message is going in final Boolean outInd = (Boolean) msgCtx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); // Handler must only add security headers to outbound messages if (outInd.booleanValue()) { try { // Get the SOAP Envelope final SOAPEnvelope envelope = msgCtx.getMessage().getSOAPPart().getEnvelope(); // Header may or may not exist yet SOAPHeader header = envelope.getHeader(); if (header == null) header = envelope.addHeader(); // Add WSS Usertoken Element Tree final SOAPElement security = header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); final SOAPElement userToken = security.addChildElement("UsernameToken", "wsse"); userToken.addChildElement("Username", "wsse").addTextNode("MyWSSUsername"); userToken.addChildElement("Password", "wsse").addTextNode("MyWSSPassword"); } catch (final Exception e) { LOG.error(e); return false; } } return true; } ... // Other required methods on interface need no guts } </code></pre> <p>I've made a few assumptions here, but hopefully it'll get you going!</p> <p>Kind regards.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload