- Install following
- JDK (1.5 or above)
- Apache Axis2 (I used Axis 1.4.1)
- Apache Ant
- Configure following environment variables
- JAVA_HOME
- AXIS2_HOME
- ANT_HOME
- Append following to PATH
- %JAVA_HOME%\bin;%AXIS2_HOME%\bin;%ANT_HOME%\bin
- Ensure that you can run the following commands from command line
- java
- wsdl2java
- ant
Sunday, March 28, 2010
Consuming Exchange Web Service from Java – Setup Environment
Thursday, March 25, 2010
Consuming Exchange Web Service from Java
I had to get the Exchange Web Service (Exchange Version: 2010) APIs consumed from a Java program. Here is a set of preconditions, that I had, to start working on this.
- Need to use Apache Axis2 web service stack, version 1.4
- Consume mail and calendar APIs from Java
I did some research on any existing work for the same. I couldn’t find anything specific for Axis2. However, I found this great wiki page from imap2exchange project, which explains how to do it from Metro. In this blog series, I am trying to put together the sequence of actions I had to do to get the proxy code working from Axis2.
To get the email from user’s inbox, I had to do the following sequence.
- Setup your development environment
- Customize the WSDL & Schema to get Axis2 generate the proxy
- Fix compilation issues of Axis2 generated proxy
- Remove some namespace attaching in the request to avoid EWS complaining about the request format
- Edit the schema to resolve bugs in Axis2, regenerate proxy code and fix compilation issues
Back to blogging
Title could be little confusing. When I say back to blogging, I wasn’t blogging so frequently earlier. So that is probably a partially correct sentence. What I want to say is, I am starting to blog again now. :)
Wednesday, October 7, 2009
LINQ / Lambda Examples : Aggregate collection
///////////////////////////////////////////////////////////////////////////////
//
// Copyright © Schakra Inc. 2009. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace Schakra.Samples.DotNet.Linq
{
///
/// Sample demonstrating aggregating content of a Collection.
///
public class LinqSample_02
{
public void AggregateRequestParameters()
{
// Generate Data.
Random random = new Random();
Listuids = new List ();
for (int i = 0; i < 10; i++)
{
uids.Add(random.Next(1, int.MaxValue));
}
// Had to use similar code snippet while working with Facebook APIs.
string uidString = uids.Aggregate(
string.Empty,
(s, uid) => string.Format("{0},{1}", s, uid.ToString())
// (s, uid) => s + "," + uid.ToString())
).Substring(1);
// Had to use similar code while working with OAuth signature creation.
SortedListoauthParams = new SortedList ();
// Append all parameters in sorted order.
string sigBaseString = oauthParams.Aggregate(
string.Empty,
(s, kvp) => string.Format(
"{0}&{1}={2}", s, UrlEncode(kvp.Key), UrlEncode(kvp.Value))
).Substring(1);
}
private static Regex hexCharsExp = new Regex("%.{2}", RegexOptions.Compiled);
// Custom encoding in upper case for OAuth String.
private static string UrlEncode(string input)
{
if (string.IsNullOrEmpty(input))
{
return input;
}
return hexCharsExp.Replace(
HttpUtility.UrlEncode(input), m => m.Value.ToUpper());
}
}
}
Tuesday, September 29, 2009
LINQ / Lambda Examples : Convert list of one type to another
///////////////////////////////////////////////////////////////////////////////
//
// Copyright © Schakra Inc. 2009. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
using System.Collections.Generic;
using System.Linq;
namespace Schakra.Samples.DotNet.Linq
{
public class LinqSample_01
{
ListOutlookContacts { get; set; }
public void ConvertListFromOneTypeToAnother()
{
ListwinLiveContacts =
OutlookContacts.ConvertAll(
contact => contact.ToWindowsLiveContact());
ListoutlookContacts =
winLiveContacts.ConvertAll(
contact => new OutlookContact()
{
Name = contact.DisplayName,
Phone = contact.MobilePhone
});
ListoutlookContacts2 =
(from contact in winLiveContacts
select new OutlookContact()
{
Name = contact.DisplayName,
Phone = contact.MobilePhone
}).ToList();
}
}
public class OutlookContact
{
public string Name { get; set; }
public string Phone { get; set; }
public WindowsLiveContact ToWindowsLiveContact()
{
return
new WindowsLiveContact()
{
DisplayName = this.Name,
MobilePhone = this.Phone
};
}
}
public class WindowsLiveContact
{
public string DisplayName { get; set; }
public string MobilePhone { get; set; }
}
}
Wednesday, July 22, 2009
BlackBerry File Explorer
As part of work, we had to generate code coverage report for the application on BlackBerry. We have used Cobertura for J2ME for generating the code coverage results. However, we had to develop a quick tool to transfer the coverage result file generated on the simulator to desktop. For this purpose, we have developed the file explorer / transfer tool for BlackBerry, which works on USB connection.
We would make this tool available tool for public download soon.
Sunday, July 12, 2009
Overriding ServerCertificateValidation
//using System.Net;
//using System.Security.Cryptography.X509Certificates;
//using System.Net.Security;
ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, X509Certificate certificate,
X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};