コード例 #1
0
  /**
   * Read user setting with ProtocolConnection value.
   *
   * @param reader EwsServiceXmlReader
   * @return the protocol connection
   * @throws Exception the exception
   */
  protected static ProtocolConnection loadFromXml(EwsXmlReader reader) throws Exception {
    ProtocolConnection connection = new ProtocolConnection();

    do {
      reader.read();

      if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) {
        if (reader.getLocalName().equals(XmlElementNames.EncryptionMethod)) {
          connection.setEncryptionMethod(reader.readElementValue(String.class));
        } else if (reader.getLocalName().equals(XmlElementNames.Hostname)) {
          connection.setHostname(reader.readElementValue(String.class));
        } else if (reader.getLocalName().equals(XmlElementNames.Port)) {
          connection.setPort(reader.readElementValue(int.class));
        }
      }
    } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.ProtocolConnection));

    return connection;
  }
コード例 #2
0
  /**
   * * Read ServerVersionInfo SOAP header.
   *
   * @param reader EwsXmlReader.
   * @return ExchangeServerInfo ExchangeServerInfo object
   * @throws Exception the exception
   */
  private ExchangeServerInfo readServerVersionInfo(EwsXmlReader reader) throws Exception {
    ExchangeServerInfo serverInfo = new ExchangeServerInfo();
    do {
      reader.read();

      if (reader.isStartElement()) {
        if (reader.getLocalName().equals(XmlElementNames.MajorVersion)) {
          serverInfo.setMajorVersion(reader.readElementValue(Integer.class));
        } else if (reader.getLocalName().equals(XmlElementNames.MinorVersion)) {
          serverInfo.setMinorVersion(reader.readElementValue(Integer.class));
        } else if (reader.getLocalName().equals(XmlElementNames.MajorBuildNumber)) {
          serverInfo.setMajorBuildNumber(reader.readElementValue(Integer.class));
        } else if (reader.getLocalName().equals(XmlElementNames.MinorBuildNumber)) {
          serverInfo.setMinorBuildNumber(reader.readElementValue(Integer.class));
        } else if (reader.getLocalName().equals(XmlElementNames.Version)) {
          serverInfo.setVersionString(reader.readElementValue());
        }
      }
    } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.ServerVersionInfo));

    return serverInfo;
  }