Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ASP.NET Web服务中接收XML?_C#_Asp.net_Xml_Web Services_Security - Fatal编程技术网

C# 如何在ASP.NET Web服务中接收XML?

C# 如何在ASP.NET Web服务中接收XML?,c#,asp.net,xml,web-services,security,C#,Asp.net,Xml,Web Services,Security,我有一个准RESTful ASP.NET web服务,我希望能够将XML发布到该服务。我的方法如下所示: [WebMethod(false, System.EnterpriseServices.TransactionOption.NotSupported)] public void save(string saveXml) { XDocument saveXml = XDocument.Parse(saveXml); .... 当我尝试发布到该web服务时,会出现异常: Sys

我有一个准RESTful ASP.NET web服务,我希望能够将XML发布到该服务。我的方法如下所示:

[WebMethod(false, System.EnterpriseServices.TransactionOption.NotSupported)]
public void save(string saveXml)
{
    XDocument saveXml = XDocument.Parse(saveXml);
    ....
当我尝试发布到该web服务时,会出现异常:

System.Web.HttpRequestValidationException: A potentially dangerous Request.Form
value was detected from the client...

根据一些搜索,我的理解是,所有对ASP.NET页面的请求都会查找类似“的字符,新的4.0 RequestValidation模型有点挑剔,但只要您的客户端将HTTP请求
内容类型
头作为
文本/xml
而不是
应用程序/x-www-form-urlencoded
发送,它就应该通过(或者干脆绕开)ASP.NET RequestValidation.

您也可以对XML字符串进行base64编码。En/decoding base64非常简单,可以避免此类配置问题。什么样的客户端将发布到此服务?当您遇到此异常时,您将如何发布?此外,这可能暗示是停止使用ASP.NET Web服务的时候了,这是一个“遗留技术"@John Saunders:客户端是一个Flex应用程序。我知道还有其他几个更好的选择,但由于时间限制,我必须使用应用程序中已设置的内容。web服务是否在单独的IIS应用程序中?此异常是为了保护您的网站。如果该服务位于不同的应用程序中,则该网站,那么你将不会得到错误。