/// <summary> /// Funkcja wysylajaca POST do serwisu. /// </summary> public void SendPostXml() { Feed f = new Feed() {Title = "Post feed"}; // wyslanie POST var response = _client.PostAsync("api/simple", new ObjectContent(typeof (Feed), f, new XmlMediaTypeFormatter())).Result; //albo response = _client.PostAsync("api/simple", new ObjectContent<Feed>(f, new XmlMediaTypeFormatter())).Result; }
// GET api/feed/5 public HttpResponseMessage Get() { int a = 100; var resultObj = new Feed() { Address = "http://www.wp.pl", CreatedAt = DateTime.Now, CreatedBy = "", Description = "Description", Title = "Title", UrlId = 1 }; return new HttpResponseMessage(){Content = new ObjectContent<Feed>(resultObj,new BufferedFeedFormatter("application/xml"),"application/xml")}; }
/// <summary> /// Funkcja wysylajaca PUT do serwisu. /// </summary> public void SendPutXml() { Feed f = new Feed() {Title = "Put feed"}; _client.PutAsync("api/simple", new ObjectContent<Feed>(f, new XmlMediaTypeFormatter())); }
/// <summary> /// Funkcja wykonujaca asynchronicznie POST. /// </summary> public async void SendAsyncPostXml() { Feed f = new Feed() { Title = "Post feed" }; var response = await _client.PostAsync("api/simple", new ObjectContent<Feed>(f, new XmlMediaTypeFormatter())); if (response.IsSuccessStatusCode) { } }
private SyndicationItem BuildSyndicationItem(Feed u) { var item = new SyndicationItem() { Title = new TextSyndicationContent(u.Title), BaseUri = new Uri(u.Address), LastUpdatedTime = u.CreatedAt, Content = new TextSyndicationContent(u.Description) }; item.Authors.Add(new SyndicationPerson() { Name = u.CreatedBy }); return item; }
public void Post(Feed f) { int a = 100; }