Accessing Quantify database from service

Hi,
I am trying to connect to quantify database using the dlls from sample console application and also I am using same config file settings in web.config file.

I am getting Protocol exception at this line.
bool success = AvontusPrincipal.Login() //I have removed userid password here but I have p.

application framework is 4.7 which is compatible with quantify version.

why console app is able to connect why not same simple code cannot connect to quantify api from a web or web service.
please help.