我的ASMX代理方法中有哪些额外参数?
如果我将.NET 1.1客户端的Web引用添加到WCF服务,则客户端生成的代理方法包含一个额外的参数,以每个服务方法参数的后缀’Specified’结尾,例如
[OperationContract] string HelloWorld(string foo, int bar);
结果是:
Service1.HelloWorld(string foo, bool fooSpecified, int bar, bool barSpecified);
我的服务参数不是可选的,所以客户端的这些额外参数是什么,我怎样才能摆脱它们?
这是由于WCF和ASMX Web服务中使用的序列化机制不同。 要避免额外的参数,必须在ServiceContract上指定XmlSerializerFormat属性。
添加阅读: http : //msmvps.com/blogs/windsor/archive/2008/05/17/calling-wcf-services-from-net-1-1.aspx
当允许不存在时,问题在于值类型的参数。 没有*specified
参数,.NET 1.1无法指定它。 需要将它们设置为true以指示正在发送相应的参数。
.NET 1.1 Web服务没有null概念,因此WCF会为您生成这些额外的属性。 fooSpecified = false表示foo确实为null。
你可能需要你的参数是必需的
[OperationContract] string HelloWorld([RequiredDataParameter] string foo, [RequiredDataParameter] int bar);