Note that there are some explanatory texts on larger screens.

plurals
  1. PORequest Exchange Web Services 2007/2010 with SOAP+XML over HTTPS in Android
    text
    copied!<p>I used the following C# code from Microsoft to request EWS 2010 <a href="http://msdn.microsoft.com/en-us/library/cc526065.aspx" rel="nofollow noreferrer">MSDN link</a> and it worked. I need the same solution for android. </p> <p>I tried to use the following code but it does not help</p> <pre><code> 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()); </code></pre> <p>Here is my xml request</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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"&gt; &lt;soap:Body&gt; &lt;GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"&gt; &lt;FolderShape&gt; &lt;t:BaseShape&gt;Default&lt;/t:BaseShape&gt; &lt;/FolderShape&gt; &lt;FolderIds&gt; &lt;t:DistinguishedFolderId Id="inbox"/&gt; &lt;t:DistinguishedFolderId Id="deleteditems"/&gt; &lt;/FolderIds&gt; &lt;/GetFolder&gt; </code></pre> <p> </p> <p>I also use custom HttpsClient with keystore.</p> <pre><code>public class HttpsClient extends DefaultHttpClient { private final Context context; public HttpsClient(final Context context) { super(); this.context = context; } /** * The method used to create client connection manager */ @Override protected ClientConnectionManager createClientConnectionManager() { final SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 8080)); // Register for port 443 our SSLSocketFactory with our keystore // to the ConnectionManager registry.register(new Scheme("https", newSslSocketFactory(), 8443)); return new SingleClientConnManager(getParams(), registry); } private SSLSocketFactory newSslSocketFactory() { try { // Get an instance of the Bouncy Castle KeyStore format final KeyStore trusted = KeyStore.getInstance("BKS"); // Get the raw resource, which contains the keystore with // your trusted certificates (root and any intermediate certs) final InputStream inputStream = context.getResources().openRawResource(R.raw.parkgroup_ws_client); try { // Initialize the keystore with the provided truste // certificates // Also provide the password of the keystore trusted.load(inputStream, "myKeyStorePassword".toCharArray()); } finally { inputStream.close(); } // Pass the keystore to the SSLSocketFactory. The factory is // responsible // for the verification of the server certificate. final SSLSocketFactory ssf = new SSLSocketFactory(trusted); // Hostname verification from certificate // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506 ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); return ssf; } catch (Exception e) { Log.e("MYTAG", e.getMessage()); throw new AssertionError(e); } } @Override protected HttpParams createHttpParams() { final HttpParams httpParams = super.createHttpParams(); httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1000); httpParams.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); return httpParams; } </code></pre> <p>}</p> <p>But it always show "<em>connect timeout</em>" and does not response anything <br>Please tell me where is my problem? Any example would be help. Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload