<Creating WCF RESTful Web Service>
- Create New WCF Service Application (remove default IService.cs and Service.svc)
- Add WCF RESTful nnnService (Add > New > WCF Service > rename it to xxxService)
- Create new XML file (or database set)
- Create Operation Contacts (WebGet or WebInvoke) in xxxIService.cs
- Implement IxxxService in xxxService.svc
- Add service EndPoint (to use webHtpbinding) in web.config
- Execute WCF RESTful xxxService: (right click on xxxService.svc and view in browser)
- Credit: http://dotnetmentors.com/wcf/how-to-create-wcf-restful-services.aspx
<Publishing RESTful service in IIS>
1. Prerequisites
# Install All WCF features in
NB. make sure you’ve activated WCF components from here. Or alternate and easy way is, go to control panel -> Turn Windows feature on or off -> and make sure you’ve all the options ticked as mentioned in below screenshot.
2. Procedure
# http://beyondrelational.com/modules/2/blogs/48/posts/10055/walkthrough-on-creating-wcf-40-service-and-hosting-in-iis-75.aspx
# (option) http://www.csharptutorial.in/38/csharp-net-how-to-publish-a-web-service-in-iis-using-visual-studio-2010
1) Open IIS
2) Right click on Sites and then click Add Web Site
3) Give any name of your choice as the site name.
– Site Name: RESTforPE
– Application Pool: .NET v4.5
– Bindings: http:*:4567
– Physical Path: C:\inetpub\wwwroot\RESTforPE
– Physical Path Credential: sysops
4) aspnet_regiis.exe /iru # Not sure if needed (it works without this)
5) Publishing the WCF Service in VS
– Web Deploy
– http://localhost:4567/Service1.srv
– Site/application: RESTforPE
– Destination URL: http://localhost:4567/Service1.srv
6) Browsing (set Enable) the service hosted in IIS
7) http://10.0.1.4:4567/PEService.svc/Loan/1000/5/1
#
# 5
# 1000
# 1
# 85.6074817884675
#
NB. If needed, give full R/W access to folder (C:\inetpub\wwwroot\RESTforPE)
Reference:
– http://beyondrelational.com/modules/2/blogs/48/posts/10055/walkthrough-on-creating-wcf-40-service-and-hosting-in-iis-75.aspx
– http://www.csharptutorial.in/38/csharp-net-how-to-publish-a-web-service-in-iis-using-visual-studio-2010(supplement)

[References]
– 5 simple steps to create your first RESTful service : http://www.topwcftutorials.net/2013/09/simple-steps-for-restful-service.html
– A Beginner’s Tutorial on Creating WCF REST Services: http://www.codeproject.com/Articles/571813/A-Beginners-Tutorial-on-Creating-WCF-REST-Services
– An Introduction to Entity Framework for Absolute Beginners: http://www.codeproject.com/Articles/363040/An-Introduction-to-Entity-Framework-for-Absolute-B
http://blog.naver.com/h2d2002/50151749177
[How to call RESTfull in C# from R]
library(XML)
library(RCurl)
url <- "http://10.0.1.4:4567/PEService.svc/Loan/1000/200/3" # Save the URL of the xml file in a variable xml.url <- url # Use the xmlTreePares-function to parse xml file directly from the web xmlfile <- xmlTreeParse(xml.url) # the xml file is now saved as an object you can easily work with in R: class(xmlfile) # Use the xmlRoot-function to access the top node xmltop = xmlRoot(xmlfile) # have a look at the XML-code of the first subnodes: print(xmltop)[1:2] # To extract the XML-values from the document, use xmlSApply: xml.extracted <- xmlSApply(xmltop, function(x) xmlSApply(x, xmlValue)) # Finally, get the data in a data-frame and have a look at the first rows and columns xml.df <- data.frame(t(xml.extracted),row.names=NULL) xml.df[1:1,1:4] # XML to Dataframe xml.valueonly.df <- xmlToDataFrame(url) xml.valueonly.df