MultipleBaseAddressBasicHttpBindingServiceHostFactory or WebScriptServiceHostFactory for SharePoint 2010 Web Service?

When it comes to creating a new service running in SharePoint 2010, people usually use Sharepoint MultipleBaseAddressBasicHttpBindingServiceHostFactory .

However, I would like to use the standard .net / WCF WebScriptServiceHostFactory because it gives me JavaScript code by calling the service url with / js.

My class of service 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'm just wondering what are the real differences? What will SharePoint ServiceHostFactory give me?

+5
1

! , , , Reflector. , , , .

-: MultipleBaseAddressBasicHttpBindingServiceHostFactory MultipleBaseAddressBasicHttpBindingServiceHost; WebScriptServiceHostFactory WebScriptServiceHost.

System.ServiceModel.ServiceHost, . , , , .

, , . OnOpening().

WebScriptServiceHost :

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());
    }
}

, , endpoint.Behaviors.Add(new WebScriptEnablingBehavior());, URL (/js), .

, MultipleBaseAddressBasicHttpBindingServiceHost, ():

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

WebServiceHost.AddAutomaticWebHttpBindingEndpoints() this.CreateEndpoints() . , SharePoint .

ClientServiceHost.CreateServiceHost() - factory, ClientServiceHost , web.config microsoft.sharepoint.client/serverRuntime.

OnServiceHostOpeningInternal() OnServiceHostOpening(). web.config , , :

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

, . OnServiceHostOpening() :

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

, , .

! , . , WebScriptServiceHost .

, . , , WebScriptServiceHost . , , factory, Microsoft, , /js endpoint.Behaviors.Add(new WebScriptEnablingBehavior(). , , - . , , SP- factory, .

, .

+14

All Articles