在WEBSERVICE学习中遇到的问题
2005-03-02 11:14
435 查看
向我的WEBSERVICE发了一个这样的GET类的请求
http://127.0.0.1/VegService.asmx/Getvegetable?vegetablename=cucumber
然后得到报错
“/”应用程序中的服务器错误。
异常详细信息: System.InvalidOperationException: 请求格式无法识别。
源错误:
堆栈跟踪:
版本信息: 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 string) as 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方法
直接在页面点击方法提交参数还是可以的。
请高手帮帮忙!!!!
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 |
原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 string) as 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方法
直接在页面点击方法提交参数还是可以的。
请高手帮帮忙!!!!
相关文章推荐
- 学习中遇到的c++问题,持续更新
- 学习中遇到的问题-关于set_new_handler()
- 记录自己学习心得以及工作中遇到问题的总结
- 在w3c学习angular2遇到的问题
- 自学习Django中遇到的一些问题
- javascript学习过程中遇到的问题序列
- osg学习示例之遇到问题四骨骼动画编译osgCal
- python学习中遇到的问题
- 刚学习遇到的问题
- vs学习中遇到的问题总结
- docker学习遇到的问题
- Qt学习中遇到的问题
- openclinica学习遇到的问题
- 学习VC、MFC中遇到的各种问题及解决办法
- ok6410学习遇到问题汇总
- webservice 接口的实现和实现过程所遇到的问题!!
- 机器学习实战-KNN算法实现及遇到的问题总结
- 近期学习javascript和jquery遇到一些问题的技巧知识总结
- 近期学习javascript和jquery遇到一些问题的技巧知识总结
- SSH-Struts第四弹:Struts2学习过程中遇到的问题