webserice bug大全

1.调用webservice经常会出现 因 URL 意外地以“/HelloWorld”结束,请求格式无法识别”的错误,那是因为webservice没有指定提交方式,post还是get

只要在web.config的 <system.web> 节点下加入   
<webServices> 
  <protocols> 
  <add name= "HttpPost " />  
<add name= "HttpGet " /> 
  </protocols> 
</webServices>

就好了,但一般还是不行,因为我们的参数一般是通过session提交的,而post的方式提交过去是没有sessionid的,所以一般暴找不到参数的错误如下:

System.InvalidOperationException: 缺少参数: a。
   在 System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
   在 System.Web.Services.Protocols.UrlParameterReader.Read(HttpRequest request)
   在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

有两种方法可以解决,一种是指定get方法传输,它是保存sessionid的,也就是去掉web.config里面的<add name= "HttpPost " />就可以了

还有一种是更好的方法,就是在webservice里的method方法上面明文引用session

http://www.dotblogs.com.tw/rainmaker/archive/2009/09/19/10717.aspx

此网址是解决方法,不过我没试过;有兴趣的可以一试

Crazy Cherry:everything is possible!
原文地址:https://www.cnblogs.com/userbibi/p/webservice.html