Call call = (Call) service.createCall();
call.setTargetEndpointAddress(opts.getURL());
SOAPEnvelope env = new SOAPEnvelope();
Document doc = env.getAsDocument();
WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
// Create a new request object passing an XML document for element creation and the RequestType (in this case issue)
RequestSecurityToken tokenRequest = new RequestSecurityToken(doc, TrustConstants.REQUEST_ISSUE);
// Setting the context and the token type we want to be returned
tokenRequest.setContext(new URI("http://context.context"));
tokenRequest.setTokenType(TokenTypes.X509);
// Construct a bunch of username tokens to be used as <Base> and <Supporting> elements
UsernameToken userToken = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc);
userToken.setName("bob");
userToken.setPassword("bobspass");
tokenRequest.setBase(new SecurityTokenOrReference(userToken));
UsernameToken user2Token = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc);
user2Token.setName("joe");
user2Token.setPassword("bobspass");
tokenRequest.addSupporting(new SecurityTokenOrReference(user2Token));
UsernameToken user3Token = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc);
user3Token.setName("mike");
user3Token.setPassword("bobspass");
tokenRequest.addSupporting(new SecurityTokenOrReference(user3Token));
// Set the desired Lifetime of the token being requested in this case to 250 seconds