コード例 #1
0
  public void quickLogon(String namespace, String uid, String pwd) {

    try {
      StringBuffer credentialXML = new StringBuffer();

      credentialXML.append("<credential>");
      credentialXML.append("<namespace>").append(namespace).append("</namespace>");
      credentialXML.append("<username>").append(uid).append("</username>");
      credentialXML.append("<password>").append(pwd).append("</password>");
      credentialXML.append("</credential>");

      String encodedCredentials = credentialXML.toString();
      XmlEncodedXML xmlCredentials = new XmlEncodedXML();
      xmlCredentials.set_value(encodedCredentials);

      this.cmService.logon(xmlCredentials, null);

      SOAPHeaderElement temp =
          ((Stub) this.cmService)
              .getResponseHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader");
      cmBiBusHeader =
          (BiBusHeader)
              temp.getValueAsType(
                  new QName("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader"));
      ((Stub) this.cmService)
          .setHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader", cmBiBusHeader);
      ((Stub) this.dispatcher)
          .setHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader", cmBiBusHeader);
      banonymous = false;
    } catch (Exception e) {
      System.out.println("Warning: Named authentication failed. Will try as anonymous.");
      banonymous = true;
    }
  }