Web服务中的重载方法 [英] Overloading Method in Web Services
本文介绍了Web服务中的重载方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
i我在网络服务中使用Web服务我有2种重载方法
[Webmethod]
Ex:Public void Add()
{
}
[Webmethod]
public void添加(字符串a)
{
}
如果我编译那段时间我收到错误使用MessageName WebMethod自定义属性的属性,用于指定方法的唯一消息名称。
你可以帮助我..
Hi Friends,
i am using Web services in that webservices i have 2 overload methods
[Webmethod]
Ex:Public void Add()
{
}
[Webmethod]
public void Add(string a)
{
}
if i compile that time i got Error "Use the MessageName property of the WebMethod custom attribute to specify unique message names for the methods."
can you help Me..
推荐答案
Google发布之前
Web服务需要唯一标识每个方法,因此我们需要通过设置MessageName属性为方法提供别名。 />
例如
Google before you post
Web service needs to identify each method uniquely hence we need to give alias to the methods by setting the MessageName property.
e.g.
[WebMethod(MessageName = "SinInt")]
[WebMethod(MessageName = "CosInt")]
[WebMethod(MessageName = "TanInt")]
解决方案1 :
步骤1:更新Web服务绑定
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] to
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
Setp 2:如上所述使用上面建议的不同消息名称
[WebMethod(MessageName =SinInt)]
[WebMethod(MessageName =CosInt)]
解决方案2:如果可能尝试使用不同的方法名称。
Happy Coading ....
Solution 1 :
Step 1: update Web Service Binding
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] to
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
Setp 2 : As suggested above use different message name like suggested above
[WebMethod(MessageName = "SinInt")]
[WebMethod(MessageName = "CosInt")]
Solution 2 : If possibe try to use different Method name.
Happy Coading....
这篇关于Web服务中的重载方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文