Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 974547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:27:11+00:00 2026-05-16T03:27:11+00:00

When it comes to creating a new Service running on SharePoint 2010, people seem

  • 0

When it comes to creating a new Service running on SharePoint 2010, people seem to usually use the Sharepoint MultipleBaseAddressBasicHttpBindingServiceHostFactory.

However, I would like to use the standard .net/WCF WebScriptServiceHostFactory instead because this gives me JavaScript code by calling the Service URL with /js.

My Service Class itself is still decorated with the required Attributes:

[BasicHttpBindingServiceMetadataExchangeEndpoint]
[AspNetCompatibilityRequirements(RequirementsMode =
         AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(Namespace = "http://mycompany/namespace")]
public class MyService : IMyServiceContract

The whole Service actually works fine, but I just wonder what the real differences are? What would the SharePoint ServiceHostFactory give me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:27:11+00:00Added an answer on May 16, 2026 at 3:27 am

    This is a great question! My curiosity finally got the better of me, and I started poking around in Reflector. It’s not the authoritative final answer, but I think you’ll be interested in what I learned.

    First off: MultipleBaseAddressBasicHttpBindingServiceHostFactory simply generates MultipleBaseAddressBasicHttpBindingServiceHost objects; WebScriptServiceHostFactory simply generates WebScriptServiceHost objects.

    Both hosts inherit System.ServiceModel.ServiceHost, so they have a healthy base of common ground. Lucky for us, this reduces the size of the code footprint we must inspect to get a fair comparison.

    Now, though there’s not much new code in each class, they quickly branch off in different directions. Take a look at the OnOpening() implementations.

    In WebScriptServiceHost we have:

    base.OnOpening();
    WebServiceHost.AddAutomaticWebHttpBindingEndpoints(
        this,
        base.ImplementedContracts,
        SR2.GetString(SR2.JsonWebScriptServiceHostOneServiceContract, base.ImplementedContracts.Count));
    foreach (ServiceEndpoint endpoint in base.Description.Endpoints)
    {
        if (endpoint.Binding != null &&
            endpoint.Binding.CreateBindingElements().Find<WebMessageEncodingBindingElement>() != null &&
            endpoint.Behaviors.Find<WebHttpBehavior>() == null)
        {
            endpoint.Behaviors.Add(new WebScriptEnablingBehavior());
        }
    }
    

    Unless I am mistaken, the line reading endpoint.Behaviors.Add(new WebScriptEnablingBehavior()); is responsible for the URL behavior (/js) you want.

    Now, in MultipleBaseAddressBasicHttpBindingServiceHost, we have (abbreviated):

    ClientServiceHost host = ClientServiceHost.CreateServiceHost();
    this.CreateEndpoints();
    base.OnOpening();
    host.OnServiceHostOpeningInternal(this);
    

    The differences between WebServiceHost.AddAutomaticWebHttpBindingEndpoints() and this.CreateEndpoints() were not abundantly clear to me. I got the impression that the SharePoint host contained more automatic configuration support for different authentication models.

    ClientServiceHost.CreateServiceHost() is a factory method that creates a ClientServiceHost object based on a type listed in the web.config section microsoft.sharepoint.client/serverRuntime.

    The OnServiceHostOpeningInternal() method simply forwards the call to the host’s OnServiceHostOpening() method. Looking at the web.config of a default install, we find the assembly qualified name for the service host type, from which we can inspect the method:

    <serverRuntime>
      <hostTypes>
        <add type="Microsoft.SharePoint.Client.SPClientServiceHost, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      </hostTypes>
    </serverRuntime>
    

    Here’s where it gets interesting. The OnServiceHostOpening() method looks like this:

    [SharePointPermission(SecurityAction.Demand, ObjectModel=true)]
    protected override void OnServiceHostOpening(ServiceHost serviceHost)
    {
        if (serviceHost != null)
        {
            SPUtility.ConfigServiceHostIfClaimsAuth(serviceHost);
        }
    }
    

    Drilling in further, we see a metric boatload of logic surrounding configuring a host for claims-based authentication.

    Aha! There is a difference worth noting. Unless I’m mistaken, there’s no claims-based authentication support in WebScriptServiceHost.

    Conclusion

    Perhaps you are not using claims-based authentication. If so, you might find that using WebScriptServiceHost is fine. However, were it me writing the service, I’d create a new host and host factory inheriting the Microsoft types, and see if I could create the /js extension by using endpoint.Behaviors.Add(new WebScriptEnablingBehavior(). The worst thing that could happen is that it wouldn’t work. On the other hand, if it does work, you could expect to have a highly-SP-compatible service host factory that supports your endpoint preferences.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a new web app/service, one of the features of this service
I'm creating a new website in Visual Studio 2010 Ultimate / vb and I
When it comes to creating stored procedures, views, functions, etc., is it better to
I see several programmers, including Apple, creating codes where they declare stuff like this:
I'm creating a user form that requires the functionality for people to come back
I'm pretty new to sharepoint-development, so I thought I'd check real quick with the
I´ve unpacked a WSP package creating a new Project in Visual Studio with the
I'm preparing for performance tests and creating new test cases. So I was just
I am creating a net.tcp based WCF service to control one of our backend
Whilst writing a custom webpart for use in Sharepoint 2007 / WSS 3.0 I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.