PDA

View Full Version : Httphandler & Virtual Directory



namxam
12-04-2007, 10:14 AM
Well, now that I finally got the host.service running, I had to realize that what I really needed was the HttpHandler. Bad luck, but at least I will know it for the future ;) Or does anyone knows a way how to get run the service on the same port as IIS (80) without interfering?

The problem I am facing is that the site is access directly and through a proxy. Unfortunately, this proxy only accesses pages on this very server on port 80. So the solution I am thinking about is using the HttpHandler and provide the service functionality in a VirtualDirectory.

So far I got Dream running without any error messages - until I try to actually access a service. No matter what service I try, the log states, that the feature could not be found. my config looks like:


<appSettings>
<add key="service-dir" value="C:\DreamServer" />
<add key="root-uri" value="http://localhost/services"/>
<add key="apikey" value="12345"/>
<add key="script" value="C:\DreamServer\startup.xml" />
</appSettings>


I tried several settings but did not really manage to get rid of the problem. So any ideas why this isn't working? I cannot even call the host service to check any configuration options.

namxam
12-06-2007, 03:01 PM
Ok, I am not sure if my solution really is the best one, or if I simply doing something wrong, but I could not figure out how to set the "host-path" for the DreamHost instance launched by the HttpHandler.
I checked the source and I thing it is simply a matter of adding one line to the source. It might be just a hack, but at least this way it is working for me ;)

I replaced the following code in mindtouch.core > http > httphandler.cs



XDoc config = new XDoc("config")
.Elem("service-dir", ConfigurationSettings.AppSettings["service-dir"])
.Elem("apikey", apikey);


with



XDoc config = new XDoc("config")
.Elem("service-dir", ConfigurationSettings.AppSettings["service-dir"])
.Elem("host-path", ConfigurationSettings.AppSettings["host-path"])
.Elem("apikey", apikey);


This way the "host-path" configuration is read from the webconfig appSettings section and passed onto the launched DreamHost process.

SteveB
12-18-2007, 07:23 AM
That's probably the easiest fix. I applied it locally as well. However, going forward, I think it would be better if the HttpHandler startup code would borrow from the console host and service host startup code paths. Both now rely on an external XML document that contains all relevant settings. This document could either be co-located with the dream.dll or be specified inside app settings.