I used the following C # code from Microsoft to request an EWS 2010 MSDN link and it worked. I need the same solution for Android.
I tried using the following code, but this does not help
DefaultHttpClient client = new HttpsClient( MyActivity.this); requestBytes = myXMLStringRequest.getBytes("UTF-8"); HttpPost httpPost = new HttpPost(url); httpPost.setHeader("Content-Type", "text/xml;utf-8"); if (requestBytes != null) { httpPost.setHeader("Content-length", String.valueOf(requestBytes.length)); Log.d(TAG, "content length: " + requestBytes.length); } client.getCredentialsProvider().setCredentials( new AuthScope(url, 443), new UsernamePasswordCredentials(userName, password)); Log.d(TAG, "Begin request"); HttpResponse response = client.execute(httpPost); Log.d(TAG, "status Line: " + response.getStatusLine().toString());
Here is my xml request
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <soap:Body> <GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <FolderShape> <t:BaseShape>Default</t:BaseShape> </FolderShape> <FolderIds> <t:DistinguishedFolderId Id="inbox"/> <t:DistinguishedFolderId Id="deleteditems"/> </FolderIds> </GetFolder>
I also use custom HttpsClient with keystore.
public class HttpsClient extends DefaultHttpClient { private final Context context; public HttpsClient(final Context context) { super(); this.context = context; } @Override protected ClientConnectionManager createClientConnectionManager() { final SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 8080));
}
But it always shows "connection timeout" and does not respond
Please tell me where is my problem? Any example is help. Thanks in advance!
source share