We know that each method within a WSDL must be unique; which leads to how to use overloading methods in our web services. Well, there is way to do it using the MessageName Property. Let’s look at the document web service example we built earlier here. Suppose we wanted to overload the GetDocument with chunky and chatty interfaces, here would be the signatures look like:
namespace DocumentWebService
{
/// <summary>
/// Gets document with SoapHeader Authentication
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
[WebMethod(Description = "Gets document with SoapHeader Authentication", MessageName = "GetDocumentChatty"),
SoapHeader("soapAuthHd")]
public byte[] GetDocument(string fileName)
{
// code goes here
}
/// <summary>
/// Gets document with parameter Authentication
/// </summary>
/// <param name="fileName"></param>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <returns></returns>
[WebMethod(Description = "Gets document with parameter Authentication", MessageName = "GetDocumentChunky")]
public byte[] GetDocument(string fileName, string userName, string password)
{
// code goes here
}
}
This, however, allows the client proxy’s to use the overloaded methods; like in this case GetDocument.
Love coding!
No comments:
Post a Comment