Method overloading in webservices created with Visual Studio 2005
When creating a webservice in Visual Studio 2005, the IDE adds the following WebServiceBinding:
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
This line indicates that your webservice conforms to the Web Services Interopability Organization's (WS-I) Baisc Profile 1.1. The Basic Profile defines a set of rules to which your webservice must conform.
One of its rules is that the webservice may not include method overloading. If you run a webservice that uses method overloading lile the one below, you will receive an errormessage telling that your service is not conform to WS-I Basic Profile v1.1:
Code:
using System.Web.Services;
using System.Web.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{[WebMethod(MessageName = "HelloWorld")]
public string HelloWorld(){return "Hello World";}[WebMethod(MessageName = "HelloWorldWithName")]public string HelloWorld(string name){return "Hello world " + name;}
}
Exception:
Message: Service 'Service' does not conform to WS-I Basic Profile V1.1. Please examine each of the normative statement violations below ...
To be able to still use method overloading, you need to change the WebServiceBinding as follows:
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
References:
0 comments:
Post a Comment