我有 2 个与网络服务相关的问题。
- 我们如何在 Web 服务中实现方法重载。
- 如何在网络服务中实现安全(身份验证)。
最佳答案
How we achieve the method overloading in web services.
如果您使用的是 SOAP,则不能。方法名称在导出的 WSDL 中必须具有唯一名称。根据您使用的技术,有不同的方法来指定方法名称。例如,在 WCF 中,您可以使用 [OperationContract]
指定名称的属性:
[ServiceContract]
public interface IMyService
{
[OperationContract(Name = "Foo")]
void Foo();
[OperationContract(Name = "FooWithId")]
void Foo(int id);
}
How to implement security(authentication) in web services.
following guide是在 WCF 中实现安全性的良好开端。
关于c# - Web服务中的方法重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5689033/