Saturday, 10 November 2007

.NET and Java Integration

Here are the things you need to watch out when trying to integrate web services via HTTPS (.NET as the client)
  • Certificate trust issue
    DOT NET client needs to trust the certificate by adding this class which accepts all certificates. public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy {
    public TrustAllCertificatePolicy() {}
    public bool CheckValidationResult(ServicePoint sp, X509Certificate cert,WebRequest req, int problem) {
    return true;
    }
    }
    To use this CertificatePolicy?, tell the ServicePointManager? to use it before making a call to the webservice: System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
    Refer to: http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx
  • Expect 100-Continue issue
    I spent a significant amount of time trying to solve this issue! I finally ended up using tcpmon, an open source Java utility to monitor and capture data through TCP connection. Apparently, the problem is quite prevalent because some web servers do not implement this properly. We are hosting web services in our server in the office using Apache Tomcat, and the web service client is written in .NET framework. Both systems talk to each other using SOAP requests via the web. .NET client by default sends the header without the form data. The web server should respond with 100 (continue). Not all webservers handle this correctly, and to avoid this problem, the Expect100Continue flag needs to be set to false. Before making a call to the webservice, add this code: System.Net.ServicePointManager.Expect100Continue = false;
    Refer to: http://haacked.com/archive/2004/05/15/449.aspx
  • Arrays
    Coming up..
blog comments powered by Disqus