在WEBSERVICE学习中遇到的问题

简介: 向我的WEBSERVICE发了一个这样的GET类的请求http://127.0.0.1/VegService.asmx/Getvegetable?vegetablename=cucumber然后得到报错  “/”应用程序中的服务器错误。
向我的WEBSERVICE发了一个这样的GET类的请求
http://127.0.0.1/VegService.asmx/Getvegetable?vegetablename=cucumber
然后得到报错
 

“/”应用程序中的服务器错误。

请求格式无法识别。

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidOperationException: 请求格式无法识别。

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

[InvalidOperationException: 请求格式无法识别。]
   System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +388
   System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +94
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +699
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +95
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173


版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

原webservice程序如下

img_a6339ee3e57d1d52bc7d02b338e15a60.gif < %@ WebService Language = " vb "  Class = " Vegetables.Vegservice " % >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifimports system
img_a6339ee3e57d1d52bc7d02b338e15a60.gifimports system.web.services
img_a6339ee3e57d1d52bc7d02b338e15a60.gifimports system.web.services.protocols
img_a6339ee3e57d1d52bc7d02b338e15a60.gifimports system.xml
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnamespace Vegetables
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif    
< webservice(namespace: = " http://hx66.com/net " ) > public  class Vegservice
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        inherits system.web.services.webservice
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif    
public  enum Appearance
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
Round
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        Bendy
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        Odd
img_a6339ee3e57d1d52bc7d02b338e15a60.gif    
end  enum
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif    
Public  structure Vegetable
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
public  VegName  as   string
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
public  VegColor  as   string
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
public  VegLooks  as  Appearance
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
public  NumberInStock  as   integer
img_a6339ee3e57d1d52bc7d02b338e15a60.gif    
end  structure
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
< webmethod() > Public   function  GetVegetable(byval vegetablename  as   string as  Vegetable
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
' Context.request.saveas("c:\VegServiceRequest.htm",false)
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
             dim  result  as  Vegetable
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
select   Case  vegetablename.tolower()
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                
case   " cucumber"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegName = " Cucumber"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegColor = " Green"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegLooks =  Appearance.Bendy
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    result.NumberInStock
= 10
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                
case   " sweetcorn"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegName = " Sweetcorn"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegColor = " Yellow"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegLooks =  Appearance.Odd
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    result.NumberInStock
= 2
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                
case   " potato"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegName = " Potato"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegColor = " Brown"
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
                    result.VegLooks =  Appearance. Round
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    result.NumberInStock
= 55
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                
case   else
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    
dim  code  as  xmlqualifiedname
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    code
= new  xmlqualifiedname( " Sender " , " http://schemas.xmlsoap.org/soap/envelope " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    
dim  doc  as  xmldocument
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    doc
= new  xmldocument()
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    
dim  detail  as  xmlelement
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    detail
= doc.createelement( " detail " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    
dim  veg  as  xmlelement
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    veg
= doc.createelement( " vegFault " , " vegetableName " , " http://www.hx66.com/net/vegservice/faults " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    veg.innertext
= vegetablename
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    detail.Appendchild(veg)
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    doc.appendchild(detail)
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                    throw 
new  soapexception( " Unknown vegetable. " ,code, " http://www.hx66.com/net/vegservice " ,doc)
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
end   select
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            return result
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
end function
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
< webmethod() > public   function  GetVegetables(byval vegetablenames  as   string ())  as  Vegetable()
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
' context.request.Saveas("c:\VegServiceRequest.htm",false)
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
             dim  results()  as  Vegetable
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            results
=   new  Vegetable(vegetablenames.length){}
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
dim  resultNum  as   integer
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
for  resultNum  =   0   to  results.length  -   1  step resultNum  +   1
img_a6339ee3e57d1d52bc7d02b338e15a60.gif                results(resultNum)
= GetVegetable(vegetablenames(resultNum))
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            
next
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif            return results
img_a6339ee3e57d1d52bc7d02b338e15a60.gif        
end function
img_a6339ee3e57d1d52bc7d02b338e15a60.gif    
end  class
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
end  namespace    

我在机器上是装了.net framework SDK的
这种情况我也不知道是什么原因了
好像是不接受GET方法
直接在页面点击方法提交参数还是可以的。

请高手帮帮忙!!!!
相关文章
|
测试技术 网络架构
|
JavaScript 数据格式 XML
webService学习之前奏
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.
847 0
|
Web App开发
【WebService学习】用思维导图和实例学习Web Service
作者:gnuhpc 出处:http://www.cnblogs.com/gnuhpc/ 1.SOAP消息: 2.WSDL 3.Web Service 4.实例: 1)Eclipse 以及Ant建立一个简单的Web Service,以演示Web Service的基本开发过程:http://blog.csdn.net/gnuhpc/archive/2009/12/22/5047951.aspx 2)QT SOAP 的一个实例: 开始学习时,看到网上有朋友说这个库难用,我觉得还好吧,蛮好使的,下边写一个例子。
1182 0
|
Java C# 应用服务中间件
java学习:调用 java web service
先写一个java的class:AwbModel(相当于要在web service中传输的实体对象) package webservicesample; public class AwbModel { private String _a1 = "_a1"; publ...
954 0