我试着去反序列化从响应这个简单的Web服务
即时通讯使用以下code:
的WebRequest请求= WebRequest.Create("http://inb374.jelastic.tsukaeru.net:8080/VodafoneDB/webresources/vodafone/04111111");
WebResponse的WS = request.GetResponse();
XmlSerializer的S =新的XmlSerializer(typeof运算(字符串));
串效应初探=(字符串)s.Deserialize(ws.GetResponseStream());
解决方案
XmlSerializer的声明作为
XmlSerializer的S =新的XmlSerializer(typeof运算(字符串),新XmlRootAttribute(回应));
就足够了。
Im trying to deserialize the response from this simple web service
Im using the following code:
WebRequest request = WebRequest.Create("http://inb374.jelastic.tsukaeru.net:8080/VodafoneDB/webresources/vodafone/04111111");
WebResponse ws = request.GetResponse();
XmlSerializer s = new XmlSerializer(typeof(string));
string reponse = (string)s.Deserialize(ws.GetResponseStream());
解决方案
Declaring XmlSerializer as
XmlSerializer s = new XmlSerializer(typeof(string),new XmlRootAttribute("response"));
is enough.