IIS 6.0 does not serve aspx pages out of the box

I have used ASP.NET for quite some time. I have probably always been lucky that the infrastructure or deployment person always enabled aspx on IIS for me. I use a Windows XP with IIS 5 sometimes or Vista with IIS 7. They do serve aspx pages by default, on XP once the .NET framework is downloaded and installed, there is nothing else to tweak.

On Friday afternoon, I had to deploy to an IIS 6 box on windows 2003, to my surprise, it didn’t serve any of the aspx pages. Even a small Hello World project on an simple label. I missed the happy hour with my colleagues and went home completely puzzle. Why? ASP.NET was already available when Windows 2003 saw the light. To my surprise there was nothing on the event log.

The answer came a few hours later and after few Google queries:

IIS 6.0: ASP.NET Is Not Automatically Installed on Windows Server 2003

1. Open IIS Manager, expand the master server node (that is, the Servername node), and then select the Web service extensions node.
2. In the right pane of IIS Manager, right-click the extension that you want to enable. In this example, this is Active Server Pages.
3. Click to select the Allow check box.
Add a New Web Service Extension to IIS 6.0

To permit IIS to serve content that requires a specific ISAPI or CGI extension that is not already listed in the Web service extensions list, follow these steps:
1.Open IIS Manager, expand the master server node, and then select the Web service extensions node.
2.In the right pane of the IIS Manager, click Add a new Web service extension under Tasks.
3.In the Extension name box, type a friendly name for the extension that you want to add (for example, FrontPage Server Extensions).
4.In the Required files box, click Add, and then select the path and the name of the file that will handle requests for the specific extension. After you select the path and the file name, click OK.
5. If the extension must be enabled immediately, click to select the Set extension status to allowed check box.
6. Click OK to save your changes.

Hopefully Mono will run seamless  on Apache one of these days…

Oh Fiddler, how did I live without you?

This is one of the tools that once you get a good grab of it, you can’t let go…

Fiddler link here

For me it’s invaluable the information it gives me to debug my custom soap headers or my JSON streams.

One trick though, if you are hosting your services on a webserver on your own development box, use the machine name instead of localhost on your HTTP requests or Fiddler won’t intercept them.

Other than that the TextView/XML View is the perfect tool to see what you’re sending on your SOAP request:

Happy SOAP envelop debugging 😉

Client proxy stub generation nightmare. SVCUtil generates colliding types. Beware of the porttype name and your data types…

This is one of the things that drives us insane from time to time. You may call this a bug, a lazy developer encapsulating bad code on a code generation tool, or just bad luck, but I quite some hours on this issue.

We have Java services that need to be consumed from C# client proxies. We do have a contract first approach and have the types defined on schema files and the service contracts are defined on their corresponding wsdl 1.2 files.

We validated the wsdl and xsd files with Altova XmlSpy and did the code generation with the svcutil tool several times, as well as the Visual Studio 2008 Add a Service Reference Tool.

The code generation  goes on fine, but the project that contains the proxy classes does not build. There are conflicting type names under the same namespace.

This does not happen with the Java client proxy generation tools, the Java code builds fine.

Here’s part of the problematic wsdl:

<?xml version=”1.0″ encoding=”utf-8″?>
<wsdl:definitions xmlns:tns=”http://service.some.com/Driver/” xmlns:soap12=”http://schemas.xmlsoap.org/wsdl/soap12/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:comm=”schema” name=”Driver” targetNamespace=”http://service.some.com/Driver/” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>
<wsdl:types>
<xsd:schema targetNamespace=”http://service.some.com/Driver/”>
<xsd:import schemaLocation=”Schema.xsd” namespace=”schema” />
<xsd:element name=”UpdateDriver”>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driver” type=”comm:Driver” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverRelation” type=”xsd:int” />
<xsd:element minOccurs=”0″ maxOccurs=”unbounded” name=”claims” type=”comm:Claim” />
<xsd:element minOccurs=”0″ maxOccurs=”unbounded” name=”convictions” type=”comm:Conviction” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”AddDriverConviction”>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionDate” type=”xsd:date” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionType” type=”xsd:int” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”UpdateDriverConviction”>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionDate” type=”xsd:date” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionType” type=”xsd:int” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<wsdl:message name=”CreateDriverRequest”>
<wsdl:part name=”parameters” element=”tns:CreateDriver” />
</wsdl:message>
<wsdl:message name=”CreateDriverResponse”>
<wsdl:part name=”returnValue” element=”tns:CreateDriverResponse” />
</wsdl:message>
<wsdl:message name=”UpdateDriverRequest”>
<wsdl:part name=”parameters” element=”tns:UpdateDriver” />
</wsdl:message>
<wsdl:message name=”UpdateDriverResponse”>
<wsdl:part name=”returnValue” element=”tns:UpdateDriverResponse” />
</wsdl:message>

<wsdl:portType name=”Driver”>
<wsdl:operation name=”CreateDriver”>
<wsdl:input message=”tns:CreateDriverRequest” />
<wsdl:output message=”tns:CreateDriverResponse” />
</wsdl:operation>


</wsdl:portType>

<wsdl:binding name=”DriverSoapBinding” type=”tns:Driver“>
<soap12:binding transport=”http://schemas.xmlsoap.org/soap/http” />
<wsdl:operation name=”CreateDriver”>
<soap12:operation soapAction=”http://service.some.com/Driver/CreateDriver” />
<wsdl:input>
<soap12:body use=”literal” />
</wsdl:input>
<wsdl:output>
<soap12:body use=”literal” />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name=”UpdateDriver”>
<soap12:operation soapAction=”http://service.some.com/Driver/UpdateDriver” />
<wsdl:input>
<soap12:body use=”literal” />
</wsdl:input>
<wsdl:output>
<soap12:body use=”literal” />
</wsdl:output>
</wsdl:operation>

</wsdl:binding>
<wsdl:service name=”DriverService”>
<wsdl:port name=”DriverPort” binding=”tns:DriverSoapBinding”>
<soap12:address location=”http://www.example.org/” />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

and the schema file:

<?xml version=”1.0″ encoding=”utf-8″?>
<xsd:schema xmlns:this=”schema” targetNamespace=”schema” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>

<xsd:complexType name=”Driver”>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”person” type=”this:Person” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driveInNASince” type=”xsd:date” />
<xsd:element name=”driverLicence” type=”xsd:string” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”provinceOfLicence” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”graduateType” type=”xsd:int” />
<xsd:element name=”hasTrainingCertificate” type=”xsd:boolean” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”hasAutoInsuranceBefore” type=”xsd:boolean” />
<xsd:element name=”previousInsurer” type=”xsd:int” />
<xsd:element name=”previousPolicy” type=”xsd:string” />
</xsd:sequence>
</xsd:complexType>

</xsd:schema>

The generated code had a Driver Interface defined and a driver partial class defined.

After quite a few hours trying to figure out what was wrong (we changed the namespace names, the type names etc), a colleague pointed out the name of the port on the wsdl file.

Voilá!!!

On the service definition tag in the wsdl we put:

<wsdl:portType name=”DriverService“>
<wsdl:operation name=”CreateDriver”>
<wsdl:input message=”tns:CreateDriverRequest” />
<wsdl:output message=”tns:CreateDriverResponse” />
</wsdl:operation>

<wsdl:binding name=”DriverSoapBinding” type=”tns:DriverService“>


Now the interface is generated with the name DriverService and not Driver, so there is no collision with the data contract types, whew…

Happy development!!!

Blogger to stop FTP publishing…

Whatever was free once, is no longer free, after all, Google has to get money out of something else, other than ads…
I had used Blogger for a while, probably since their beginning when it was acquired by Google.
I never liked to host my blog on their servers though, and I still won’t. Hosting on my own account gives me the freedom of owning anything I post, whether it is a rant, an image or just random IT knowledge.
Blogger has cut down features little by little. First the labels on the blog, then the amount of available HTML/CSS themes, now the FTP publishing.
Bottom line, you either host with them or you’ll be eventually unable to use them.

I guess the conversion to WordPress is mandatory now. No more procrastination for me.

L.

PS. On the bright side, I’ll be able to close my gmail account, I never use it and it is full of spam. I won’t force the kind people who leave comments to have a Gmail account and I’ll have full control on my ramblings…and the infrastructure that supports it.

To nvarchar or to varchar in SQL Server to accept French text

I found one single character from the French language that its binary representation is not the same for Unicode and Windows-1252. The oe ligature. Let me rant about it…

create table test_table
(name1 varchar (1) ,
name2 nvarchar (1) )

insert test_table
values (‘œ’, ‘œ’)

select * from test_table

select ASCII(name1), ASCII(name2), Unicode(name1), unicode(name2) from test_table

select COL_LENGTH(‘test_table’,’name1′) as Length1, COL_LENGTH(‘test_table’,’name2′) as Length2 from test_table

select char(156), char(339)

drop table test_table

This character is used in the word “eggs” in French
‘des œufs’ means some eggs…

These first two sets of characters from the Latin alphabet have identical Unicode and Windows-1252 (ASCII) character code.
(Basic Latin)
http://en.wikipedia.org/wiki/Basic_Latin_Unicode_block
and
Latin-1:
http://en.wikipedia.org/wiki/Latin-1_Supplement_Unicode_block

Their binary representation is the same as they all fit in one single byte or octet.

However, the extended Latin characters do not have the same Windows-1252 (ASCII) code and Unicode code.
http://en.wikipedia.org/wiki/Latin_Extended-A_Unicode_block

From this character set, French only uses the oe ligature though.

French accents and ligatures and how to type them with the number pad:
a with grave accent
à ALT + 133 À ALT + 0192

a with circumflex
â ALT + 131 Â ALT + 0194

a with tréma
ä ALT + 132 Ä ALT + 142

a e ligature
æ ALT + 145 Æ ALT + 146

c with cedilla
ç ALT + 135 Ç ALT + 128

e with acute accent
é ALT + 130 É ALT + 144

e with grave accent
è ALT + 138 È ALT + 0200

e with circumflex
ê ALT + 136 Ê ALT + 0202

e with tréma
ë ALT + 137 Ë ALT + 0203

i with circumflex
î ALT + 140 Î ALT + 0206

i with tréma
ï ALT + 139 Ï ALT + 0207

o with circumflex
ô ALT + 147 Ô ALT + 0212

o e ligature
œ ALT + 0156 Œ ALT + 0140

u with grave accent
ù ALT + 151 Ù ALT + 0217

u with circumflex
û ALT + 150 Û ALT + 0219

u with tréma
ü ALT + 129 Ü ALT + 154

French quotation marks
« ALT + 174 » ALT + 175

Euro symbol
€ ALT + 0128

The Windows-1252 encoding can be seen here:
http://www.visibone.com/htmlref/char/webascii.htm

For more, see Joel on Software rant :-p

As most questions in technology, the answer is: it depends.

http://stackoverflow.com/questions/35366/varchar-vs-nvarchar-performance

Performance wise, varchar is more efficient, less memory space, 20% to 30% smaller indexes.
Most database drivers will interpret the incoming stream and convert to Windows-1252 encoding, if the server code page is Windows 1252.
If you use way too many characters in the extended Latin group, you have no choice but using nvarchar…if you deal with other languages that are not Romance Languages, you have no choice but nvarchar.

Cheers!

Java Initialization blocks…why should we ever use them?

Coming from a C# world I’m trying to get a grasp on the Java language, mostly for comparison purposes and to see if really the grass is greener on the other side of the fence.

What I like so far of the Java 1.6 that I see C# might benefit from:
1. The main one is cross platform portability. I wish Mono would have more support.
2. Enums are more complex, but I’m wondering if we ever really use that complexity…
3. Static imports, but do they really add to maintainability or make it worse?

What I find confusing in Java vs C#:

1. Checked exceptions: In Java, the exceptions that a method throws must be declared and are part of a method’s public interface. They were left out from C# on purpose. Here’s an interview made by Bruce Eckel (Thinking in C++) to Anders Hejlsberg (lead C# architect and Turbo Pascal creator, I should point out I wrote my first program in Turbo Pascal :-p)…
2. Initialization blocks, not the static ones that are similar to c# static constructors but instance initialization blocks…why would you ever use them? I’m still puzzled…

HTTP 1.1 caching directives for dummies and caching problems for old versions of Internet Explorer.

The reason why I published this link is because a coworker had a problem with viewing a PDF on IE6 when the cache was set to no-store over https.

The problem does not happen with Internet Explorer 7 or above or with FireFox, but the old IEs fail to retrieve the files when the cache directive is no-store or no-cache.

More of this on:

Internet Explorer file downloads over SSL do not work with the cache control headers

Unable to Open or Run Files if “Cache-Control: No Store” Header Set

and

Prevent caching when you download active documents over SSL

And another good reading on Caches on the web:

Caching Tutorial for Web Authors and Webmasters

The importance of schemas, where’s that XSD file?

I’m coming across more and more projects that make heavy use of xml for data integration or data exchange that lack of schema files.

First case:
My team was POC-ing the integration with a third party web service. I won’t mention names but this company is one of the main sources of collected data for rating. After a purchased subscription for monthly text files with data dumps we are also able to access their web service. This web service provides a restricted interface to the data available on the text files. The service call is an http request with some parameters passed via POST (I would say it looks REST-ful). There is no WSDL published and the service returns an XML.
The main problem here is that the documentation on the XML is a PDF, yes a PDF! that will give you examples of the XMLs obtained in the response. Yes, samples with real data and a data dictionary, for instance the Product Element means XYZ, the codeA element means DFG.
All that amount of documentation looks fancy for the untrained eye, and most business analysts look puzzle when we say the documentation is not complete… why? There is a 200 pages PDF there!!!
Yes, but is there a schema that will validate all possible combination of XML responses? No.
Will the service consumer be prepared for all possible combination of XML responses? with luck and a lot of trial and error…

From W3schools:

The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.

An XML Schema:

* defines elements that can appear in a document
* defines attributes that can appear in a document
* defines which elements are child elements
* defines the order of child elements
* defines the number of child elements
* defines whether an element is empty or can include text
* defines data types for elements and attributes
* defines default and fixed values for elements and attributes

Second case:
The second time this month I came across a similar xsd-less approach was in a data exchange project. The project consisted of extracting data from two databases, building a huge xml file and applying transformations to that file to comply with CSIO standards. The transformed XML would be consumed by several external applications.
After seeing a few of the initial xml files with with the data dumps I asked, where’s the schema definition? and the answer was, there is none… Apparently the the development of the transformation engine had been contracted to a third party company that had advised the tweaks to be made on the xml to be able to transform into an AL3 file. All by trial and error…

Third case:
This case was actually some years ago. I recall suffering the consequences of an xsd-less approach when I was in charge of uploading data batches into a database to power an online quoting tool.
The XML file was provided periodically by a third party company and registered the sale prices of pre-owned models produced by that manufacturer. The data exchange wasn’t fancy, they would send me the 2GB+ xml file by secured email.
I was in charge of parsing that DOM, transform it to a schema the online tool could consume, get the differential data and dump it (via a SQL Server DTS) into the database the online tool will be fed from.
As it was a .NET project I used XPathNavigator heavily to avoid loading all the DOM in memory with an XmlDocument, my machine at the time had 512 MB.
The first two attempts worked fine, but the subsequent data batches were not so straightforward. My XPath expressions kept failing. Why?
The differences were minimal, anyone that hasn’t parsed XML or deserialize XML will consider them nuances:
One child node was before another one while in the previous document they were in reverse order, one piece of data that was before in the text area of an xml element was now an attribute of the parent element . Some elements were null sometimes, while sometimes they were completely omitted from the file and the list goes on.
I learned the lesson the hard way, we told the other end, no, we need to agree upon a schema and if the file you sent us cannot be validated against the schema we won’t acknowledge the reception…
I still jitter when I see XML exchange without an XSD…but it seems to be a recurrent theme.