开发者

Method overloading in webservices

开发者 https://www.devze.com 2023-02-25 02:40 出处:网络
I have 2 question related to the web servic开发者_Go百科es. How we achieve the method overloading in web services.

I have 2 question related to the web servic开发者_Go百科es.

  1. How we achieve the method overloading in web services.
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号