exchangewebservices - How to authenticate EWS Java API -


we using ews java api use outlook calendar on our java application. having authentication issues on ews.

i tried application on cloud outlook account that's supplied rackspace , worked fine know credentials accurate.

here code:

import java.net.uri; import java.net.urisyntaxexception; import microsoft.exchange.webservices.data.*;  public class testclass {      public static void main(string[] args) {         testclass obj = new testclass();         obj.testmethod();     }      public void testmethod() {         exchangeservice service = new exchangeservice(                 exchangeversion.exchange2007_sp1);         exchangecredentials credentials = new webcredentials("username",                 "password");          service.setcredentials(credentials);          try {             service.seturl(new uri("https://domain/ews/exchange.asmx"));         } catch (urisyntaxexception e) {             e.printstacktrace();         }          emailmessage msg;         try {             msg = new emailmessage(service);             msg.setsubject("hello world");             msg.setbody(messagebody                     .getmessagebodyfromtext("sent using ews api"));             msg.gettorecipients().add("test@test.com");             msg.send();         } catch (exception e) {             e.printstacktrace();         }      }  } 

the url rackspace is:https://connect.emailsrvr.com/ews/exchange.asmx when put username , password account , works, see console spitting out one:

apr 05, 2013 1:40:28 pm org.apache.commons.httpclient.auth.authchallengeprocessor selectauthscheme info: ntlm authentication scheme selected 

our client using exchangeversion.exchange2007_sp1 whereas rackspace using exchangeversion.exchange2010 when use credentials(username, password , url) our client provided, getting error:

apr 05, 2013 1:49:13 pm org.apache.commons.httpclient.auth.authchallengeprocessor selectauthscheme info: basic authentication scheme selected apr 05, 2013 1:49:13 pm org.apache.commons.httpclient.httpmethoddirector processauthenticationresponse severe: invalid challenge: basic org.apache.commons.httpclient.auth.malformedchallengeexception: invalid challenge: basic @ org.apache.commons.httpclient.auth.authchallengeparser.extractparams(authchallengeparser.java:98) @ org.apache.commons.httpclient.auth.rfc2617scheme.processchallenge(rfc2617scheme.java:94) @ org.apache.commons.httpclient.auth.basicscheme.processchallenge(basicscheme.java:112) @ org.apache.commons.httpclient.auth.authchallengeprocessor.processchallenge(authchallengeprocessor.java:162) @ org.apache.commons.httpclient.httpmethoddirector.processwwwauthchallenge(httpmethoddirector.java:694) @ org.apache.commons.httpclient.httpmethoddirector.processauthenticationresponse(httpmethoddirector.java:668) @ org.apache.commons.httpclient.httpmethoddirector.executemethod(httpmethoddirector.java:193) @ org.apache.commons.httpclient.httpclient.executemethod(httpclient.java:397) @ org.apache.commons.httpclient.httpclient.executemethod(httpclient.java:323) @ microsoft.exchange.webservices.data.httpclientwebrequest.executerequest(httpclientwebrequest.java:358) @ microsoft.exchange.webservices.data.servicerequestbase.getewshttpwebresponse(servicerequestbase.java:930) @ microsoft.exchange.webservices.data.servicerequestbase.validateandemitrequest(servicerequestbase.java:825) @ microsoft.exchange.webservices.data.simpleservicerequestbase.internalexecute(simpleservicerequestbase.java:46) @ microsoft.exchange.webservices.data.multiresponseservicerequest.execute(multiresponseservicerequest.java:144) @ microsoft.exchange.webservices.data.exchangeservice.internalcreateitems(exchangeservice.java:464) @ microsoft.exchange.webservices.data.exchangeservice.createitem(exchangeservice.java:535) @ microsoft.exchange.webservices.data.item.internalcreate(item.java:215) @ microsoft.exchange.webservices.data.emailmessage.internalsend(emailmessage.java:125) @ microsoft.exchange.webservices.data.emailmessage.send(emailmessage.java:253) @ com.aurora.trials.testclass.testmethod(testclass.java:43) @ com.aurora.trials.testclass.main(testclass.java:17)  microsoft.exchange.webservices.data.ewshttpexception: connection not established @ microsoft.exchange.webservices.data.httpclientwebrequest.throwifconnisnull(httpclientwebrequest.java:394) @ microsoft.exchange.webservices.data.httpclientwebrequest.getresponseheaders(httpclientwebrequest.java:280) @ microsoft.exchange.webservices.data.exchangeservicebase.processhttpresponseheaders(exchangeservicebase.java:1045) @ microsoft.exchange.webservices.data.simpleservicerequestbase.internalexecute(simpleservicerequestbase.java:58) @ microsoft.exchange.webservices.data.multiresponseservicerequest.execute(multiresponseservicerequest.java:144) @ microsoft.exchange.webservices.data.exchangeservice.internalcreateitems(exchangeservice.java:464) @ microsoft.exchange.webservices.data.exchangeservice.createitem(exchangeservice.java:535) @ microsoft.exchange.webservices.data.item.internalcreate(item.java:215) @ microsoft.exchange.webservices.data.emailmessage.internalsend(emailmessage.java:125) @ microsoft.exchange.webservices.data.emailmessage.send(emailmessage.java:253) @ com.aurora.trials.testclass.testmethod(testclass.java:43) @ com.aurora.trials.testclass.main(testclass.java:17) 

i couldn't find solution issue. please provide info think can authenticated ews. causing these exceptions?

i had exact same errors , wasted 5 hours trying fix it. conclusion should not waste more time on trying ews codebase work, ews code confused , you'll have go in under hood fix bugs in library.

i settled on using javax.mail implementation need. https://stackoverflow.com/a/18043717/445131


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -