public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); servletContext = servletConfig.getServletContext(); try { SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance(); con = scf.createConnection(); } catch (Exception e) { logger.log(Level.SEVERE, "Unable to open a SOAPConnection", e); } InputStream in = servletContext.getResourceAsStream("/WEB-INF/address.properties"); if (in != null) { Properties props = new Properties(); try { props.load(in); to = props.getProperty("to"); data = props.getProperty("data"); } catch (IOException ex) { // Ignore } } }
public SecurityToken logon( String anEndpointReference, String aUserName, String aPassword, String anApplicationID) throws LogonManagerException, SOAPException, IOException { SecurityToken result; SOAPMessage message; SOAPConnection conn = null; try { result = null; String request = REQUEST_FORMAT.format( ((Object) (new Object[] {fURL, aUserName, aPassword, anEndpointReference}))); message = MessageFactory.newInstance() .createMessage(new MimeHeaders(), new ByteArrayInputStream(request.getBytes())); conn = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage response = conn.call(message, fURL); SOAPBody body = response.getSOAPBody(); if (body.hasFault()) throw new LogonManagerException(body.getFault()); result = new SecurityToken(); result.setSOAPBody(body); for (Iterator it = body.getChildElements(); it.hasNext(); fill(result, (Node) it.next())) ; return result; } finally { if (conn != null) conn.close(); } }