WCF
====
IF YOU WANT TO CHANGE YOUR SERVICE TO JSON
YOU NEED TO FOLLOW BELOW STEPS
================================
YOU NEED TO ADD REFERENCE:using System.ServiceModel.Web;(C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5 go to this path if not found).
1) IN iSERVICE1
==============
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "listofcities")]
List<cities> listofcities();
UNDER SERVICE1
2) AT TOP
// NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in App.config.
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
======================================================================(ADD THIS ONE(********))
public class Service1 : IService1
{
3) IN HOST WEB.CONFIG
====================== (in 2010 vs you need to add one endpoint explicitely)
</serviceBehaviors>
=======================
<endpointBehaviors>
<behavior name="WEB">
<webHttp/>
</behavior>
</endpointBehaviors>
PUT THE NAME="WEB" IN ENDPOIN TAG
==================================
<endpoint address="" binding="webHttpBinding" contract="restarentlib.IService1" behaviorConfiguration="WEB">
====
IF YOU WANT TO CHANGE YOUR SERVICE TO JSON
YOU NEED TO FOLLOW BELOW STEPS
================================
YOU NEED TO ADD REFERENCE:using System.ServiceModel.Web;(C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5 go to this path if not found).
1) IN iSERVICE1
==============
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "listofcities")]
List<cities> listofcities();
UNDER SERVICE1
2) AT TOP
// NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in App.config.
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
======================================================================(ADD THIS ONE(********))
public class Service1 : IService1
{
3) IN HOST WEB.CONFIG
====================== (in 2010 vs you need to add one endpoint explicitely)
</serviceBehaviors>
=======================
<endpointBehaviors>
<behavior name="WEB">
<webHttp/>
</behavior>
</endpointBehaviors>
PUT THE NAME="WEB" IN ENDPOIN TAG
==================================
<endpoint address="" binding="webHttpBinding" contract="restarentlib.IService1" behaviorConfiguration="WEB">
No comments:
Post a Comment