I have 2 question related to the web servic开发者_Go百科es.
- How we achieve the method overloading in web services.
- How to implement security(authentication) in web services.
How we achieve the method overloading in web services.
If you are using SOAP you can't. Method names must have unique names in the exported WSDL. Depending on the technology you are using there are different ways to specify a method name. For example in WCF you could use the [OperationContract]
attribute to specify a name:
[ServiceContract]
public interface IMyService
{
[OperationContract(Name = "Foo")]
void Foo();
[OperationContract(Name = "FooWithId")]
void Foo(int id);
}
How to implement security(authentication) in web services.
The following guide is a very good start for implementing security in WCF.
Okay for overloading:
[WebMethod(MessageName = "MaxInt", Description = "Compare two int values
and return the max value", EnableSession = true)]
public int MaxValue(int a, int b)
{
return (a > b ? a : b);
}
[WebMethod(MessageName = "MaxFloat", Description = "Compare two float values
and return the max value", EnableSession = true)]
public float MaxValue(float a, float b)
{
return (a > b ? a : b);
}
What do you mean precisely by authentication? You can obviously use a validation key to access webservice. The question is confusing. Elaborate please.
精彩评论