To begin with I have a WCF REST web service that intends for a Comment object to be POSTed:
[WebInvoke(UriTemplate = "comment", Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)] public Comment Comment(Comment comment) { return comment; }
The definition of Comment is simple:
[DataContract(Namespace = "")] public class Comment { [DataMember] public string Body { get; set; } }
Note this namespace is very important as it will need to be specified in the XML sent in the request. Personally I set my DataContract with no namespace to save having to write it out in the XML every time.
Now open up Fiddler and lets get testing:
Create a POST to your REST service in Fiddler
- Go to the Request Builder tab in Fiddler.
- Set the verb to POST
- Set the URL to the one of your service
- Type "Content-Type: application/xml" into the Request Headers. (This is the bit that got be stumped for hours)
- Add your XML to the Request Body like
<Comment><Body>colin</Body></Comment>
If you did give your DataContract a namespace other than blank as I did you will need to specify it in the XML of your Request Body. Such as:
<Comment xmlns="MyNameSpace"><Body>colin</Body></Comment>
Happy testing!
Thanks I did it . It works great
ReplyDeletewww.oniontest.org (EASY/SIMPLE) rest/http web service testing without mocking yourself to an imaginary world ! - Write an Onion !
ReplyDeleteThat's a great way to test our services, really. I was struggling with all the work it takes to mock up my services until I found your post. Thank you so much!
ReplyDeleteEven If you have blank namespace you have to put
ReplyDeletexmlns="" in the request body ...
http://pantestmb.blogspot.com/2011/10/pass-multiple-body-parameters-wcf-rest.html
Whithout xmlns="" in the request body , problems can appear
Thanks for the tip but I'll be honest, I have never found any problems myself nor have the iPhone developers that consumed this API.
ReplyDeleteWhat problems were you experiencing exactly? Just for my benefit in case I have missed something.
Hello, Thanks for the great tutorial. I tried to extend the class with inserting DateTime? variable in it as following:-
ReplyDelete[DataContract(Namespace = "")]
public class Comment
{
[DataMember]
public string BodyComment { get; set; }
[DataMember]
public DateTime? CreatedDate { get; set; }
}
And followed everything else as you mentioned in the tutorial.
But when I'm sending a POST request like this:
xyz, or
xyz
As I want CreatedDate to be empty, it is giving me "Http 400 Bad request error".
Kindly suggest if I'm doing something wrong.
Sorry POST didn't come, but it is like
DeleteI'm sending xyz in body and empty CreatedDate...
Bit hard to debug this kind of thing remotely. Where is the exception being thrown and what is it when you are debugging?
DeleteThank you so much. I have been trying to understand the WebInvoke attribute for a few days and your example made it clear.
ReplyDeleteThank you so much, this is exactly what I was looking for.
ReplyDeleteFantastic post, been knocking myself out working out why object was not posting correctly, the namespace did it.
ReplyDeleteWhy is my Fiddler meets "415 Unsupported Media Type"?
ReplyDeleteI do everything in your example...
This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.Contact Us Content
ReplyDeleteThanks for sharing a very helpful AND ALSO very informative blogPromotion King
ReplyDeleteOnline medium and audio visual media is undoubtedly the strongest medium these days with extensive reach to the audience.
ReplyDeletecreate your brand
With this, you ought to just trust your well deserved cash and speculation to an Ecommerce Web Development Company that brags a past filled with mastery and polished skill in the business.easy proven way to start a blog
ReplyDeleteHowever we do agree that there are a lot of differences in the way some of these web browsers operate and the various scripting and web coding languages they use and their interpretation of this.Kttp
ReplyDeleteIn the event that you don't yet have a website, the initial step is to record precisely why you need a website and what you need it to improve the situation your business. hybrid app development
ReplyDeleteI suggest that you look around and see what the various web hosting companies have to offer before you make that final choice. www.ldainteractive.com
ReplyDeleteHello, https://wordpresstemplates.ch/ - premium wordpress templates
ReplyDelete
ReplyDeleteThis is genuinely an awesome read for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
Web Development
Hey, great post! I also interested in Fiddler and I think you might like this article - vue vs react
ReplyDeleteThis is a front-end JavaScript library developed by Facebook. Most of the major applications are currently running on React.JS. The applications which required data changes constantly are using React.JS.
ReplyDeleteI found this as an informative and interesting post, so i think it is very useful and knowledgeable.- gta 5 cheats
ReplyDeletegreat tutorial! Read also React vs Vue.js.Which to Choose?
ReplyDelete
ReplyDeleteRespecting the time and exertion you put into your site and point by point data you offer!..
Web Development
This current Google's child should be in the best position of web structures.
ReplyDeleteGetting reliable SEO services has become a very tedious task now. Thank God that Canada's SEO Company is here to resolve our issues. Canada's SEO Company
ReplyDelete
ReplyDeletefifa 18 apk download full version for android for best apk game you can get here
ReplyDeleteKodi Apk is best site for kodi download
Micromax Flash Tool for best firmware you can get here
ReplyDeleteBreathtakingly beautiful use of words.
ReplyDeletesoftware development company in delhi
You ought to be a part of a contest for one of the finest sites on the internet. I will recommend this web site!
ReplyDeletefnaf world download
Web development is a specialized area of work which involves an understanding of the web development technologies and all other related processes. Web developers do not automatically produce a fine website on demand. small business web design Toronto
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIt is an excellent blog, I have ever seen. I found all the material on this blog utmost unique and well written. And, I have decided to visit it again and again. animal logo design
ReplyDeleteVery informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. Webdesign
ReplyDeleteThanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. Webdesign
ReplyDeleteI recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing. Webdesign
ReplyDeleteI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.. Webdesign
ReplyDeleteI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.. Webdesign
ReplyDeleteI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.. Webdesign
ReplyDeleteWebdesigner waar u een professionele en betaalbare website kan laten maken? De nr. 1 webdesigner in Limburg, Antwerpen en Vlaams-Brabant voor SEO websites. Webdesigner
ReplyDeleteThe challenge on independent occupation sheets is wild. How is somebody with no portfolio expected to emerge? Webdesign
ReplyDeleteI have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates. Webdesign bureau
ReplyDeleteHere are just a few of the very important web design and search engine optimization (SEO) elements seo services in gurugram haryana that website builders can't do for you:
ReplyDeleteRevdl Apk for best apps and games free download apk revdl
ReplyDeleteI would like to say that this blog really convinced me to do it! Thanks, very good post. dominio y página web
ReplyDeleteThere are a lot more online business stages like shopify, virtuemart, zeuscart, zencart and so on. Picking any of these awesome stages guarantees your website executes as required.
ReplyDeleteweb developer nuneaton
I am very happy to discover your post as it will become on top in my collection of favorite blogs to visit. freelance web designer
ReplyDeleteMy webpage has a few hints on the best way to perform site design improvement (additionally know as SEO) on your site. Webdesign
ReplyDeleteThank you so much Love your blog.. web design company
ReplyDeleteThis succession, whenever rehashed by different organizations, prompts a gathering of insufficiently planned sites. premium wordpress blog themes
ReplyDeleteI wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. theymakedesign
ReplyDeleteThanks for posting such an excellent read, i have bookmarked your site and will post it to my followers Web Designers Toronto
ReplyDeleteI love the way you write and share your niche! Very interesting and different! Keep it coming! design
ReplyDelete
ReplyDeleteارخص نقل عفش بالرياض ارخص شركة نقل عفش بالرياض
ارخص شركة نقل عفش بالرياض
They are over-burden with work and frequently, you won't think about them since they don't have time (or need) to showcase themselves. Webdesign
ReplyDeletePositive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. https://www.seoragno.com
ReplyDeleteTook me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! jasa pengiriman barang ke indonesia dari china
ReplyDeleteI think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. business setup dubai
ReplyDeleteExcellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. corner bathroom sink
ReplyDeleteWe all stand in awe at the genius behind simple strap lines that have the ability to recall entire branding messages.smm panel
ReplyDeleteI think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. forsage review
ReplyDeleteMaking an online presence could help you whether you sell things on the web or need to utilize the web to drive individuals to your neighborhood business. Professional graphic design
ReplyDeleteChoosing to begin a vocation in Website composition is the initial segment. The focal points are engaging. Webdesign
ReplyDeleteSite improvement specialists apply the freshest examination administration, which positively affects a site. SEO organizations are confronting incredible rivalry in the SEO field. Website laten maken
ReplyDeleteThank you for taking the time to publish this information very useful! SDWAN
ReplyDeleteHave you tried this brand naming firm’s new online course? Someone told me that it helped them learn how to brainstorm ideas on their own. Also, brainstorming resources were given for your own use after the session. business dialogs
ReplyDelete55% of the current SEOs in the market discover third party referencing to be the most monotonous and tedious work. Webdesign-seo-antwerpen.be
ReplyDeleteIt's the Ecommerce website design in USA that really can facilitate you to make the most of the internet based company techniques and process as well as it can permit you to conduct the internet based company in the most systematic method. https://www.sandeepmehta.co.in/affordable-seo-services-delhi/
ReplyDeletebuy electronics online in Pakistan at best prices delivered at your doorstep. Get free shipping.
ReplyDeleteFor the advancement of your firm, then, at that point you can generally trust the web designers.
ReplyDeletehttps://onohosting.com/
Making your web webpage can be an interesting interaction. Picking the best web design firm for your business web webpage is a vital choice.MavericksMedia
ReplyDeleteIf you are looking to hire a top-rated SEO company in Toronto, you have landed at the right place. We have over 10 years of experience in ranking websites from different industry verticals on top of the search results. Get in touch with us for more details.
ReplyDeleteThe categorisation is huge and so are the possibilities to get into it. You will need to use for the U.S. Civil offerings examinations to get a job within the Indian Administrative Service, Indian Police Service, Indian Foreign Service, and other comparable designations. It’s one of the maximum sought of Fresher jobs in India and calls in for lots of efforts to clear the exam. The pay may be 12 lakhs and
ReplyDeletetn govt jobs
1Solutions is the top-rated WordPress development company providing end-to-end digital solutions that include conceptualization, design, development, and marketing. Our WordPress websites are easy to manage and create a lasting impression. Get in touch for more details.
ReplyDeleteI can set up my new idea from this post. It gives in depth information. Thanks for this valuable information for all,.. Web Design Melbourne
ReplyDeleteMultilingua is the best foreign language institute in Delhi that offers the best in-its-class language Education, IELTS training & personalized guidance to students who wish to learn and are willing to try new and unfamiliar things. We are also one of the BEST language & IELTS coaching, IELTS Training Course, English Language Course, German Language Course, French Language Institute, Chinese Language Classes in Delhi, Language Translation services, provide training to a large number of students every year who are looking to work & study Abroad.
ReplyDeleteIf you are planning to study or work abroad then you have to take the IELTS test to prove your English language efficiency. Then you have to join the best IELTS Coaching in Delhi for the preparation IELTS test. We aim to develop the student completely. Hence, Multilingua gives training for all the four sections of IELTS, that is, reading, writing, listening, and speaking. All the courses and training are majorly crafted to make you shine in your exam. Mastering all four sections will help you gain a good pointers.
ReplyDeleteMultilingua is the best foreign language institute in Delhi that offers the best in-its-class language Education, IELTS training &personalized guidance to students who wish to learn and are willing totry new and unfamiliar things. We are also one of the BEST language &
ReplyDeleteIELTS coaching, IELTS Training Course, English Language Course, GermanLanguage Course, French Language Institute, Chinese Language Classesin Delhi, Language Translation services, provide training to a largenumber of students every year who are looking to work & study Abroad.
To place your page up and running, you need to hire two different services: a domain and a hosting service. https://onohosting.com/
ReplyDelete