简体   繁体   English

Asp.net中的Web服务

[英]Webservices in Asp.net

I have the following webmethod in my application 我的应用程序中有以下网络方法

[WebMethod]
public bool Test(string id)
{
    return true;
}

using WebRequest.Create(..) I get the following xml file 使用WebRequest.Create(..)我得到以下xml文件

<?xml version="1.0" encoding="utf-8"?>
<boolean xmlns="http://tempuri.org/">true</boolean>

and using the following code 并使用以下代码

 XmlSerializer ser = new XmlSerializer(typeof(bool));
 var result = (bool)ser.Deserialize(responseStream);

I get the following exception 我得到以下异常

  • "There is an error in XML document (2, 2)." “ XML文档(2,2)中存在错误。”
  • <boolean xmlns='http://tempuri.org/'> was not expected.

我设法通过执行以下操作

XmlSerializer serializer = new XmlSerializer(typeof(T), "http://tempuri.org/");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM