Ok. Finally I found a solution by myself after talking with my friend. :D. So let's look at how to send a Complex type
over WCF REST Web Service.
So let's think that there is a Interface class which contain MakeComplain and this method take a complain object as a parameter. and it's return a boolean value to ensure that the object received.
public interface IComplainService
[WebInvoke(Method = "POST", RequestFormat= WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json)]
bool MakeCompalin(Complain comp);
So, Let's look at the Implementation of the Interface class. In hear we check whether the object is received.
public class ComplainService : IComplainService
public bool MakeCompalin(Complain comp)
if (comp != null)
I hope everyone knows how to do the configuration part in web.config file. I think i don't want to mention it hear. ;)
Now Let's create a Client Project to test the Service. I have created a console application to test the service.
static void Main(string args)
Complain complain = new Complain()
CompainType = "type1",
CompainBody = "Body1"
string output = serializer.Serialize(complain);
string strUri = "http://localhost:6595/ComplainService.svc/MakeCompalin";
Uri uri = new Uri(strUri);
WebRequest request = WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
string serOut = jsonSerializer.Serialize(complain);
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
WebResponse responce = request.GetResponse();
Stream reader = responce.GetResponseStream();
StreamReader sReader = new StreamReader(reader);
string outResult = sReader.ReadToEnd();
So that's all :D
this may not be the ideal method to do this. If there are any other methods. Please do share with us... ;)