I'm creating a webservice with a wsHttp and JSON endpoint. The config below is hosted in a website project and works fine except when I try to create a service reference WITHIN the website. The endpoint behaviour seem to cause the error:
"Extension Error 'webHttp' cannot be added to this element. Verify the exception is registered in the extension collection at system.servicemode/extensions/behaviorExtensions"
It doesn't throw an error in svcUtil.exe. It seems VS specific but I'd like to get the bottom of it.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="JSON">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="HelloWorldBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="HelloWorldBehavior" name="HelloWorld">
<endpoint address="/json" behaviorConfiguration="JSON"
binding="webHttpBinding" contract="IHelloWorld" >
</endpoint>
<endpoint name="wcf" address="" binding="wsHttpBinding"
contract="IHelloWorld" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
I don't know whether it would solve your problem or not, but I think I should share my experience on a similar problem here.
I was getting an almost similar error:
Extension element 'webHttp' cannot be added to this element. Verify that the extension is registered in the extension collection at system.servicemodel/extensions/behaviorExtensions.

I tried a lot of things to fix this thing but couldn't do it. Then I found this suggestion on a similar problem from this page:
check your client (ASP.NET MVC) config and comment the WCF endpoint behavior which uses
<enableWebScript />. Then add your service reference and uncomment the behavior. Same procedure has to be done if you want to update existing script reference. I guess it is a bug and should be reported to Microsoft Connect.
Mine wasn't ASP.NET MVC, but I tried the suggestion by commenting out
<behavior name="web">
<webHttp />
</behavior>
this portion from my app.config and could add the service reference then!! Then after adding the reference I just uncommented that portion again.
I can't explain it. It just worked for me and that's why I am sharing. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With