Dev Blog - Johan Danforth
I'm Johan Danforth and this is my dev blog - a mix of .NET, ASP.NET, Rest, Azure and some other random coding stuff.
-
[Interop] How to Apply the Basic Profile (Web Service practices)
Got this URL on a Microsoft seminar. Seems to contain some pretty good recommendations and best practices. Especially the chapter about "How to Apply the Basic Profile":
This chapter details some best practice recommendations. These recommendations explain how to use Microsoft® Visual Studio® .NET to create Web services and Web service clients that conform to the Basic Profile. Some recommendations are general guidelines while others apply to particular directives in the Basic Profile. If a recommendation does apply to particular directives, their numbers are listed in square brackets after the recommendation (for example, [R1120]).
The whole thingy is available as a pdf file too.
-
MVC in ASP.NET
I agree with Eric that the way the Model-View-Controller (MVC) pattern is described at the .NET architecture center is not really spot-on. I've always looked at the (typed) DataSets as the model.
Not that it matters much but it's fun to discuss common patterns like this :)
-
Unable to load DLL (oci.dll)
It's been written in several places, but lots of people still seem to get this error when deploying ASP.NET apps that use Oracle on win2k3. It's all about permission to the oracle client directories. Make sure Everyone or the ASPNET account got read and execute access to the oracle client directories, especially the bin dir and where you keep your tnsnames.ora file.
You may have to reboot the server to make it work properly. Sometimes it works straight off with a restart of the web app, but I've had to reboot the server once to make it work.
If you add the rights to the top "oracle" or "ora92" directory or similar, make sure the rights gets applied to the lower directories. Windows 2003 can be a bit tricky with that.
-
First snowfall of the season hits Stockholm
-
"What are the best practices for J2EE?"
I'm reading the comments-battle between IBM and Microsoft regarding the IBM WebSphere/J2EE versus Microsoft .NET "Productivity, Performance, Reliability and Manageability Analysis" performed by The Middleware Company not long ago. I have long experience from both large and small J2EE and .NET projects, and some of the comments from Microsoft are quite funny and I must say spot on. Like this one:
IBM comment: We believe that if J2EE development best practices had been used, the developer productivity would have exceeded that of Visual Studio.NET. The performance and manageability of the WebSphere J2EE application also would have exceeded the published numbers.
Microsoft comment: The tricky question here is what are the best practices for J2EE? In several cases, the WebSphere team was using best practices documented by Sun, and yet IBM claims that they were not best practices. This confusion is typical in the J2EE programming model, and is the source of a programmer productivity tax. One thing these studies have shown over and over again is that with J2EE, often times the huge number of architectural choices, with no clear guidance on the tradeoffs between them, leads to failed implementations and loss of productivity. This study and IBM’s response proves that even the J2EE vendors themselves do not agree on how to build a J2EE application. for example, use EJBs or no EJBs? Use stateless session beans or entity beans? Use JDO vs. entity beans? Use POJOs with embedded JDBC? Use a straight servlet architecture instead? Use a third party framework (eg. Struts) or not? The choices are complicated, and many customers find out late in the game they have made the wrong choice. A choice that works well in one application server, may not work well in another.
-
[Interop] Understanding the WS-I Test Tools
I gave the WS-I test tools a go last night, and it was a bit of a challenge to configure it to run properly... I'm sure someone out there has coded up a UI, but I've not found it yet.
Anyway, this page on the IBM webby provided some help, so together with the pdf documents shipped with the tools, I managed to monitor and analyze my web service.
-
Data Provider for Oracle - Microsoft Provider vs. Oracle Provider
-
Using the OracleHelper class
Last week I moved some Data Access Layer code from MSSQL to Oracle and I started out downloading the Oracle provider for .NET from OTN. I thought that OracleHelper would work well with the provider from Oracle, but it didn't. At least not the provider for Oracle 9.2.
So I went with the System.Data.OracleClient namespace instead and it works like a charm.
The OracleHelper that looks and works similar to the SqlHelper 2.0 class is available in the Nile 3.0 sample project from Microsoft.
-
[Java] Things I learn while I dig into JSR 168
The portlet API spec (JSR 168) is a piece of good work, but once you want to do something out of the ordinary with a portlet, it feels a bit...limited. Perhaps it depends on what portal engine you're using, but I'd like to share some stuff I've noticed with session variables.
A portlet sitting in one page needs to know on what portal page it is used - it needs to know the name of the portal page or the name of the navigation item / menu item the user clicked so that the portlet may show dynamic content based on that. If this is possible, I could use the same portlet instance on several portal pages.
I know, maybe portlets shouldn't be aware of where they are used, be it a mobile phone, digital TV-box or in a java portal, but I sure would like to get some more information out of the portal context.
My first thought was - the session object. I can extend the portal navigation or the portal frame (which is just a JSP page) and add code to it that sets the name of the current page or the menu item the user clicked in a session variable. Problem is that it seems impossible for a JSR 168 portlet to get to the Session object of the portal. Since the portal and the portlet are two separate web applications, this is maybe as it should be, but even so...
Then I had a quick look at the portal context object to see if I could add a property to the context from the portal framework, then read it from the portlet, but it seems impossible without changing some of the portal code that I'm not sure I want to (or can) do.
So, final option seems to be to store the name of the selected portal page in the database, using the username as key, then read it from the database in the portlet. Not the most effective solution, but I can't find any other way to do this.
-
ASP.ASP - good at generating a dynamic RSS feed
I did a few tests some weeks ago and coded some base classes and an HttpHander that generates an RSS feed depending on the URI of the get request. I ended up with an RssHandler that does:
1) listens on get requests for *.rss
2) parses the URI to see what kind of feed the requester wants to have (news.rss, 123.rss, whatever.rss)
3) gets the requested data from different data sources and builds up a rss object generated with the XSD Object Generator
4) Serializes the RSS object back to the user on the Response-stream.Using .NET to do this is really a walk in the park. Some of the code looks like this:
public class RssHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
//Gets som info about the requested data
string newsType = GetNewsType(Request);
//Build up the RSS object – consider caching
rss rssData = GetRss(newsType);
//set response content type to text/xml
Response.ContentType = "text/xml";
//Add namespace for my extension to the RSS
XmlSerializerNamespaces ns =
new XmlSerializerNamespaces();
ns.Add("ext", "http://company.com/myRssExtension");
//serialize via response stream back to browser
XmlSerializer serializer =
new XmlSerializer(typeof(rss));
serializer.Serialize(Response.OutputStream, rssData, ns);
}
private static rss GetRss(String newsType)
{
rss rssData = new rss();
rssData.version = "2.0";
//Add other stuff to rss object here
//things like author, all the items etc...
return rssData;
}
}
The rss object is automatically created from a sample rss XML file and a schema, therefore it is serialized into correct RSS XML. I modified the generated RSS types to support a few extensions I wanted to have, with their own namespace. To do this, add a Namespace="someNamespace" to the XmlElement attribute for each element that should have it.