Thursday, October 29, 2009

Hosting WCF services in Partial Trust Environment of GoDaddy

When I tried to deploy my WCF web services in GoDaddy’s normal account, I got the below three errors:

  1. There is no build provider registered for the extension '.svc' error.
  2. This collection already contains an address with scheme http error
  3. WSHttpBinding would not work

Below are the resolutions:

1. There is no build provider registered for the extension '.svc' error.

Below error is thrown:

There is no build provider registered for the extension '.svc'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: There is no build provider registered for the extension '.svc'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

clip_image002

In the web.Config, make the below changes under <System.web> element:

clip_image004

<buildProviders>

<remove extension=".svc" />

<add extension=".svc" type="System.ServiceModel.Activation.ServiceBuildProvider,System.ServiceModel, Version=3.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089" />

</buildProviders>

2. This collection already contains an address with scheme http error

Below error is thrown:

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

Parameter name: item

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

Parameter name: item

Resolution:

clip_image006

<serviceHostingEnvironment>

<baseAddressPrefixFilters>

<add prefix="http://api.ajitsingh.net/ajit2/" />

</baseAddressPrefixFilters>

</serviceHostingEnvironment>

3. WSHttpBinding would not work

Change the binding to basicHttpBinding

Below error is thrown:

The WSHttpBinding with name WSHttpBinding failed validation because it contains a BindingElement with type System.ServiceModel.Channels.SymmetricSecurityBindingElement which is not supported in partial trust. Consider disabling the message security and reliable session options, using BasicHttpBinding, or hosting your application in a full-trust environment.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The WSHttpBinding with name WSHttpBinding failed validation because it contains a BindingElement with type System.ServiceModel.Channels.SymmetricSecurityBindingElement which is not supported in partial trust. Consider disabling the message security and reliable session options, using BasicHttpBinding, or hosting your application in a full-trust environment.

clip_image008

Change the binding to basicHttpBinding

clip_image010