Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Connection not established through Exchange Web Services

$
0
0

I know I am using abandoned API, but the same code worked with one exchange server but failed with other. I am usingJava EWS API. Though Java API I believe its functionality is very similar to .NET equivalent and looking out to exceptions thrown one can pin point whats wrong with my second exchange server.\

So below is the code to obtain instance of ExchangeService and send mail using it. It worked fine with one exchange server but failed with other.

ExchangeService service = new ExchangeService(		ExchangeVersion.Exchange2010_SP2);
ExchangeCredentials credentials = new WebCredentials("uname@domain.com", "password@123");
service.setCredentials(credentials);
service.setPreAuthenticate(true);
service.setUrl(new URI("https://excngevr.domain1.com/EWS/exchange.asmx"));
EmailMessage message = new EmailMessage(service);
message.getToRecipients().add("uname@domain.com");
message.setSubject("JAVA Test Subject update");
message.setBody(MessageBody.getMessageBodyFromText("JAVA Test Body  >>>>>>>>>>>>"));
EmailAddress emailAddress = new EmailAddress("uname@domain.com");
message.setSender(emailAddress);
message.send();
System.out.println("Mail sent");

The exception that is thrown is:

Nov 19, 2013 1:00:29 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: NTLM authentication scheme selected
Exception in thread "main" microsoft.exchange.webservices.data.EWSHttpException: Connection not established
	at microsoft.exchange.webservices.data.HttpClientWebRequest.throwIfConnIsNull(Unknown Source)
	at microsoft.exchange.webservices.data.HttpClientWebRequest.getResponseHeaders(Unknown Source)
	at microsoft.exchange.webservices.data.ExchangeServiceBase.processHttpResponseHeaders(Unknown Source)
	at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(Unknown Source)
	at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(Unknown Source)
	at microsoft.exchange.webservices.data.ExchangeService.internalCreateItems(Unknown Source)
	at microsoft.exchange.webservices.data.ExchangeService.createItem(Unknown Source)
	at microsoft.exchange.webservices.data.Item.internalCreate(Unknown Source)
	at microsoft.exchange.webservices.data.EmailMessage.internalSend(Unknown Source)
	at microsoft.exchange.webservices.data.EmailMessage.send(Unknown Source)
	at TestEws.main(TestEws.java:60)

That line 60 in TestEws.java is line

message.send();



Viewing all articles
Browse latest Browse all 7132

Trending Articles