We can configure WCF services with Multiple EndPoints. To return Json, the following steps are needed: (1) Change OperationContract using WebGet, Json and UriTemplate --- note that input can only be string [WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate="Data/{value}")] [OperationContract] ListGetData(string value); (2) App.Config ==> Edit WCF config ==> Add webHttpBinding with Binding Behavior wedHttp <services> <service name="WcfServiceLibrary1.Service1"> ... <endpoint address="jsonTest" behaviorConfiguration="NewBehavior0" binding="webHttpBinding" bindingConfiguration="" contract="WcfServiceLibrary1.IService1" /> ... <behaviors> <endpointBehaviors> <behavior name="NewBehavior0"> <webHttp /> </behavior> </endpointBehaviors> (3) Publish to AppFabric Site/App considering the following details: (3.1) Make sure WebDeploy (MSDeploy,VS2010SP1) update installed so that AppFabric has deploy menu and VS2010 WCF App has Package/publish tab (3.2) Note that We are using WCF Lib not app so publish to AppFabric rather than using package. (3.3) Edit binding to default WebSite to have net.tcp binding infor 808:* and net.pipe etc and create an App "mb" with "http,net.tcp,net.pipe" as enabled protocols. (3.4) Browse the app to get base address like http://localhost/mb/WcfServiceLibrary1.Service1.svc test http://[baseAddress]/jsonTest/Data/0 should get to Json Data (save to disk) (3.5) make sure net.tcp port and address match 808:* and uses App "mb" and use a WPF client to add Service Reference for testing. and we should see client config has all protocols.
Sunday, June 3, 2012
AppFabric 1.1 host WCF multi-binding and Json Data
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment