使用GET在ASMX Web服务可空类型不工作方法 [英] Methods with Nullable Types not working in ASMX Web Service using GET

查看:119
本文介绍了使用GET在ASMX Web服务可空类型不工作方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASMX Web服务设置为使用HTTP GET方法。它采取基本的字符串和Int参数的简单方法是确定工作,我可以叫 MyService.asmx /方法名?参数=值和XML获得回应。

I have an ASMX Web Service set up to use the HTTP GET method. Simple methods which take basic String and Int parameters are working ok, and I can call MyService.asmx/MethodName?Param=Value and get a response back in XML.

然而,当我有有一个可空INT(?即 INT )的方法,我得到这个错误:

However, when I have a method which has a nullable Int (i.e. int?), I get this error:

<方法名称> Web服务方法的名称是无效的。

该错误消息是混乱的,因为该方法确实存在,只是没有在GET范围。我相信这是因为可空类型太复杂通过URL传递,但我不能找到这个任何文件或SO帖子。

The error message is confusing, as the method does exist, just not in the GET scope. I presume this is because a nullable type is too complex to be passed via the URL, but I can't find any documentation or SO posts on this.

我对此表示赞赏复杂的类型,比如列表或自定义类等将无法正常工作使用GET,但我会假设一个简单的为空的int或为空的日期时间,可以在本机处理,只需通过检测它是否是从URL省略。猜猜它不是那么简单!

I appreciate that complex types like Lists or custom classes etc will not work using GET, but I would have assumed that a simple nullable int or nullable datetime could be handled natively, simply by detecting whether it was omitted from the URL. Guess it's not that simple!

任何意见或解决方法,将不胜感激。

Any advice or workarounds would be greatly appreciated.

谢谢,

推荐答案

可空int是不是太复杂。它应该产生

nullable int is not too complex. it should produce

  <s:element minOccurs="1" maxOccurs="1" name="Param" nillable="true" type="s:int" /> 

在WSDL。请查看这个帖子。该错误可能是别的东西,也许?

in WSDL. Check out this post. The error could be for something else, perhaps?

这篇关于使用GET在ASMX Web服务可空类型不工作方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆