{"action":"closed","number":5454,"pull_request":{"url":"https://api.github.com/repos/aspnet/Mvc/pulls/5454","id":90917356,"html_url":"https://github.com/aspnet/Mvc/pull/5454","diff_url":"https://github.com/aspnet/Mvc/pull/5454.diff","patch_url":"https://github.com/aspnet/Mvc/pull/5454.patch","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/5454","number":5454,"state":"closed","locked":false,"title":"XmlResult and FromBodyXmlAttribute new features in the  project \"Microsoft.AspNetCore.Mvc.Formatters.Xml\".","user":{"login":"Wallsmedia","id":22687550,"avatar_url":"https://avatars.githubusercontent.com/u/22687550?v=3","gravatar_id":"","url":"https://api.github.com/users/Wallsmedia","html_url":"https://github.com/Wallsmedia","followers_url":"https://api.github.com/users/Wallsmedia/followers","following_url":"https://api.github.com/users/Wallsmedia/following{/other_user}","gists_url":"https://api.github.com/users/Wallsmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wallsmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wallsmedia/subscriptions","organizations_url":"https://api.github.com/users/Wallsmedia/orgs","repos_url":"https://api.github.com/users/Wallsmedia/repos","events_url":"https://api.github.com/users/Wallsmedia/events{/privacy}","received_events_url":"https://api.github.com/users/Wallsmedia/received_events","type":"User","site_admin":false},"body":"### Reasons for adding these features into the aspnet/MVC project:\n1. When ASP.NET CORE is using as the base for development for Web REST API there is no controllable by code flexibility to have deal with flat XML and DataContract XML.\n2. Without work around, Indeed, it is possible to use only one type of XML formatters per application.\n3.  Currently used ObjectResult cannot provide the compulsory return XML or DataContract XML as an action result. \n4. The order of applying:  \n       services.AddMvc().AddXmlDataContractSerializerFormatters().AddXmlSerializerFormatters();\n   and  \n       services.AddMvc().AddXmlSerializerFormatters().AddXmlDataContractSerializerFormatters();\n   affects on using the type of xml formatters for Content Type : \"application/xml\"\n\nTo improve the quality and flexibility  XML based Web REST API were developed the following features:\n### \"XmlResult\" feature:\n\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\XmlResult.cs (new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\Internal\\XmlDcResultExecutor.cs (new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\Internal\\XmlResultExecutor.cs (new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\Internal\\XmlResultExecutorBase.cs (new)\n\\Mvc\\test\\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test\\XmlResultTest.cs(new)\n\\Mvc\\test\\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test\\Models\\PurchaseOrder.cs(new, shared)\n\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\DependencyInjection\\MvcXmlMvcBuilderExtensions.cs(changes, shared)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\DependencyInjection\\MvcXmlMvcCoreBuilderExtensions.cs(changes, shared)\n### Description:\n1. The XmlResult is the similar feature to JsonResult in project \"Microsoft.AspNetCore.Mvc.Formatters.Json\".\n2. It allows to return Xml formatted response in the body, as Action result.\n3. This feature improve the  consistence of the type XML used formatter.\n4. XmlResult allows to return XML serialized object with using ether \"DataContractSerializer\" ether \"XmlSerializer\". It allows to satisfy all REST communication scenarios from JAVA  to .NET.\n### Example of using in the application:\n\nStartup.cs\n\n```\npublic void ConfigureServices(IServiceCollection services)\n        {\n            // Add framework services.\n            services.AddMvc().AddXmlDataContractSerializerFormatters().AddXmlSerializerFormatters();\n        }\n\nController: \n\n```\n\n```\n// GET api/[controller]/xml\n    [HttpGet(\"xml\")]\n    public ActionResult GetXmlObject()\n    {\n        object obj = new PurchaseOrder();\n        return new XmlResult(obj);\n    }\n\n    // GET api/[controller]/dcxml\n    [HttpGet(\"dcxml\")]\n    public ActionResult GetDcXmlObject()\n    {\n        object obj = new PurchaseOrder();\n        return new XmlResult(obj) { XmlSerializerType = XmlSerializerType.DataContractSerializer };\n    }\n```\n### \"FromBodyXmlAttribute\" feature:\n\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\FromBodyXmlAttribute.cs(new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\ModelBinding\\Binders\\BodyXmlModelBinder.cs(new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\ModelBinding\\Binders\\BodyXmlModelBinderOnly.cs(new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\ModelBinding\\Binders\\BodyDcXmlModelBinder.cs(new)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\ModelBinding\\Binders\\BodyDcXmlModelBinderOnly.cs(new)\n\\Mvc\\test\\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test\\Models\\Binders\\BodyXmlModelBindersTest.cs(new)\n\\Mvc\\test\\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test\\Models\\PurchaseOrder.cs(new, shared)\n\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\DependencyInjection\\MvcXmlMvcBuilderExtensions.cs(changes, shared)\n\\Mvc\\src\\Microsoft.AspNetCore.Mvc.Formatters.Xml\\DependencyInjection\\MvcXmlMvcCoreBuilderExtensions.cs(changes, shared)\n### Description:\n\nFromBodyXmlAttribute forces try to get  XML serialized object from the http request body with using ether \"DataContractSerializer\" or \"XmlSerializer\".\n### Example of using in the application:\n\nStartup.cs\n\n```\npublic void ConfigureServices(IServiceCollection services)\n        {\n            // Add framework services.\n            services.AddMvc().AddXmlDataContractSerializerFormatters().AddXmlSerializerFormatters();\n        }\n\n```\n\nController: \n\n``````\n```\n// POST api/[controller]/xml\n    [HttpPost(\"xml\")]\n    public void PostXml([FromBodyXml]PurchaseOrder value)\n    {\n        var x = value;\n        x.billTo.street += \" 123\";\n    }\n\n    // POST api/[controller]/dcxml\n    [HttpPost(\"dcxml\")]\n    public void PostDcXml([FromBodyXml(XmlSerializerType = XmlSerializerType.DataContractSerializer)]PurchaseOrder value)\n    {\n        var x = value;\n        x.billTo.street += \"No -10\";\n   }\n``````\n\nWhere:\n\n```\n   [DataContract (Namespace =\"http://puchase.Interface.org/Purchase.Order\")]\n    public class PurchaseOrder\n    {\n        public PurchaseOrder()\n        {\n            billTo = new Address() { street = \"Bill to Address\" };\n            shipTo = new Address() { street = \"Ship to  Address\" };\n        }\n        [DataMember]\n        public Address billTo;\n        [DataMember]\n        public Address shipTo;\n    }\n\n\n    [DataContract(Namespace = \"http://puchase.Interface.org/Purchase.Order.Address\")]\n    public class Address\n    {\n        [DataMember]\n        public string street;\n    }\n```\n","created_at":"2016-10-26T00:36:40Z","updated_at":"2016-11-01T08:23:13Z","closed_at":"2016-11-01T08:23:13Z","merged_at":null,"merge_commit_sha":"4b80cdcadb83d85d9be4f73000c7277196590ca6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Mvc/pulls/5454/commits","review_comments_url":"https://api.github.com/repos/aspnet/Mvc/pulls/5454/comments","review_comment_url":"https://api.github.com/repos/aspnet/Mvc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/5454/comments","statuses_url":"https://api.github.com/repos/aspnet/Mvc/statuses/c1375e1bbc9f52892fc35a828673debba2828dce","head":{"label":"Wallsmedia:wm/xmlresult.dev","ref":"wm/xmlresult.dev","sha":"c1375e1bbc9f52892fc35a828673debba2828dce","user":{"login":"Wallsmedia","id":22687550,"avatar_url":"https://avatars.githubusercontent.com/u/22687550?v=3","gravatar_id":"","url":"https://api.github.com/users/Wallsmedia","html_url":"https://github.com/Wallsmedia","followers_url":"https://api.github.com/users/Wallsmedia/followers","following_url":"https://api.github.com/users/Wallsmedia/following{/other_user}","gists_url":"https://api.github.com/users/Wallsmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wallsmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wallsmedia/subscriptions","organizations_url":"https://api.github.com/users/Wallsmedia/orgs","repos_url":"https://api.github.com/users/Wallsmedia/repos","events_url":"https://api.github.com/users/Wallsmedia/events{/privacy}","received_events_url":"https://api.github.com/users/Wallsmedia/received_events","type":"User","site_admin":false},"repo":{"id":71068887,"name":"Mvc","full_name":"Wallsmedia/Mvc","owner":{"login":"Wallsmedia","id":22687550,"avatar_url":"https://avatars.githubusercontent.com/u/22687550?v=3","gravatar_id":"","url":"https://api.github.com/users/Wallsmedia","html_url":"https://github.com/Wallsmedia","followers_url":"https://api.github.com/users/Wallsmedia/followers","following_url":"https://api.github.com/users/Wallsmedia/following{/other_user}","gists_url":"https://api.github.com/users/Wallsmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wallsmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wallsmedia/subscriptions","organizations_url":"https://api.github.com/users/Wallsmedia/orgs","repos_url":"https://api.github.com/users/Wallsmedia/repos","events_url":"https://api.github.com/users/Wallsmedia/events{/privacy}","received_events_url":"https://api.github.com/users/Wallsmedia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Wallsmedia/Mvc","description":"ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor.","fork":true,"url":"https://api.github.com/repos/Wallsmedia/Mvc","forks_url":"https://api.github.com/repos/Wallsmedia/Mvc/forks","keys_url":"https://api.github.com/repos/Wallsmedia/Mvc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wallsmedia/Mvc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wallsmedia/Mvc/teams","hooks_url":"https://api.github.com/repos/Wallsmedia/Mvc/hooks","issue_events_url":"https://api.github.com/repos/Wallsmedia/Mvc/issues/events{/number}","events_url":"https://api.github.com/repos/Wallsmedia/Mvc/events","assignees_url":"https://api.github.com/repos/Wallsmedia/Mvc/assignees{/user}","branches_url":"https://api.github.com/repos/Wallsmedia/Mvc/branches{/branch}","tags_url":"https://api.github.com/repos/Wallsmedia/Mvc/tags","blobs_url":"https://api.github.com/repos/Wallsmedia/Mvc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wallsmedia/Mvc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wallsmedia/Mvc/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wallsmedia/Mvc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wallsmedia/Mvc/statuses/{sha}","languages_url":"https://api.github.com/repos/Wallsmedia/Mvc/languages","stargazers_url":"https://api.github.com/repos/Wallsmedia/Mvc/stargazers","contributors_url":"https://api.github.com/repos/Wallsmedia/Mvc/contributors","subscribers_url":"https://api.github.com/repos/Wallsmedia/Mvc/subscribers","subscription_url":"https://api.github.com/repos/Wallsmedia/Mvc/subscription","commits_url":"https://api.github.com/repos/Wallsmedia/Mvc/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wallsmedia/Mvc/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wallsmedia/Mvc/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wallsmedia/Mvc/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wallsmedia/Mvc/contents/{+path}","compare_url":"https://api.github.com/repos/Wallsmedia/Mvc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wallsmedia/Mvc/merges","archive_url":"https://api.github.com/repos/Wallsmedia/Mvc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wallsmedia/Mvc/downloads","issues_url":"https://api.github.com/repos/Wallsmedia/Mvc/issues{/number}","pulls_url":"https://api.github.com/repos/Wallsmedia/Mvc/pulls{/number}","milestones_url":"https://api.github.com/repos/Wallsmedia/Mvc/milestones{/number}","notifications_url":"https://api.github.com/repos/Wallsmedia/Mvc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wallsmedia/Mvc/labels{/name}","releases_url":"https://api.github.com/repos/Wallsmedia/Mvc/releases{/id}","deployments_url":"https://api.github.com/repos/Wallsmedia/Mvc/deployments","created_at":"2016-10-16T18:26:08Z","updated_at":"2016-10-16T18:26:15Z","pushed_at":"2016-10-27T19:54:57Z","git_url":"git://github.com/Wallsmedia/Mvc.git","ssh_url":"git@github.com:Wallsmedia/Mvc.git","clone_url":"https://github.com/Wallsmedia/Mvc.git","svn_url":"https://github.com/Wallsmedia/Mvc","homepage":"","size":24027,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"wm/xmlresult.dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"1ac731519a5858397a9870c43f3881ee8bbf6b09","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":15126429,"name":"Mvc","full_name":"aspnet/Mvc","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Mvc","description":"ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor.","fork":false,"url":"https://api.github.com/repos/aspnet/Mvc","forks_url":"https://api.github.com/repos/aspnet/Mvc/forks","keys_url":"https://api.github.com/repos/aspnet/Mvc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Mvc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Mvc/teams","hooks_url":"https://api.github.com/repos/aspnet/Mvc/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Mvc/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Mvc/events","assignees_url":"https://api.github.com/repos/aspnet/Mvc/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Mvc/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Mvc/tags","blobs_url":"https://api.github.com/repos/aspnet/Mvc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Mvc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Mvc/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Mvc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Mvc/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Mvc/languages","stargazers_url":"https://api.github.com/repos/aspnet/Mvc/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Mvc/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Mvc/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Mvc/subscription","commits_url":"https://api.github.com/repos/aspnet/Mvc/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Mvc/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Mvc/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Mvc/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Mvc/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Mvc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Mvc/merges","archive_url":"https://api.github.com/repos/aspnet/Mvc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Mvc/downloads","issues_url":"https://api.github.com/repos/aspnet/Mvc/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Mvc/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Mvc/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Mvc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Mvc/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Mvc/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/Mvc/deployments","created_at":"2013-12-12T03:54:00Z","updated_at":"2016-11-01T08:20:19Z","pushed_at":"2016-10-31T23:23:36Z","git_url":"git://github.com/aspnet/Mvc.git","ssh_url":"git@github.com:aspnet/Mvc.git","clone_url":"https://github.com/aspnet/Mvc.git","svn_url":"https://github.com/aspnet/Mvc","homepage":"","size":59733,"stargazers_count":3636,"watchers_count":3636,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1439,"mirror_url":null,"open_issues_count":379,"forks":1439,"open_issues":379,"watchers":3636,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/5454"},"html":{"href":"https://github.com/aspnet/Mvc/pull/5454"},"issue":{"href":"https://api.github.com/repos/aspnet/Mvc/issues/5454"},"comments":{"href":"https://api.github.com/repos/aspnet/Mvc/issues/5454/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/5454/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/5454/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Mvc/statuses/c1375e1bbc9f52892fc35a828673debba2828dce"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":2,"review_comments":0,"commits":1,"additions":1342,"deletions":6,"changed_files":24}}
{"actor":{"display_login":"Wallsmedia"}}