What is web method and all its various properties?
Adding [WebMethod()] attribute to a method within an XML Web service created using ASP.NET makes method callable from remote Web clients. This class cannot be inherited.the
By passing followingh properties, we can get additional capability or control over method behaviour.
Ex:
[WebMethod(Description="Obtains the Server Machine Name", EnableSession=true)]
public string GetMachineName()
{
return Server.MachineName;
}
Properties:

1. Windows-Based Security
Table 1: Comparing Windows-based and custom authentication techniques for Web services.
Can a method be overload in web services?
Method Overloading is outside paradigm of SOA as each method within a WSDL must be unique. Hence by default Web Services do not support Method Overloading.
Otherwise it leads to WSDL name clashes.
But .NET provides an alternative way to do it using the MessageName Property of the WebMethod Attribute which changes the method name in the WSDL.
Sample Code:
namespace TestOverloadingWebService
{
[WebService(Namespace = "http://tempuri.org/")]
public class OverloadingInWebService : System.Web.Services.WebService
{
[WebMethod(MessageName = "AddInt", EnableSession = true)]
public int Add(int a, int b)
{
return (a + b);
}
[WebMethod(MessageName = "AddFloat", EnableSession = true)]
public float Add(float a, float b)
{
return (a + b);
}
}
}
Adding [WebMethod()] attribute to a method within an XML Web service created using ASP.NET makes method callable from remote Web clients. This class cannot be inherited.the
By passing followingh properties, we can get additional capability or control over method behaviour.
Ex:
[WebMethod(Description="Obtains the Server Machine Name", EnableSession=true)]
public string GetMachineName()
{
return Server.MachineName;
}
Properties:
How to provide security in .NET web services
Following are few authentication technics to secure a .NET Web Services
1. Windows-Based Security
- Basic Windows Authentication
- Digest Windows Authentication
- Integrated Windows Authentication
2. Custom Authentication
- Log-in Method
- SOAP Headers
- SOAP header with cookie
- SOAP Extensions
- SOAP extension with encryption
Table 1: Comparing Windows-based and custom authentication techniques for Web services.
Can a method be overload in web services?
Method Overloading is outside paradigm of SOA as each method within a WSDL must be unique. Hence by default Web Services do not support Method Overloading.
Otherwise it leads to WSDL name clashes.
But .NET provides an alternative way to do it using the MessageName Property of the WebMethod Attribute which changes the method name in the WSDL.
Sample Code:
namespace TestOverloadingWebService
{
[WebService(Namespace = "http://tempuri.org/")]
public class OverloadingInWebService : System.Web.Services.WebService
{
[WebMethod(MessageName = "AddInt", EnableSession = true)]
public int Add(int a, int b)
{
return (a + b);
}
[WebMethod(MessageName = "AddFloat", EnableSession = true)]
public float Add(float a, float b)
{
return (a + b);
}
}
}
No comments:
Post a Comment