Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 29, 2012 03:37 PM by mitja.GTI
Jul 28, 2012 08:23 PM|LINK
I have been having issues trying to get a rest service going, so I decided to generate a simple service to make sure everything was good.
I generated a new wcd service app use the template.
The only thing i have changed in the code is to remove the exceptions with
return new SampleItem();
and the WebInvoke to
[WebInvoke(UriTemplate = "", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
the get works fine, the post will not work!
I am using the sample body from the help page
}to this address http://localhost:53134/Service1/But i get a bad request Any suggestions?
Jul 29, 2012 09:11 AM|LINK
please take a look at
this thread and my
last post in it.
You can not use POST with GET. If you wish to use POST, then you have to use either client or server side code. Also testing it with WCFTestClient.exe will help you.
Jul 29, 2012 01:52 PM|LINK
I don't understand.
I just created a new service using the "WCF REST Service Template 40(CS) " extension.
I did not change ANY code in it at all. All i did was put a break point in the GetCollection(), and Create(SampleItem instance) function.
These are called from a get and a post.
I then ran the project
It came up in the browser, i then copied the url to restclient ( a firefox extension) and sent a get message to the url (http://localhost:56686/service1/)
It returned data, i then ran the help for the post function. and copied the xml request and pasted it into the restclient body. set it to post and sent it - bad request. Just to test i also ran the json data as well with the same result.
Jul 29, 2012 03:37 PM|LINK
WCF services are complicated for beginners and one must have advanced knowledge of various standards, protocols, ... to even start working with them and knowing how to debug an application is essential.
I'm not familliar with a Firefox extension you are using. One should know that by default WCF method accepts ONLY XML unless you set it to Json (then it accepts ONLY JSON).
If you'll write the client in C# (server side) then you must add a service reference and when you browse to
http://localhost:port/service1/ with metadata enabled you should see an example page of how to create a client.
I'm not sure what XML or Json you are posting and where you got them but without relavant code samples of your application or a debug log it's impossible to suggest a solution.
I really suggest you start learing from the beggining... Here's a Beginner's Guide to Windows Communication Foundation.