NOTE : YOU WILL NOT BE ABLE TO CALL THIS FROM JAVASCRIPT.
1. using using System.ServiceModel.Web;
2. [WebGet] to operation contract
3. new endpoint behavior for webHttp
<endpointBehaviors>
<behavior name="xyz">
<webHttp/>
</behavior>
</endpointBehaviors>
if i write the name of the binding incorrectly, i get the following error :
Configuration binding extension 'system.serviceModel/bindings/webHttp' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
4. add new endpoint
<endpoint address="web" binding="webHttpBinding" behaviorConfiguration="xyz" contract="IService"></endpoint>
note that the address has been changed to "web"
this is to avoid the conflict :
A binding instance has already been associated to listen URI 'http://localhost:49706/WebSite2/Service.svc'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.
4. Call the service using the url ( you need to change the localhost portno)
http://localhost:49706/WebSite2/Service.svc/web/dowork
notice the address of the function : web/dowork
"web" is what we have given in the endpoint address
No comments:
Post a Comment