【问题标题】:Sending Xml from $http in Angularjs to webapi从Angularjs中的$http发送Xml到webapi
【发布时间】:2017-10-23 01:47:36
【问题描述】:

我有一个 webapi 方法,并且在 Angular 应用程序中低于 $http 服务调用:-

[HttpPost]
Public Employee Getdata ([FROMBODY] XElement  objxml)
{ }


$http({
url : wwww.google.com,
method : 'POST',
data : $.param({
        xml: vm.inputxml
       }),
headers : {'Content-Type' : 'application/xml'}
})

vm.inputxml 只不过是粘贴在 html 页面上的 xml。

这里的问题是 webapi 抛出一个错误, “反序列化 system.xml.linq.Xelement 类型的对象时出错,根级别的数据无效”。

您能否建议我们如何将 xml 从 angular 发送到 webapi。 Web api 输入类型 Xleelement 不能更改,或者它只能接受 xml 类型作为 xmlreader 等,但 i/p 不能更改为字符串。 请提出方法..将非常感谢您的帮助。

【问题讨论】:

标签: c# angularjs asp.net-mvc asp.net-web-api2


【解决方案1】:

直接使用试试吧:

$http({
    url : wwww.google.com,
    method : 'POST',
    data : vm.inputxml,
    headers : {'Content-Type' : 'application/xml'}
})

见:POST-ing XML in AngularJS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 2015-05-11
    • 2015-04-15
    • 1970-01-01
    • 2017-04-15
    • 2018-04-19
    • 1970-01-01
    相关资源
    最近更新 更多