Dynamic WCF base addresses in SharePoint

Posted by Paul Bevis on Stack Overflow See other posts from Stack Overflow or by Paul Bevis
Published on 2010-04-19T09:57:52Z Indexed on 2010/04/20 6:13 UTC
Read the original article Hit count: 227

Filed under:
|

I'm attempting to host a WCF service in SharePoint. I have configured the service to be compatible with ASP.NET to allow me access to HttpContext and session information

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class MISDataService : IMISDataService { ... }

And my configuration looks like this

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
        <service name="MISDataService">
            <endpoint address="" binding="webHttpBinding" contract="MISDataViews.IMISDataService" />
        </service>
    </services>        
</system.serviceModel>

Whilst this gives me access to the current HTTP context, the serivce is always hosted under the root domain, i.e. http://www.mydomain.com/_layouts/MISDataService.svc.

In SharePoint the URL being accessed gives you specific context information about the current site via the SPContext class. So with the service hosted in a virtual directory, I would like it to be available on mulitple addresses e.g.

http://www.mydomain.com/_layouts/MISDataService.svc
http://www.mydomain.com/sites/site1/_layouts/MISDataService.svc
http://www.mydomain.com/sites/site2/_layouts/MISDataService.svc

so that the service can figure out what data to return based upon the current context.

Is it possible to configure the endpoint address dynamically? Or is the only alternative to host the service in one location and then pass the "context" to it some how?

© Stack Overflow or respective owner

Related posts about wcf

Related posts about sharepoint