Absente
asked on
Exchange Web Service API - Java
Hi I am triying to access exchange web service using java.
I have got trail excahn ge web service account from microsoft.
I am trying to acces the following code.
----------
java.security.Security.add Provider(n ew com.sun.net.ssl.internal.s sl.Provide r());
Security.addProvider(new com.sun.net.ssl.internal.s sl.Provide r());
System.setProperty(
"java.protocol.handler.pkg s",
"com.sun.net.ssl.internal. www.protocol");
try {
// TODO code application logic here
ExchangeService service = new ExchangeService();
// Provide credentials.
service.setCredentials(new WebCredentials("asdasd@asd asdl", "asdsa","HM.DM.AD"));
// Autodiscover EWS end point.
URI url = new URI("https://chsdasd802.outlook.com/owa/Exchange.asmx");
System.out.println(service .getReques tedServerV ersion());
ItemView view = new ItemView(50);
FindItemsResults<Item> findResults;
do {
findResults = service.findItems(WellKnow nFolderNam e.Inbox, view);
for (Item item : findResults.getItems()) {
// Do something with the item.
}
view.setOffset(view.getOff set() + 50);
} while (findResults.isMoreAvailab le());
} catch (Exception ex) {
ex.printStackTrace();
}
-----------
I got error.
microsoft.exchange.webserv ices.data. HttpErrorE xception: The remote server returned an error: (440)Login Timeout
at microsoft.exchange.webserv ices.data. ServiceReq uestBase.v alidateAnd EmitReques t(Unknown Source)
at microsoft.exchange.webserv ices.data. SimpleServ iceRequest Base.inter nalExecute (Unknown Source)
at microsoft.exchange.webserv ices.data. MultiRespo nseService Request.ex ecute(Unkn own Source)
at microsoft.exchange.webserv ices.data. ExchangeSe rvice.find Items(Unkn own Source)
at microsoft.exchange.webserv ices.data. ExchangeSe rvice.find Items(Unkn own Source)
at microsoft.exchange.webserv ices.data. ExchangeSe rvice.find Items(Unkn own Source)
at ewsdeneme.EWSDeneme.main(E WSDeneme.j ava:53)
-I think it is about ssl connection.
How can i solve this?
I have got trail excahn ge web service account from microsoft.
I am trying to acces the following code.
----------
java.security.Security.add
Security.addProvider(new com.sun.net.ssl.internal.s
System.setProperty(
"java.protocol.handler.pkg
"com.sun.net.ssl.internal.
try {
// TODO code application logic here
ExchangeService service = new ExchangeService();
// Provide credentials.
service.setCredentials(new
// Autodiscover EWS end point.
URI url = new URI("https://chsdasd802.outlook.com/owa/Exchange.asmx");
System.out.println(service
ItemView view = new ItemView(50);
FindItemsResults<Item> findResults;
do {
findResults = service.findItems(WellKnow
for (Item item : findResults.getItems()) {
// Do something with the item.
}
view.setOffset(view.getOff
} while (findResults.isMoreAvailab
} catch (Exception ex) {
ex.printStackTrace();
}
-----------
I got error.
microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at ewsdeneme.EWSDeneme.main(E
-I think it is about ssl connection.
How can i solve this?
Your URI is incorrect - try replacing /owa/ with /EWS/ . What you are encountering (the 440 login timeout) is the server's response when you try to get past the OWA login form without actually submitting the correct values.
ASKER
now I got this error.
org.apache.commons.httpcli ent.auth.A uthChallen geProcesso r selectAuthScheme
INFO: Basic authentication scheme selected
microsoft.exchange.webserv ices.data. ServiceRes ponseExcep tion: The request failed schema validation: The 'Id' attribute is invalid - The value 'sentitems' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:DistinguishedFolderIdNameType' - The Enumeration constraint failed.
at microsoft.exchange.webserv ices.data. ServiceReq uestBase.p rocessWebE xception(U nknown Source)
at microsoft.exchange.webserv ices.data. ServiceReq uestBase.v alidateAnd EmitReques t(Unknown Source)
at microsoft.exchange.webserv ices.data. SimpleServ iceRequest Base.inter nalExecute (Unknown Source)
at microsoft.exchange.webserv ices.data. MultiRespo nseService Request.ex ecute(Unkn own Source)
at microsoft.exchange.webserv ices.data. ExchangeSe rvice.find Items(Unkn own Source)
at microsoft.exchange.webserv ices.data. ExchangeSe rvice.find Items(Unkn own Source)
at microsoft.exchange.webserv ices.data. ExchangeSe rvice.find Items(Unkn own Source)
at ewsdeneme.EWSDeneme.main(E WSDeneme.j ava:57)
org.apache.commons.httpcli
INFO: Basic authentication scheme selected
microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at microsoft.exchange.webserv
at ewsdeneme.EWSDeneme.main(E
I don't see any code in your OP that accesses the sent items folder. Has it changed since?
ASKER
This it the Code
This it the Error
public static void main(String[] args) {
try {
ExchangeService service = new ExchangeService();
service.setCredentials(new WebCredentials("asdl@yasd.onmicrosoft.com", "1Ysnciiim2", "HM.DM.AD"));
WebCredentials webCredentials = new WebCredentials();
URI url = new URI("https://chtrt1p802.outlook.com/ews/Exchange.asmx");
service.setUrl(url);
System.out.println(service.getRequestedServerVersion());
ItemView view = new ItemView(50);
FindItemsResults<Item> findResults;
do {
findResults = service.findItems(WellKnownFolderName.SentItems, view);
for (Item item : findResults.getItems()) {
}
view.setOffset(view.getOffset() + 50);
} while (findResults.isMoreAvailable());
} catch (Exception ex) {
ex.printStackTrace();
}
}
This it the Error
Ara 14, 2011 5:34:41 PM org.apache.commons.httpclient.auth.A uthChallen geProcesso r selectAuthScheme
INFO: Basic authentication scheme selected
microsoft.exchange.webservices.data. ServiceRes ponseExcep tion: The request failed schema validation: The 'Id' attribute is invalid - The value 'sentitems' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:DistinguishedFolderIdNameType' - The Enumeration constraint failed.
at microsoft.exchange.webservices.data. ServiceReq uestBase.p rocessWebE xception(U nknown Source)
at microsoft.exchange.webservices.data. ServiceReq uestBase.v alidateAnd EmitReques t(Unknown Source)
at microsoft.exchange.webservices.data. SimpleServ iceRequest Base.inter nalExecute (Unknown Source)
at microsoft.exchange.webservices.data. MultiRespo nseService Request.ex ecute(Unkn own Source)
at microsoft.exchange.webservices.data. ExchangeSe rvice.find Items(Unkn own Source)
at microsoft.exchange.webservices.data. ExchangeSe rvice.find Items(Unkn own Source)
at microsoft.exchange.webservices.data. ExchangeSe rvice.find Items(Unkn own Source)
at ewsdeneme.EWSDeneme.main(EWSDeneme.j ava:39)
Hm. I've never used the Java API, but WellKnownFolderName.SentIt ems looks exactly like what you'd use in any other language, so I can only assume that it's correct. What happens if you use other folders, such as JunkEmail (should be something in there, no doubt)?
It's not impossible that the Java API is broken, too. I recently discovered a flaw in EWS replying to IPM.Post items in public folders. The EWS SDK guy acknowledged the flaw, but said it was unlikely to be fixed since I was apparently the only person that had ever tried it :-)
It's not impossible that the Java API is broken, too. I recently discovered a flaw in EWS replying to IPM.Post items in public folders. The EWS SDK guy acknowledged the flaw, but said it was unlikely to be fixed since I was apparently the only person that had ever tried it :-)
ASKER
I think it related to connection.
org.apache.commons.httpcli ent.auth.A uthChallen geProcesso r selectAuthScheme
INFO: Basic authentication scheme selected
microsoft.exchange.webserv ices.data. HttpErrorE xception: The remote server returned an error: (405)Method Not Allowed
I try to send mail. but I fail and i get same error.
org.apache.commons.httpcli ent.auth.A uthChallen geProcesso r selectAuthScheme
INFO: Basic authentication scheme selected
microsoft.exchange.webserv ices.data. HttpErrorE xception: The remote server returned an error: (405)Method Not Allowed
org.apache.commons.httpcli
INFO: Basic authentication scheme selected
microsoft.exchange.webserv
I try to send mail. but I fail and i get same error.
org.apache.commons.httpcli
INFO: Basic authentication scheme selected
microsoft.exchange.webserv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks LeeDerbyshire. My last problem wass weelknownfoldername.
I am in turkey.
I set to locate("English"). I solve. Thanks.
I am in turkey.
I set to locate("English"). I solve. Thanks.
ASKER
Thanks
ASKER