zoukankan      html  css  js  c++  java
  • 在WEBSERVICE学习中遇到的问题

    向我的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程序如下

    <%@ WebService Language="vb" Class="Vegetables.Vegservice"%>

    imports system
    imports system.web.services
    imports system.web.services.protocols
    imports system.xml

    namespace Vegetables


        
    <webservice(namespace:="http://hx66.com/net")>public class Vegservice
            inherits system.web.services.webservice

        
    public enum Appearance
            
    Round
            Bendy
            Odd
        
    end enum

        
    Public structure Vegetable
            
    public VegName as string
            
    public VegColor as string
            
    public VegLooks as Appearance
            
    public NumberInStock as integer
        
    end structure
            
    <webmethod()>Public function GetVegetable(byval vegetablename as stringas Vegetable
                
    'Context.request.saveas("c:\VegServiceRequest.htm",false)
                dim result as Vegetable

                
    select Case vegetablename.tolower()
                    
    case "cucumber"
                        result.VegName="Cucumber"
                        result.VegColor="Green"
                        result.VegLooks= Appearance.Bendy
                        result.NumberInStock
    =10
                    
    case "sweetcorn"
                        result.VegName="Sweetcorn"
                        result.VegColor="Yellow"
                        result.VegLooks= Appearance.Odd
                        result.NumberInStock
    =2
                    
    case "potato"
                        result.VegName="Potato"
                        result.VegColor="Brown"
                        result.VegLooks= Appearance.Round
                        result.NumberInStock
    =55
                    
    case else
                        
    dim code as xmlqualifiedname
                        code
    =new xmlqualifiedname("Sender","http://schemas.xmlsoap.org/soap/envelope")
                        
    dim doc as xmldocument
                        doc
    =new xmldocument()
                        
    dim detail as xmlelement
                        detail
    =doc.createelement("detail")
                        
    dim veg as xmlelement
                        veg
    =doc.createelement("vegFault","vegetableName","http://www.hx66.com/net/vegservice/faults")
                        veg.innertext
    =vegetablename
                        detail.Appendchild(veg)
                        doc.appendchild(detail)
                        throw 
    new soapexception("Unknown vegetable.",code,"http://www.hx66.com/net/vegservice",doc)
                
    end select
                return result
            
    end function

            
    <webmethod()>public function GetVegetables(byval vegetablenames as string()) as Vegetable()
                
    'context.request.Saveas("c:\VegServiceRequest.htm",false)
                dim results() as Vegetable
                results
    = new Vegetable(vegetablenames.length){}

                
    dim resultNum as integer
                
    for resultNum = 0 to results.length - 1 step resultNum + 1
                    results(resultNum)
    =GetVegetable(vegetablenames(resultNum))
                
    next

                return results
            
    end function
        
    end class
    end namespace    

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

    请高手帮帮忙!!!!
  • 相关阅读:
    数据结构之 内部排序---交叉排序(没啥特别的!!!)
    数据结构之 图论---基于邻接矩阵的广度优先搜索遍历(输出bfs遍历序列)
    数据结构之 图论---图的深度遍历( 输出dfs的先后遍历序列 )
    数据结构之 排序---折半插入排序(时间复杂度 O(nlog2 n) )
    HDU 1022 之 Train Problem I
    Bestcoder round 18---A题(素数筛+素数打表+找三个素数其和==n)
    Bestcoder round 18----B题(一元三次方程确定区间的最大值(包含极值比较))
    操作字典
    在线压缩图片
    JSON转C#实体类
  • 原文地址:https://www.cnblogs.com/aowind/p/111310.html
Copyright © 2011-2022 走看看