Ejemplo n.º 1
0
  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();
    }
  }
Ejemplo n.º 2
0
 /**
  * Fault response case
  *
  * @throws Exception
  */
 public void testNonAnonymousFaultTo2() throws Exception {
   invokeAsync(
       createDispatchWithoutAddressing(),
       TestMessages.NON_ANONYMOUS_FAULT_TO_COMPLETE_FAULTY_MESSAGE,
       S11_NS,
       nonAnonAddress,
       action,
       endpointAddress,
       "testNonAnonymousReplyTo");
   // Lets see we get a response in 60 s
   SOAPMessage m =
       respMsgExchanger.exchange(null, TestMessages.CLIENT_MAX_TIMEOUT, TimeUnit.SECONDS);
   // System.out.println("****************************");
   // m.writeTo(System.out);
   // System.out.println("\n****************************");
   SOAPBody sb = m.getSOAPBody();
   assertTrue(sb.hasFault());
   SOAPFault fault = sb.getFault();
   assertEquals(fault.getFaultString(), "Negative numbers can't be added!");
 }