JSON Web Service (WCF)
Hello,
As mentioned in my previous post I am currently creating a JSON Webservice (WCF REST)
You maybe wondering why JSON?
JSON will allow cross platform applications a method to communicate to the same business logic.
This means I can invoke the same calls with Android, WP7, WP8, IOS by sending a simple web request and parsing the response.
How I created my service
Specify Paths
The URI Template attribute allows you to specify the URL that will be required to invoke the service.
Example:
This states that to Access the method Login you must browse to /Login/ and provide a Username and Password. the {} indicate a required field.
Common Issues
Issue 1 - Returns XML not JSON
Check the Web Config has:
defaultOutgoingResponseFormat ="Json"

Issue 2 - Error When Deployed with Multiple Site Bindings
Check the Web Config has:
multipleSiteBindingsEnabled="true"
As mentioned in my previous post I am currently creating a JSON Webservice (WCF REST)
You maybe wondering why JSON?
JSON will allow cross platform applications a method to communicate to the same business logic.
This means I can invoke the same calls with Android, WP7, WP8, IOS by sending a simple web request and parsing the response.
How I created my service
- Open Visual Studio
- File new Project
- Online Templates
- WCF
- Select WCF Rest Service Template 40 (CS)
- Click OK and allow it to install
- Open Web.Config and make sure the Standard Endpoint has the following attribute:
defaultOutgoingResponseFormat ="Json" - Make sure the serviceHostingEnvironment has the following attribute:
multipleSiteBindingsEnabled="true" - Open Service1.cs and create your WebGet Methods
- Make sure all custom objects being returned have [DataContract] and [DataMember] tags.
Specify Paths
The URI Template attribute allows you to specify the URL that will be required to invoke the service.
Example:
[WebGet(UriTemplate = "/Login/{Username}/{Password}")]
public string Login(string Username, string Password)
{
return "TestToken";
}
This states that to Access the method Login you must browse to /Login/ and provide a Username and Password. the {} indicate a required field.
Common Issues
Issue 1 - Returns XML not JSON
Check the Web Config has:
defaultOutgoingResponseFormat ="Json"
Issue 2 - Error When Deployed with Multiple Site Bindings
Check the Web Config has:
multipleSiteBindingsEnabled="true"
