简体   繁体   中英

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

<?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)."
  • <boolean xmlns='http://tempuri.org/'> was not expected.

我设法通过执行以下操作

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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