.NET has supported extension methods since version 2.0, though in 2.0 they were pretty clunky. This post explains .NET extension methods starting with framework version 3.5. Continue reading
On a recent .NET project I had to hook up with a web service that used non-standard headers in the request. After struggling with the configuration settings and the sparse Windows Communication Foundation (WCF) documentation for creating custom headers, I finally decided to skip WCF altogether and create the request as straight XML and manually process the XML in the response. It turned out to be easy (and straightforward), but I had a little trouble processing the returned XML using LINQ. The problem? The return XML had namespaces, which is common enough in the real world, but the .NET documentation and various blog posts showing how to process XML with LINQ don’t give much attention to namespaces. Continue reading
This is a companion article to Reading XML with Namespaces using LINQ, which explains how to parse XML with namespaces. Both articles came about because I had to use a web service that had non-standard envelope headers, and after struggling with the configuration settings and the sparse Windows Communication Foundation (WCF) documentation for creating custom headers, I finally threw it in and called the service by brute force – assembling the HTTP and XML requests, calling the service, and parsing the returned XML response.
I want to stress that WCF is excellent for communicating with a web service that more or less uses SOAP standards. If that’s your situation, stop reading right now and use WCF. But if you run into trouble with non-standard services I think it’s easier to put WCF aside and work directly with the service. At the very least, it’s a lot more straightforward. Continue reading