切换到宽版
  • 8457阅读
  • 1回复

[求助]JAVA连接EWS连接不上 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2013-12-26
请大神帮助我这只小菜鸟啊。。。。。先贴代码。。

public class EWSTest {

          static String _exchangeHost = "172.16.20.132";
          static String _userName = "sysadmin";
          static String _password = "password";
          static String _accountName = "sysadmin";
      static String _domain = "soab.cn";
      static String _email = _userName+"@"+_domain;
        /**
         * @param args
         */
        public static void main(String[] args) {
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                ExchangeCredentials credentials = new WebCredentials(_email, _password);
                service.setCredentials(credentials);
                try {
                        service.setUrl(new URI(_exchangeHost));
                        System.out.println(service.getServerInfo().getVersionString()+"  VersionString");
                        FindFoldersResults findResults = service.findFolders(WellKnownFolderName.Inbox, new FolderView(Integer.MAX_VALUE));
                        for (Folder folder : findResults.getFolders()){
                         System.out.println("Count======" + folder.getChildFolderCount());
                         System.out.println("Name=======" + folder.getDisplayName());
                         System.out.println("Id=======" + folder.getId());
                        }
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }

}

  报错为:
        java.lang.NullPointerException
        at com.ideal.ext.EWSTest.main(EWSTest.java:45)

说的是service这个对象为空。我怎么判断我的service是否有连接上去啊。请大神们帮忙。。。。感激不尽。


分享到
只看该作者 1楼  发表于: 2014-11-10
我现在也是遇到这个问题,不知道楼主现在解决了没有。求回复
快速回复
限60 字节
 
上一个 下一个