请大神帮助我这只小菜鸟啊。。。。。先贴代码。。
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是否有连接上去啊。请大神们帮忙。。。。感激不尽。